[FFmpeg-devel] [PATCH] Fix first_pcr initial update
Marton Balint
cus at passwd.hu
Sat Nov 6 21:26:07 EET 2021
On Wed, 3 Nov 2021, lance.lmwang at gmail.com wrote:
> On Wed, Nov 03, 2021 at 01:01:29PM +0200, Maksym Veremeyenko wrote:
>> On 02.11.2021 12:47, Maksym Veremeyenko wrote:
>> > One of latest commit https://source.ffmpeg.org/?p=ffmpeg.git;a=commitdiff;h=6f36eb0da71d22aadf8f056f0966bd86656ea57e
>> > claim it fixes endless loop on package generation if muxrate specified
>> > and copyts used. But actually it does not work properly if
>> > *-mpegts_copyts 1* specified:
>> >
>> > ffmpeg -y -copyts -i loewe.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 1 -muxrate 4500k
>> > -vframes 1000 test.ts
>> >
>> > ffmpeg generate huge file until it reach zero-based pcr value equal to
>> > first dts.
>> >
>>
>> updated patch attached
>>
>> --
>> Maksym Veremeyenko
>
>> From 5d6265e84417d7169d9c225be7305c116c33042f Mon Sep 17 00:00:00 2001
>> From: Maksym Veremeyenko <verem at m1.tv>
>> Date: Wed, 3 Nov 2021 12:57:45 +0200
>> Subject: [PATCH] Fix first_pcr initial update
>>
>> ---
>> libavformat/mpegtsenc.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
>> index 35c835c..dd01628 100644
>> --- a/libavformat/mpegtsenc.c
>> +++ b/libavformat/mpegtsenc.c
>> @@ -1692,12 +1692,12 @@ static int mpegts_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
>> if (side_data)
>> stream_id = side_data[0];
>>
>> - if (ts->copyts < 1) {
>> - if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) {
>> - ts->first_pcr += dts * 300;
>> - ts->first_dts_checked = 1;
>> - }
>> + if (!ts->first_dts_checked && dts != AV_NOPTS_VALUE) {
>> + ts->first_pcr += dts * 300;
>> + ts->first_dts_checked = 1;
>> + }
>>
>> + if (ts->copyts < 1) {
>> if (pts != AV_NOPTS_VALUE)
>> pts += delay;
>> if (dts != AV_NOPTS_VALUE)
>> --
>> 1.8.3.1
>>
>
> LGTM
Thanks, will apply.
Regards,
Marton
More information about the ffmpeg-devel
mailing list