I have corrupt mpeg4 files which require frame reshuffling (sample at https://drive.google.com/file/d/1GD7YiVS2z8h0r6UdsPPIXFgnh9RukoeR/view?usp=drive_link )
I had some success using ffmpeg’s shuffleframes filter but it requires video reencoding, and I would like to avoid that.
I analyzed those mpeg4 files and observed they have no CTTS box, so I tried adding one with the required offsets, to no avail: VLC 3.0.20 still plays the frames in the wrong order :-(.
To confirm whether CTTS worked as I thought, I crafted the following test video with 100 numbered frames @2fps using ffmpeg: https://drive.google.com/file/d/1vp3uKZYgoOFqlMk7GLKOC-_vxzJCMwGQ/view?usp=sharing
I analyzed it and can confirm it includes a CTTS box which defines frame offsets(*), and VLC plays it fine. Good.
Now the weird thing is: if I edit that test MPEG-4 and just remove the CTTS box (resulting in the following file: https://drive.google.com/file/d/1JMEcyBoz5r0uVDt08ZOumDVngT1PYWm8/view?usp=sharing ), VLC still plays the video in the right order !
So my question is: how does VLC proceed ? I guess it uses some other (redundant) information ?
And, when both that information and CTTS are present and disagree, which ones takes precedence ?
Or, in short, how can I fix frame order in a consistent way ?
Thanks,
Vincent
(*) start of CTTS decoding from test file:
Entry{count=1, offset=16384}, 2f => frame encoded at pos. 0 => presented at pos. 0+2=2
Entry{count=1, offset=32768}, 4f => frame encoded at pos. 1 => presented at pos. 1+4=5
Entry{count=2, offset=8192}, 1f => frame encoded at pos. 2 => presented at pos. 2+1=3
1f => frame encoded at pos. 3 => presented at pos. 3+1=4
Entry{count=1, offset=40960}, 5f => frame encoded at pos. 4 => presented at pos. 4+5=9
Entry{count=1, offset=16384}, 2f => frame encoded at pos. 5 => presented at pos. 5+2=7
Entry{count=1, offset=0}, 0f => frame encoded at pos. 6 => presented at pos. 6+0=6
Entry{count=1, offset=8192}, 1f => frame encoded at pos. 7 => presented at pos. 7+1=8
Entry{count=1, offset=32768}, 4f => frame encoded at pos. 8 => presented at pos. 8+4=12
Entry{count=2, offset=8192}, 1f => frame encoded at pos. 9 => presented at pos. 9+1=10
1f => frame encoded at pos. 10 => presented at pos. 10+1=11
Entry{count=1, offset=32768}, 4f => frame encoded at pos. 11 => presented at pos. 11+4=15
Entry{count=2, offset=8192}, 1f => frame encoded at pos. 12 => presented at pos. 12+1=13
1f => frame encoded at pos. 13 => presented at pos. 13+1=14
Entry{count=1, offset=32768}, 4f => frame encoded at pos. 14 => presented at pos. 14+4=18
Entry{count=2, offset=8192}, 1f => frame encoded at pos. 15 => presented at pos. 15+1=16
1f => frame encoded at pos. 16 => presented at pos. 16+1=17
Entry{count=1, offset=24576}, 3f => frame encoded at pos. 17 => presented at pos. 17+3=20
Entry{count=1, offset=8192}, 1f => frame encoded at pos. 18 => presented at pos. 18+1=19
vdeconinck is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.