[FFmpeg-devel] [PATCH] libavformat: fix copyts and muxrate in mpegts muxer
Andreas Håkon
andreas.hakon at protonmail.com
Mon Apr 22 15:01:40 EEST 2019
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, 19 de April de 2019 10:47, Andreas Håkon via ffmpeg-devel <ffmpeg-devel at ffmpeg.org> wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, 18 de April de 2019 11:01, Andreas Håkon via ffmpeg-devel ffmpeg-devel at ffmpeg.org wrote:
>
> > Hi,
> > This patch resolves one very specific use case:
> >
> > - When you use the mpegts muxer;
> >
> > - And use the global parameter “-copyts”;
> >
> > - And use the parameter “-muxrate” for the mpegts muxer;
> >
> > - And use too the parameter “-mpegts_copyts”.
> > The problem is created because the member “first_pcr” of the MpegTSWrite struct isn’t initialized with a correct timestamp (so when copying the timestamps the initial value is 0). And in this case an infinite loop is created because the code never writes PES packets when the “mux_rate” isn’t VBR (equals to 1). See the block that creates the loop here (note the "continue" command at end):
> > https://github.com/FFmpeg/FFmpeg/blob/a0559fcd81f42f446c93357a943699f9d44eeb79/libavformat/mpegtsenc.c#L1211
> > So, this patch fixes the problem initializing the “first_pcr” with the first DTS value that comes when using the incoming timestamps.
> > Regards.
> > A.H.
> >
>
> Hi,
>
> Here a new version of the patch.
>
> The "fist_pcr" value is now derived from DTS in a more consistent way.
>
> Regards,
> A.H.
>
Hi Michael Niedermayer,
Please review this patch. It resolves a **serious** bug when using
"copyts" and "muxrate" with the mpegts muxer.
Testcase:
$ ffmpeg -loglevel debug \
-copyts -f mpegts -i 01c56b0dc1.ts \
-filter_complex "[i:0xfb]fps=fps=25[out]" \
-map "[out]" -c:v libx264 \
-f mpegts -muxrate 10M -mpegts_copyts 1 out.ts
File "01c56b0dc1.ts" is "http://samples.ffmpeg.org/ts/01c56b0dc1.ts".
Without this patch the ffmpeg enters in a INFINITE LOOP !!!
With the patch all is processed as excepted.
Please, apply it.
Regards.
A.H.
---
More information about the ffmpeg-devel
mailing list