[FFmpeg-devel] [PATCH 2/2] avformat/mpegtsenc: fix flushing of audio packets
Marton Balint
cus at passwd.hu
Wed Aug 28 00:33:13 EEST 2019
On Tue, 27 Aug 2019, Andreas Håkon wrote:
> 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).
It will require some changes. I will respond in the proper thread.
>
> 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.
I am not sure what you mean when you say PES size interval, but if you are
referring to the size of the PES packet - that is exactly what we had in
the very beginning, and it was not sufficent because for low bitrate
streams when combining small audio packets to a PES packet it took too
long time, and in order to generate a proper TS we have to make sure that
we don't delay the audio packets too much, becuase if we do, then it will
arrive at the destination later then the PCR which makes presentation
impossible.
So that is why timestamp based checks were added, but those checks were
not sufficent.
This is a completely different issue from interleaving. Interleaving is
basically ticket #912.
Regards,
Marton
More information about the ffmpeg-devel
mailing list