Hm. After fixing the obvious problems with matching moofs with tfra entries I noticed that the timestamps aren't right even after that.
AFAICT, ffmpeg's fragmentation code puts dts in the tfra time. In movenc.c: mov->tracks[i].frag_start += mov->tracks[i].start_dts + mov->tracks[i].track_duration - mov->tracks[i].cluster[0].dts; Whereas l-smash's code definitely tries to put a presentation timestamp there. I wonder if we should add some flags after all - I don't think it'll be easy to automatically detect what the creating program has been doing. I'll submit the version with fixed matching shortly. Mika On 11 October 2014 15:27, Mika Raento <mi...@iki.fi> wrote: > Interesting. The input.mov created with ./ffmpeg -i > matrixbench_mpeg2.mpg -t 1 -frag_duration 200k input.mov does not > have tfra entries for all the moofs for the audio track. The single > tfra it has is not for the first moof, but the last one. > > I'll improve the matching of the moofs and tfra entries. > > Thanks again for your help. > > Mika > > On 11 October 2014 14:21, Michael Niedermayer <michae...@gmx.at> wrote: >> On Sat, Oct 11, 2014 at 07:25:52AM +0300, Mika Raento wrote: >>> If present, an MFRA box and its TFRAs are read for fragment start times. >>> >>> Without this change, timestamps for discontinuous fragmented mp4 are >>> wrong, and cause audio/video desync and are not usable for generating >>> HLS. >>> --- >>> libavformat/isom.h | 15 ++++++ >>> libavformat/mov.c | 146 >>> +++++++++++++++++++++++++++++++++++++++++++++++++++++ >>> 2 files changed, 161 insertions(+) >> >> this appears to breaks timestamps for some files, i didnt investigate >> why >> >> ./ffmpeg -i matrixbench_mpeg2.mpg -t 1 -frag_duration 200k input.mov >> ./ffprobe input.mov -show_packets -print_format compact | grep audio >> >> >> packet|codec_type=audio|stream_index=1|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=N/A|duration_time=N/A|convergence_duration=N/A|convergence_duration_time=N/A|size=172|pos=17590|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=3840|pts_time=0.080000|dts=3840|dts_time=0.080000|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=315|pos=19048|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=4864|pts_time=0.101333|dts=4864|dts_time=0.101333|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=297|pos=19363|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=5888|pts_time=0.122667|dts=5888|dts_time=0.122667|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=9|pos=22964|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=6912|pts_time=0.144000|dts=6912|dts_time=0.144000|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=216|pos=22973|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=7936|pts_time=0.165333|dts=7936|dts_time=0.165333|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=327|pos=23521|flags=K >> >> packet|codec_type=audio|stream_index=1|pts=8960|pts_time=0.186667|dts=8960|dts_time=0.186667|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=327|pos=23848|flags=K >> -packet|codec_type=audio|stream_index=1|pts=9984|pts_time=0.208000|dts=9984|dts_time=0.208000|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=330|pos=35835|flags=K >> -packet|codec_type=audio|stream_index=1|pts=11008|pts_time=0.229333|dts=11008|dts_time=0.229333|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=317|pos=36165|flags=K >> -packet|codec_type=audio|stream_index=1|pts=12032|pts_time=0.250667|dts=12032|dts_time=0.250667|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=326|pos=36482|flags=K >> +packet|codec_type=audio|stream_index=1|pts=48896|pts_time=1.018667|dts=48896|dts_time=1.018667|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=330|pos=35835|flags=K >> +packet|codec_type=audio|stream_index=1|pts=49920|pts_time=1.040000|dts=49920|dts_time=1.040000|duration=1024|duration_time=0.021333|convergence_duration=N/A|convergence_duration_time=N/A|size=317|pos=36165|flags=K >> ... >> >> [...] >> -- >> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB >> >> During times of universal deceit, telling the truth becomes a >> revolutionary act. -- George Orwell >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel