[FFmpeg-devel] [PATCH 3/3] movenc: simplify the 'tfxd' fragment start timestamps

Jan Ekstrom jeebjp at gmail.com
Sun Mar 20 18:11:43 CET 2016


On Sun, Mar 20, 2016 at 3:28 PM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> On Sat, Mar 19, 2016 at 07:39:07PM +0200, Jan Ekström wrote:
>> As far as can be seen, this value is supposed to be the DTS of a
>> fragment in smooth streaming. Thus, don't take b-picture delay and
>> such into mention when calculating the start timestamp. The duration
>> calculation requires PTS values, so it is not touched.
>> ---
>>  libavformat/movenc.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index 11c8275..77f28b0 100644
>> --- a/libavformat/movenc.c
>> +++ b/libavformat/movenc.c
>> @@ -3565,8 +3565,7 @@ static int mov_write_tfxd_tag(AVIOContext *pb, MOVTrack *track)
>>      avio_write(pb, uuid, sizeof(uuid));
>>      avio_w8(pb, 1);
>>      avio_wb24(pb, 0);
>> -    avio_wb64(pb, track->start_dts + track->frag_start +
>> -                  track->cluster[0].cts);
>> +    avio_wb64(pb, track->start_dts + track->frag_start);
>>      avio_wb64(pb, track->end_pts -
>>                    (track->cluster[0].dts + track->cluster[0].cts));
>
> breaks fate / needs an update for the checksums if the changes match
> what is intended
>

As far as I can tell this vendor-specific UUID box is a variant of the
"fragment DTS" box specified in ISOBMFF.

Streaming servers I've dealt with seem to parse the initial
timestamp of a fragment as follows:
[timestamp in tfxd] + [CTS offset of the initial sample of the fragment]
Now, if you keep this part of it as-is, you will have the
tfxd timestamp be larger by the CTS offset *and* you will
have a CTS offset in the initial fragment, effectively
doubling the delay.

This fixes one part of the delay, the second part would be
to add support for negative CTS offsets in the "trun"
boxes, which would enable the DTS and CTS be the same for
the initial sample of a fragment (CTS offset of zero). I have a
POC of this lying on my repository, but last I tried it didn't
exactly work perfectly, so I will have to look into that some more.

Jan


More information about the ffmpeg-devel mailing list