Skip to content

Instantly share code, notes, and snippets.

@Noilednad
Forked from zimbatm/NOTES.txt
Created April 15, 2017 11:24
Show Gist options
  • Save Noilednad/a2a12b3a2968b8a9982b01bae3be574c to your computer and use it in GitHub Desktop.
Save Noilednad/a2a12b3a2968b8a9982b01bae3be574c to your computer and use it in GitHub Desktop.
MP4 moov header debug
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
#!/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
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
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment