[FFmpeg-user] Using FFMPEG to Record a MPTS

Marton Balint cus at passwd.hu
Fri Mar 2 21:30:06 EET 2018

On Fri, 2 Mar 2018, David Stephens wrote:

> Greetings!
> I am attempting to use FFMPEG to record a multi-program transport stream
> (MPTS) which arrives as UDP. There are four Programs in the MPTS. Each
> program consists of a video (h264) and seven or eight audios (mp2). And
> each Program has a defined set of PIDs assigned to that Program. So, for
> example, Program 1 has PID 100 (0x64) for video and PIDs 101-107
> (0x65-0x6B) for audio. Among the four Programs there are 34 streams (0-33).
> I need to record this MPTS as a .TS file while maintaining the original PID
> numbers. I am attempting to force the PID numbering using 34 "-streamid"
> parameters. For example:
> -streamid 0:0x64 -streamid 1:0x65 -streamid 2:0x66
> The command line runs but the resulting file renumbers the PIDs
> incorrectly. And this renumbering is different for each run. It is
> different each time, it appears, because FFMPEG associates the stream
> numbers and PID numbers differently for each run. The input UDP stream ran
> continuously during these two tests; it was not stopped or paused.
> I have attached a text file showing the command line and the console output
> for two runs. Notice in the first attempt that Program 1 is associated with
> streams 18-19-23-24-21-20-25-22. And in the second try Program 1 is
> associated with streams 33-19-29-30-27-26-31-28.
> This variability would seem to make consistent PID numbering impossible
> using "streamid".
> Is there another way?

You can always map explicitly every input stream (e.g. -map 0:i:101, 
etc.), this way the order of the output streams should be the same.


More information about the ffmpeg-user mailing list