[Ffmpeg-devel] Re: [PATCH] x264 avc encoding, movenc avcC, ctts

Baptiste COUDURIER baptiste.coudurier
Sun Feb 19 22:02:40 CET 2006


Michael Niedermayer wrote:
> Hi
> 
> On Sun, Feb 19, 2006 at 06:23:55PM +0100, Baptiste COUDURIER wrote:
> [...]
>> @@ -580,6 +633,9 @@ static int mov_write_stbl_tag(ByteIOCont
>>      if (track->enc->codec_type == CODEC_TYPE_VIDEO &&
>>          track->hasKeyframes)
>>          mov_write_stss_tag(pb, track);
>> +    if (track->enc->codec_type == CODEC_TYPE_VIDEO &&
>> +        track->enc->codec_id == CODEC_ID_H264) /* MPEG4 too ? */
>> +        mov_write_ctts_tag(pb, track);
> 
> yes, every codec which supports b frames needs CTTS
> also the CODEC_TYPE_VIDEO check is redundant CODEC_ID_H264 is always video

All right, then I will check for B frames instead.

> 
> [...]
>> +    entries_pos = url_ftell(pb);
>> +    put_be32(pb, 0); /* entry count */
> 
> i would prefer if this is written without seeking around, (non seekable stuff
> like streams ...)
> 
> 
>> +    last_cts = track->cluster[0][0].cts;
>> +    for (i=0; i<track->entry; i++) {
>> +        int cl = i / MOV_INDEX_CLUSTER_SIZE;
>> +        int id = i % MOV_INDEX_CLUSTER_SIZE;
>> +        if (track->cluster[cl][id].cts == last_cts)
>> +            current_count++; /* compress */
>> +        else {
>> +            put_be32(pb, current_count);
>> +            put_be32(pb, last_cts);
>> +            current_count = 1;
>> +            last_cts = track->cluster[cl][id].cts;
>> +            entries++;
>> +        }
>> +    }
> 
> isnt this missing the last entry?

Probably right.

> [...]
>> +        if (pkt->dts > pkt->pts) { /* first packet has weird dts */
>> +            av_log(s, AV_LOG_ERROR, "weird, dts %lld, pts %lld\n", pkt->dts, pkt->pts);
>> +            pkt->dts = pkt->pts - pkt->duration; /* first cts to 1 */
>> +        }
> 
> this looks like a bug somewhere else ...
> 
> 
>> +        trk->cluster[cl][id].cts = av_rescale(pkt->pts - pkt->dts, enc->time_base.num, pkt->duration); /* enc->time_base.num will be trk->sampleDuration */
> 
> this looks wrong, what does the pkt->duration do in there?
> 
> [...]
> 

Difference between pts and dts is pkt->duration scaled, I admit that I
don't know that much pts/dts system in ffmpeg.

For example I get 3600, 7200, 10800, differences, but duration in ctts
value should be accorded to sampleDuration. If 10800 is the difference
and and pkt->duration is 3600 then 3 is the real difference, scaled to
sampleDuration does the right duration value.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
SMARTJOG S.A.                                    http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312





More information about the ffmpeg-devel mailing list