[FFmpeg-devel] [PATCH] libavformat: add multiple PCR streams in MPEGTS muxer [v2]
marksanders at protonmail.com
Tue Nov 20 18:39:56 EET 2018
Regarding Andrey Turkin's comments on my first version of the patch,
here are some comments:
- Multiple streams with PCR marks in the same program are **allowed**.
ISO/IEC 13818-1: "Information technology — Generic coding
of moving pictures and associated audio
Section: Intro.1 Transport Stream, paragraph 2:
"[...] The Transport Stream rate is defined by the values and
locations of Program Clock Reference (PCR) fields, which in general
are separate PCR fields for each program."
Section: Intro. 8.2 Synchronization, paragraph 3:
"A program shall have one and only one PCR time base associated with it."
Conclusion: In the PMT table only one (sub)stream can transport the *master*
PCR clock. However, any other (sub)streams may be allowed to
provide **unused** PCR marks.
Note: This patch doesn't change the output if the new parameters aren't used.
In addition, when enabled, the master (sub)stream receives PCR marks
identical to the previous ones.
- Correction of the PCR repetition rate:
The new version of the patch fixes this problem. Now, each (sub)stream has
its own individual repetition rate.
Thanks Andrey for noticing it!
- User case:
I'm going to do a deeper explanation of how to use this patch.
Imagine generating a program with 1 video stream and 2 audio streams.
When you add "-pcr_all_audio 1", the two audio streams will include PCR marks.
This doesn't change anything and the program can be used as before.
But now you can also generate additional radio services just adding a PMT for
each audio stream (this part isn't the purpose of this patch).
For example, you can do it with an external tool without any remux.
The only requirement is that each radio service points to the correct pid
of the audio stream. Futhermore, you can also separate these new radio
services from the original TS with just a pid filtering, as the PCR marks already
I hope the patch is accepted. I'm using it without problems.
> This looks like a (strange) hack to me.
> First, you cannot just throw some pids out - that will make a non-standard
> compliant stream. PMT will signal missing streams; PCR pid will be missing
> also. So let's assume that your tool can also rewrite PMT.
> Secondly, there is supposed to be one and only one PCR stream per program;
> there is no way to signal multiple PCRs. So let's assume you have some
> out-of-band list of PCRs for this particular case (or maybe you can just
> assume there are PCR marks in each stream so you can configure your remuxer
> Thirdly and most importantly, I might be wrong here but it looks like your
> patch just "spreads" same PCRs which would go into single stream over all
> program's streams, i.e. overall PCR count doesn't change. Which means that
> remuxed stream might have arbitrarily large inter-PCR gaps which is pretty
> bad (assuming you care about PCRs at all, which presumably you do).
> Also - do you really have multiple audio streams in single program, which
> are supposed to be remuxed as separate radio channels? Or same for multiple
> video streams? Is this for ABR purposes? Can you describe your use case in
> some more details?
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Tuesday, 20 de November de 2018 16:57, msanders <marksanders at protonmail.com> wrote:
> This new patch adds three new options to the MPEG-TS muxer.
> You can use them to mark PCRs in additional VIDEO/AUDIO/DATA streams.
> It's useful when you will remux the output with pid filtering tools.
> For example, if you put PCR in all audio streams, then you can filter
> each audio stream to create a radio service.
> PCR marks do not disturb outgoing stream, but it is not recommended
> to do so as a regular rule. Anyway the resulting stream is conformant with specs.
> Supersedes: [FFmpeg-devel] libavformat: add multiple PCR streams in MPEGTS muxer
> M. Sanders.
More information about the ffmpeg-devel