Wednesday, August 20, 2014

Video is not streaming in Safari and Iphone

This may happen due to

RequestHeader unset Range
Header unset Accept-Ranges

>>Why do we need above configuration?
We do this to fix "Range header DoS vulnerability Apache HTTPD 1.3/2.x" issue. For details please check @

>>Does iPhone/iPad Safari require 'Accept-Ranges' header for video?
Yes. It requires these headers.Please find the apple documentation for the same.

>>Any other solution?
Actually we can use another fix as suggested @ . It is as below.

SetEnvIf Range (,.*?){5,} bad-range=1
RequestHeader unset Range env=bad-range

Here we are rejecting request when more than 5 ranges. But we can put very high value too.Please check these lines in same document.

The number 5 is arbitrary. Several 10's should not be an issue and may be
required for sites which for example serve PDFs to very high end eReaders
or use things such complex http based video streaming.

We will enable "Accept-Ranges" at .htaccess file for .mp4 videos only as below.


Header set Accept-Ranges bytes


other ffmpeg help link-

Issue 1: Audio was not playing
Cause: Sample rate of the audio file did not match with the sample rate of the video.
Check videos sample rate-- ffmpeg -i video.mp4
Use the flag -ar to specify Sample rate of audio.

Issue 2: Video was not streaming.
~~~~~: Video should be "Progressive" in nature. Video should provides its meta info at the beginning so that it playback as soon as possible.
Use the following command:

qt-faststart output.mp4 output1.mp4


Final commands:
1) ffmpeg -i video.mp4 -i test.mp3 -vcodec copy -acodec aac -strict experimental -shortest output.mp4
2) qt-faststart output.mp4 output1.mp4