[Libav-user] Fwd: help filtering an audio stream from mpegts

Brian Fallik bfallik at bamboom.com
Fri Aug 12 18:41:00 CEST 2011


Apologies for the cross-post but I think (?) that this is the more
appropriate list for my email question, which may explain the lack of
any responses.

Thanks,
brain

---------- Forwarded message ----------
From: Brian Fallik <bfallik at bamboom.com>
Date: Thu, Aug 11, 2011 at 3:45 PM
Subject: help filtering an audio stream from mpegts
To: ffmpeg-user at ffmpeg.org


Hi,

I'm trying to use lib(avcodec|format) to discard one audio stream
(PID) from an input mpegts file.  Using ffmpeg, the command line:
 $ ffmpeg -y -i infile.ts -vcodec copy -acodec copy outfile.ts -map
0.0 -map 0.2
does exactly what I want, but I want to avoid the fork&exec of ffmpeg
and use the library interface directly.

I can't figure out how to setup the input and output contexts.  If I
don't add the filtered stream to the output context,
av_interleaved_write_frame() will segfault since it accesses stream[n]
with n == 2, but the output context only contains a list of streams
for ids 0 and 1.  If I add the input stream to the output context, the
PMT contains both audio PIDs, which isn't right.

Does the 'discard' attribute of AVStream help?  I tried setting it to
AVDISCARD_ALL for the stream I want to remove but it doesn't seem to
do much of anything.

Can anyone shed some light on this?  The ffmpeg binary does the right
thing so I know it's possible.

Thanks,
brian


More information about the Libav-user mailing list