[FFmpeg-devel] [PATCH 2/2] avformat/mpegtsenc: fix flushing of audio packets

Andreas Håkon andreas.hakon at protonmail.com
Tue Aug 27 11:57:54 EEST 2019


Hi Marton,


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, 27 de August de 2019 9:34, Marton Balint <cus at passwd.hu> wrote:

> Fixes DTS < PCR errors with this command line:
>
> ./ffmpeg -loglevel verbose -y -f lavfi -i \
> "testsrc=s=64x64:d=20,split=2[out0][tmp1];[tmp1]vflip[out1];sine=d=20,asetnsamples=1000[out2]" \
> -flags +bitexact -fflags +bitexact -sws_flags +accurate_rnd+bitexact \
> -codec:v libx264 -codec:a mp2 -b:a 32k -pix_fmt yuv420p \
> -map '0:v:0' \
> -map '0:v:1' \
> -map '0:a:0' \
> -muxrate 800000 \
> -program st=0:st=2 -program st=1:st=2 -program st=2 -program st=0 -f mpegts out1.ts

> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index 047961cdea..0678657d09 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> [...]

This change breaks my interleaved patch (waiting for your review).

Please, note that the main problem at time with the mpegts muxer is that all PES packets are
written sequentially. And this generates a lot of problems when the video PES packets are large,
or when the audio packets aren't flushed at regular intervals. If you prefer to improve the
current sequential mode before you do anything with the interleaved mode, then I give this
suggestion: Use a PES SIZE INTERVAL for audio packets instead of calculating a TIME DELAY. With
CBR audio steams, every audio PES packet has the same payload size.

Regards.
A.H.

---



More information about the ffmpeg-devel mailing list