13

When running "qt-faststart" on an MP4, you're essentially taking the meta data from the back and placing it at the front of the file. In my case, so Flash can properly start playing the video before it's fully done loading.

I have a large number of videos that I'm running through a shell script to encode overnight. When I upload, however, I won't necessarily know in my final folder of videos (on the server) have "qt-faststart" run on it.

My goal is to find the straggler videos and run qt-faststart on them manually, but I'll need a way to compile a list. Is there any way to check for this meta data information with PHP or something? Wondering how I can tell if a video has already had qt-faststart run on it or not.

3 Answers 3

20
mediainfo -f file.mp4 | grep IsStreamable 

or

ffprobe -v debug file.mp4 2>&1 | grep seeks 

and

0 seeks 

means "faststart" has been applied.

Sign up to request clarification or add additional context in comments.

4 Comments

For ffprobe command, what specifically are we looking for in the output? How do we know if faststart is enabled or not?
It always finds seeks whether moov data is at beginning or end. What specifically should seeks be? seeks=0 ? seeks=1 ? seeks=2 ? What do these numbers actually mean?
@jsherk "0 seeks" == "faststart", If you have to seek to the end of the file to get the index you have to read the whole file if the stream is not seekable which would be slow compared to reading only the index (<<1% of the data typically)
I got seeks 1 for a video that wouldn't play but seeks 2 for a video that would play (see stackoverflow.com/q/18103103/990642 for background). So instead I used moov atom checking as described here: stackoverflow.com/a/56963953/990642, and the video that didn't play had moov second, and the video that worked had moov first.
8

It shouldn't do any harm to run qt-faststart more than once, it will be a no-op the second time. So the easiest solution is to always run qt-faststart.

For more precise control, I would use the Python translation of qt-faststart: https://github.com/danielgtaylor/qtfaststart

It has functions that examine the atoms in an MP4 file, it shouldn't be too hard to use them to determine whether they need to be reordered.

Comments

0

Here is a small c# helper function.

This is a very basic solution and may not work with all video files but does work for my simple case where videos were encoded with a recent version of ffmpeg.

private bool IsVideoFastStartEnabled(string fullFilePath) { ///////////////////////////////////////////////////////////////////////////////// // Fast start is enabled if "moov" is before "mdat" in first 4096 bytes fo file // https://trac.ffmpeg.org/wiki/HowToCheckIfFaststartIsEnabledForPlayback ///////////////////////////////////////////////////////////////////////////////// byte[] buffer = new byte[4096]; using (FileStream fs = new FileStream(fullFilePath, FileMode.Open, FileAccess.Read)) { fs.Read(buffer, 0, buffer.Length); fs.Close(); } var byteSpan = buffer.AsSpan(); var moovPattern = new byte[] { 0x6d, 0x6f, 0x6f, 0x76, 0x00 }.AsSpan(); var moovIndex = byteSpan.IndexOf(moovPattern); var mdatPattern = new byte[] { 0x6d, 0x64, 0x61, 0x74, 0x00 }.AsSpan(); var mdatIndex = byteSpan.IndexOf(mdatPattern); if (moovIndex > 0 && (mdatIndex == -1 || moovIndex < mdatIndex)) { // Fast start is enabled return true; } return false; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.