Swapping index of an MP4 file with FFMpeg

4

1

I run a web application which provides a few videos on it. Those videos are being displayed with a flash-video-player.

Unfortunately, the index of those container-files is at the end of the file, so the whole 2GB video has to be loaded until the playback can start.

Q: Is there a way with FFMpeg to swap the MP4-Container-index to the front of the file?

fubo

Posted 2014-12-11T12:58:21.320

Reputation: 173

Answers

7

You want to move the moov atom to the beginning. While encoding you can use:

ffmpeg -i inputfile [other parameters] -movflags +faststart outputfile.mp4

If they have been encoded already, you can simply copy streams without re-encoding:

ffmpeg -i input.mp4 -codec copy -map 0 -movflags +faststart output.mp4

You can also use the qt-fasstart tool. This needs to be compiled in the tools directory of ffmpeg. The command is simply:

qt-faststart inputfile.mp4 outputfile.mp4

There are windows binaries available.

Rajib

Posted 2014-12-11T12:58:21.320

Reputation: 2 406