public
Last active

MP4 moov header debug

  • Download Gist
NOTES.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Debug notes:
 
# On HEAD ( f821f98126595002c8cb7a5f17521908d746dc8a )
 
wget http://ffmpeg-debug.s3.amazonaws.com/1050-moov-header-size/moov-header-sample.mp4
ffmpeg -i moov-header-sample.mp4 -acodec copy -vcodec copy -y ffmpeg.mp4
MP4Box -inter 500 -out mp4box.mp4 ffmpeg.mp4
 
qt-faststart ffmpeg.mp4 /dev/null | grep 'moov '
# moov 1712220 7809
qt-faststart mp4box.mp4 /dev/null | grep 'moov '
# moov 32 4709
 
boxdumper ffmpeg.mp4 > ffmpeg.box
ruby box-sizes.rb ffmpeg.box > ffmpeg.box-sizes
boxdumper mp4box.mp4 > mp4box.box
ruby box-sizes.rb mp4box.box > mp4box.box-sizes
bisect.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
ffmpeg -i original.mp4 -acodec copy -vcodec copy -t 5 -y foo.mp4
 
Looking for moov < 6000, ordered by commit timestamp
 
1319406693 42d44ec306d0656ace5cea63867f70fa686141cb MOOV:5391 GOOD commit. Took 607 seconds
1321426103 4da45aff28de618c3be566094952bc19da9c9118 MOOV:5391 GOOD commit. Took 622 seconds
1322096901 8e576d58306df95d6373dd0ca2c1f21f1afaeca9 MOOV:5391 GOOD commit. Took 623 seconds
1322489268 ae5873f13bc7d0b4e93193ff7e90c92f52742268 MOOV:5391 GOOD commit. Took 627 seconds
1322498439 2027d073ae0bb938f1756770d4d9e310d165bdd8 MOOV:5391 GOOD commit. Took 628 seconds
1322522429 4dcd1a3145dd93602b86a44ebc07d98ca2a30ab6 MOOV:5391 GOOD commit. Took 624 seconds
1322535802 fc09bf57a60d4c4a6d339b204b3282337067c06d MOOV:6695 BAD commit. Took 625 seconds
1322578296 6ffdc262b0d821e0dda6c83b1593256c06424625 MOOV:6695 BAD commit. Took 628 seconds
1322585425 b0a90c20041b1fc8e5cd2671c6ca59ec4b1a60df MOOV:6967 BAD commit. Took 625 seconds
1322675186 8f025f2f6055cf534d3276b4aef491a912336cd2 MOOV:6691 BAD commit. Took 624 seconds
1322687454 77e0c7584b595edcec7bf393c0e77dbcfe2a8cb4 MOOV:5351 GOOD commit. Took 568 seconds
1322783471 7b0b10ce4186eaa1cd3c0a2bfbb86307d65eecfd MOOV:6691 BAD commit. Took 627 seconds
box-sizes.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
#!/usr/bin/env ruby
#
# Hacky script to get the outline of boxdumper's output
#
 
def parse_line(data)
md = /^( *)/.match(data)
data = data.lstrip
 
node = {}
node[:level] = md[1].size / 2
 
case data
when /([^=]+) = (.+)/
node[:type] = :pair
node[:key] = $1
node[:value] = $2
when /^\[([^\]:]+)(?::([^\]]+))?\]$/
node[:type] = :category
node[:name] = $1
node[:desc] = $2
else
node[:type] = :other
node[:value] = data
end
 
node
end
 
def parse(data)
data.lines.map do |line|
parse_line(line)
end
end
 
if __FILE__ == $0
require 'pp'
data = File.open(ARGV[0] || 'mp4box.box', 'rb').read
lines = parse(data)
 
lines.each do |line|
if line[:type] == :category
$stdout.write (" " * line[:level]) + line[:name]
elsif line[:type] == :pair && line[:key] == "size"
$stdout.puts ' ' + line[:value]
end
end
end
ffmpeg.box-sizes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
ROOT 1720029
ftyp 32
free 8
mdat 1712180
moov 7809
mvhd 108
trak 3487
tkhd 92
edts 36
elst 28
mdia 3351
mdhd 32
hdlr 45
minf 3266
vmhd 20
dinf 36
dref 28
url 12
stbl 3202
stsd 150
avc1 134
avcC 48
stts 24
stss 48
ctts 1448
stsc 40
stsz 748
stco 736
trak 4108
tkhd 92
edts 36
elst 28
mdia 3972
mdhd 32
hdlr 45
minf 3887
smhd 16
dinf 36
dref 28
url 12
stbl 3827
stsd 103
mp4a 87
esds 51
stts 24
stsc 1900
stsz 1056
stco 736
udta 98
meta 90
hdlr 33
ilst 45
┬ętoo 37
data 29
mp4box.box-sizes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
ROOT 1716984
ftyp 32
moov 4709
mvhd 108
trak 2915
tkhd 92
edts 36
elst 28
mdia 2779
mdhd 32
hdlr 45
minf 2694
vmhd 20
dinf 36
dref 28
url 12
stbl 2630
stsd 150
avc1 134
avcC 48
stts 24
ctts 1448
stss 48
stsc 136
stsz 748
stco 68
trak 1580
tkhd 92
edts 36
elst 28
mdia 1444
mdhd 32
hdlr 45
minf 1359
smhd 16
dinf 36
dref 28
url 12
stbl 1299
stsd 91
mp4a 75
esds 39
stts 24
stsc 52
stsz 1056
stco 68
udta 98
meta 90
hdlr 33
ilst 45
┬ętoo 37
data 29
mdat 1712180
free 8
free 55

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.