[FFmpeg-devel] libavformat/mpegtsenc: fix incorrect PCR with multiple programs [v2]

Michael Niedermayer michael at niedermayer.cc
Sun Jul 28 17:39:21 EEST 2019


On Sat, Jul 27, 2019 at 08:41:02PM +0000, Andreas HÃ¥kon wrote:
> Hi,
> 
> This newversion fixes all the problems commented in
> https://patchwork.ffmpeg.org/patch/14036/
> 
> Now, it works with/without video streams.
> 
> Regards.
> A.H.
> 
> ---

> From c9b295c49828f31bba3879de887c7b2ed0e2641c Mon Sep 17 00:00:00 2001
> From: Andreas Hakon <andreas.hakon at protonmail.com>
> Date: Sat, 27 Jul 2019 21:28:32 +0100
> Subject: [PATCH] libavformat/mpegtsenc: fix incorrect PCR with multiple
>  programs [v2]
> 
> The MPEG-TS muxer has a serious bug related to the PCR pid selection.
> This bug appears when more than one program is used. The root cause is because
> the current code targets only one program when selecting the stream for the PCR.
> 
> This patch solves this problem and select correct streams for each program.
> 
> You can check it with this command:
> 
> $ ./ffmpeg -loglevel verbose -y -f data -i /dev/zero \
>  -filter_complex "nullsrc=s=60x60,split=2[v0][v1],anullsrc[a]" \
>  -map [v0] -c:v:0 rawvideo \
>  -map [v1] -c:v:1 rawvideo \
>  -map [a]  -c:a:0 pcm_s8 \
>  -program st=0 -program st=1 -program st=2 -f mpegts out.ts
> 
> And you will see something like:
> 
> [mpegts @ 0x562f388cd800] service 1 using PCR in pid=256
> [mpegts @ 0x562f388cd800] service 2 using PCR in pid=257
> [mpegts @ 0x562f388cd800] service 3 using PCR in pid=258
> 
> 
> Signed-off-by: Andreas Hakon <andreas.hakon at protonmail.com>
> ---
>  libavformat/mpegtsenc.c |  111 ++++++++++++++++++++++++++---------------------
>  1 file changed, 61 insertions(+), 50 deletions(-)

This causes the stream from ticket/3714 to become noticably bigger

./ffmpeg -i 3714/FFmpeg\ Sample_cut.ts -vcodec copy -acodec copy -pat_period 1 -sdt_period 1 this_was_less_than_2560000.ts

-rw-r----- 1 michael michael 2700056 Jul 28 16:12 this_was_less_than_2560000.ts

before:
-rw-r----- 1 michael michael 2559808 Jul 28 16:13 this_was_less_than_2560000.ts

-rw-r----- 1 michael michael 2560000 Jun 11  2014 3714/FFmpeg Sample_cut.ts

sample should be here: https://trac.ffmpeg.org/raw-attachment/ticket/3714/FFmpeg%20Sample_cut.ts

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20190728/0e43b24d/attachment.sig>


More information about the ffmpeg-devel mailing list