Converted mp4 h264 baseline format loads long time

2019-03-01 17:01发布

问题:

I have converted my video to mp4 x264 baseline format and it works fine with all pc/mobile phones , the problem is it takes long time to load the video while googling came to know that ffmpeg converts and sets the index file at the eof the video so it loads to the end to read and then plays the video, So any advices would be appreciatable to cut short the loading time. Note:tryied out QT index swapper2 but dint give much difference , please advice .

this is the cmd i used to convert -

ffmpeg -i … -c:v libx264 -profile:v baseline -level 1 …

Thanks for your time .

回答1:

You have several options to relocate the moov atom so the video can begin playback before it is completely downloaded by the client.

-movflags faststart

The easiest is the option -movflags faststart when re-encoding:

ffmpeg -i input -c:v libx264 -profile:v baseline -movflags faststart output.mp4

If you already encoded your .mp4 file, but simply want to move the atom:

ffmpeg -i input.mp4 -codec copy -movflags faststart output.mp4

You may need to get a more recent ffmpeg version to use this option. See the FFmpeg download page for links to ffmpeg builds for Linux, OS X, and Windows, or you can follow a step-by-step guide to compile ffmpeg.

qt-faststart

Alternatively you can use the qt-faststart tool that comes with the ffmpeg source:

cd ~/ffmpeg/tools
make qt-faststart
./qt-faststart input.mp4 output.mp4

MP4Box

Or you could use MP4Box (usually provided by the gpac package depending on your distro):

MP4Box -add input.mp4 output.mp4

Also See

  • FFmpeg and x264 Encoding Guide
  • FFmpeg and AAC Audio Encoding Guide


标签: ffmpeg