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

Michael Niedermayer michaelni
Sun Feb 19 23:37:19 CET 2006


Hi

On Sun, Feb 19, 2006 at 10:02:40PM +0100, Baptiste COUDURIER wrote:
> 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.

just add it for mpeg4 and h264


[...]
> > [...]
> >> +        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.

no this is wrong pts-dts does not need to be a multiple of pkt->duration

the correct code IMHO is trk->cluster[cl][id].cts= (pkt->pts - pkt->dts) * enc->time_base.num;
though i didnt check the spec ...

also note that mov_write_stts_tag() is totally wrong, it must store the dts
not blindly assume they are all equally spaced

[...]
-- 
Michael





More information about the ffmpeg-devel mailing list