[FFmpeg-devel] [PATCH] Fix first_pcr initial update

lance.lmwang at gmail.com lance.lmwang at gmail.com
Wed Nov 3 11:19:45 EET 2021


On Tue, Nov 02, 2021 at 05:36:37PM +0200, Maksym Veremeyenko wrote:
> On 02.11.2021 16:59, lance.lmwang at gmail.com wrote:
> [...]
> > > +    if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) {
> > > +        ts->first_pcr += dts * 300;
> > > +        ts->first_dts_checked = 1;
> > > +    }
> > > +
> > 
> > I think it's not same as the old code, the first_pcr will add extra delay if copyts is
> > 0.
> > 
> 
> proposed patch extend updating ts->first_pcr not only when copyts is 0 but
> when copyts is 1 (*-mpegts_copyts 1* specified)
> 
> very similar issue i found at
> http://ffmpeg.org/pipermail/ffmpeg-devel/2019-April/242766.html
> 
I mean you need move the code before if (ts->copyts < 1) { instead of after.

try with below command:
 ./ffmpeg -y -copyts -i http://samples.ffmpeg.org/MPEG2/foxksaz.ts -c:v libx264 -x264opts nal-hrd=cbr:force-cfr=1 \
-b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 1000k  -c:a mp2 -f mpegts \
-mpegts_copyts 0 -muxrate 4500k -vframes 1000 test.ts

You'll get some "dts < pcr, TS is invalid" message.


> -- 
> Maksym Veremeyenko
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".

-- 
Thanks,
Limin Wang


More information about the ffmpeg-devel mailing list