Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 the PID's always stay the same, 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
    
I'm a bit confused by this question. The title and first paragraph strongly emphasize that the data is streamed to ffmpeg, but for the rest of the question it isn't clear why this is relevant. – nobar Mar 28 '15 at 1:12
up vote 4 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
    
If a TS contain multiple programs (TV programs that captured by DVB-T), how can split it? For example I have a TS file that contain football + cooking + cartoon .How can i split this TS file to 3 mpg files? – Mr.Hyde Jul 21 '15 at 3:58
1  
@Mr.Hyde I've added an example of that here: trac.ffmpeg.org/wiki/Map – rogerdpack Dec 30 '15 at 19:24
    
@rogerdpack No no, I means All TV shows are in one TS. I think the only way to split them from each other is using EPG. – Mr.Hyde Dec 31 '15 at 11:22
    
@Mr.Hyde Are they in separate programs/program id's? Even if they're not, they probably have different pids (the "0x406" from that example 8) so you could map them in that way. – rogerdpack Dec 31 '15 at 22:04
2  
@Mr.Hyde Specifically the comment section on every ffmpeg question should not be considered your own personal support group. Comments are intended to clarify the answer itself or clear up a point from the question, you should not be asking new questions in comments on old answers. You should instead be using the Ask Question button. – Mokubai Jan 4 at 20:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .