Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to tell if faststart for video is set using ffmpeg or ffprobe

Tags:

ffmpeg

ffprobe

I am having trouble figuring out how to determine if faststart is set on an MP4 video.

I understand that "moov atom" is the data that needs to be located at the beginning of the file for faststart to be enabled, instead of at the end of the file.

I specifically want to use ffmpeg or ffprobe to determine if it has been moved to the beginning or not already.

On a side note, I understand I can run the following command to move it from the end to the beginning (but I want to find out if it is already there):

ffmpeg -i infile.mp4 -map 0 -c:v copy -c:a copy -c:s copy -c:d copy -c:t copy -movflags +faststart outfile.mp4
like image 740
jsherk Avatar asked Jul 10 '19 05:07

jsherk


People also ask

What does Movflags Faststart do?

If the file is created by adding the -movflags faststart option to the ffmpeg command line, the "moov" atom is moved at the beginning of the MP4 file during the ffmpeg second pass. By using this option, the "moov" atom is located before the "mdat" atom.

How do I fix MOOV atom not found?

Method 1: Download the video again from the source If possible, download the video file again from the source, be it from the Internet, CD/DVD, Android, or other devices. Get your video again, and this time, ensure the file is wholly and appropriately downloaded or transferred without interruption.

What is MOOV atom?

The moov atom, aka movie atom, defines the timescale, duration, and display characteristics of the movie, as well as sub-atoms containing information for each track in the movie. The optimal location of the moov atom depends on the selected delivery method.


1 Answers

Run

ffmpeg -v trace -i file.mp4 2>&1 | grep -e type:'mdat' -e type:'moov'

This will produce an output like,

[mov,mp4,m4a,3gp,3g2,mj2 @ 000000000036ca40] type:'mdat' parent:'root' sz: 62740 48 65044 [mov,mp4,m4a,3gp,3g2,mj2 @ 000000000036ca40] type:'moov' parent:'root' sz: 2264 62788 65044

Since moov appears second, it is at the end in this example.

On bash-like shells, escape the single quotes:

ffmpeg -v trace -i file.mp4 2>&1 | grep -e type:\'mdat\' -e type:\'moov\'


For Windows, findstr can be used,

ffmpeg -v trace -i file.mp4 2>&1 | findstr /l "type:'moov' type:'mdat'"

like image 142
Gyan Avatar answered Sep 21 '22 13:09

Gyan