Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Assume that I have a fifo of bytes that is essentially coming from a capture card. Basically, this is NOT A FILE ON DISK.

The data in this fifo is a multi-program MPEG-TS. There are three programs, each containing a video stream and one or more audio streams.

When I run FFmpeg by piping in the fifo, it displays the programs and the streams inside of it. However, sometimes Program 1 contains streams 0.1 and 0.3 and other times it may contain 0.4 and 0.2. Even though these are the same PIDs from the MPEG-TS, FFmpeg tends to give them a random numbering.

My question: Is there a way to select the appropriate streams - I'm fine with selecting by PID - using FFmpeg? (I'm using CLI, btw)

Keep in mind that the map option in FFmpeg will not work because the stream numbers are "randomized" each time I run the ffmpeg command.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Say you are capturing using v4l2 from /dev/video0, then you can map using the program id like this:

ffmpeg -i /dev/video0 -acodec copy -vcodec copy -map 0:p:keep_pid -map -0:p:first_remove_pid -map -0:p:second_remove_pid output.m2ts

Checkout: http://ffmpeg.org/ffmpeg.html#Stream-specifiers-1 and http://ffmpeg.org/ffmpeg.html#Advanced-options

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.