Changes between Version 3 and Version 4 of HowToCheckIfFaststartIsEnabledForPlayback
- Timestamp:
- Nov 6, 2021, 3:03:47 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HowToCheckIfFaststartIsEnabledForPlayback
v3 v4 7 7 This '''How to''' applies to '''H.264/MP4''' files only but will probably work with '''H.264/MOV''' files too. 8 8 9 Streaming web sites recommend to upload videos with Fast Start enabled. Itallows video playback to begin before the file has been completely downloaded.9 Streaming web sites recommend to upload videos with Fast Start enabled. This allows video playback to begin before the file has been completely downloaded. 10 10 11 11 Why ? 12 12 13 Normally, a MP4 file has all the metadata about all packets stored at the end of the file, unless it has been created by adding the '''-movflags faststart''' option to the ffmpeg command line. In this latter case, an atom named "moov" is moved at the beginning of the MP4 file during the ffmpeg second pass.13 Normally, a MP4 file has all the metadata about all packets stored at the end of the file, in data units named atoms. The "mdat" atom is located before the "moov" atom. 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. 14 14 15 Therefore, the location of the "moov" atom in an existing MP4 file (begining or end) helps to check if Fast Start is enabled or not for this file. 16 17 Another atom named "mdat" may also help. If the "moov" atom is located before the "mdat" atom then the file is enabled for Fast Start playback. 15 In other words, the file is enabled for Fast Start playback only when the "moov" atom is located before the "mdat" atom. 18 16 19 17 == Prerequisites == … … 34 32 pause 35 33 }}} 36 This batch file searches only the first occurence of either "mdat" atom or "moov" atom (i.e. grep -m 1)within each MP4 file in the current directory. The output listing contains two lines for each file :34 This batch file searches the first occurence of either "mdat" atom or "moov" atom within each MP4 file in the current directory. The output listing contains two lines for each file : 37 35 * the MP4 file name 38 * the first atom found (either "moov" or "mdat") 39 40 When a MP4 file is enabled for Fast Start playback, the "moov" atom is printed within the second line. If not, it is the "mdat" atom. 36 * the name of the first atom found (either "moov" or "mdat") 41 37 42 38 The drawback of this batch file is that it can take a while to run when scanning hundreds of MP4 files. … … 44 40 == Alternate method == 45 41 46 An alternate method is to truncate the MP4 files before scanning. If the moov atom is not in the 47 first 4K bytes, the file is not fast start ready. 42 An alternate method is to truncate the MP4 files before scanning. If the "moov" atom is not located in the first 4K bytes, then Fast Start is not enabled. 48 43 {{{ 49 44 @echo off … … 51 46 for /F "delims=µ" %%i in ('dir /b /on *.mp4') do ( 52 47 echo %%i 53 head -c 4096 "%%i" > temp.mp454 ffmpeg -v trace -i temp.mp4 NUL 2>"%%i.txt"48 head -c 4096 "%%i" >TEMP.mp4 49 ffmpeg -v trace -i TEMP.mp4 NUL 2>"%%i.txt" 55 50 grep -L -m 1 -e "type:'moov'" "%%i.txt" >>OUTPUT.txt 56 51 del "%%i.txt" 57 52 ) 58 del temp.mp453 del TEMP.mp4 59 54 pause 60 exit61 55 }}} 62 The OUTPUT.txt file contains the list of MP4 files that are NOT fast start ready.56 The OUTPUT.txt file contains the list of MP4 files that are not enabled for Fast Start playback.
