Why won't some MP4 videos start streaming until the entire file is downloaded?

Sujeet picture Sujeet · Nov 24, 2011 · Viewed 9.6k times · Source

I'm working on an application where users upload a video and play it back the browser using jwplayer, jplayer, flowplayer, etc. Some videos play immediately, while others wait until the entire video file has been downloaded.

I'm using ffmpeg to convert the video to mp4 format.

Here is some detailed information about one of the video files I tried.

General
Complete name                    : 429183132058337290450_AutoFF.mp4
Format                           : MPEG-4
Format profile                   : Base Media
Codec ID                         : isom
File size                        : 10.2 MiB
Duration                         : 24s 333ms
Overall bit rate                 : 3 501 Kbps

Video
ID                               : 1
Format                           : AVC
Format/Info                      : Advanced Video Codec
Format profile                   : [email protected]
Format settings, CABAC           : Yes
Format settings, ReFrames        : 3 frames
Codec ID                         : avc1
Codec ID/Info                    : Advanced Video Coding
Duration                         : 24s 333ms
Bit rate mode                    : Variable
Bit rate                         : 3 351 Kbps
Width                            : 1 024 pixels
Height                           : 560 pixels
Display aspect ratio             : 16:9
Frame rate mode                  : Constant
Frame rate                       : 30.000 fps
Color space                      : YUV
Chroma subsampling               : 4:2:0
Bit depth                        : 8 bits
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.195
Stream size                      : 9.72 MiB (96%)
Language                         : Japanese

Answer

Aleks G picture Aleks G · Nov 24, 2011

I had this problem with some MP4 videos as well. I was converting uploaded videos to mp4 (h.264 + aac) and they wouldn't buffer. The reason is that this format contains some important metadata required for the playback at the end of the file, hence the entire file has to be loaded before the playback can start. The solution was to use a tiny program called qt-faststart (https://github.com/danielgtaylor/qtfaststart) on the result of the conversion. This program relocates this metadata to the beginning of the file making progressive-download playback possible.