MKV \ channel two tracks (English & French) simultaneously to different outputs : EN > speakers, FR > headphones

Tim-Philipp Müller t.i.m at zen.co.uk
Fri Sep 7 02:36:16 PDT 2012


On Mon, 2012-08-27 at 14:37 +0300, Alex Alab Artemiev wrote:

Hi Alex,

> My  name  is Alex, I'm an extensive mkv files user, but it's the first
> time ever I'm asking an mkv related question.
> I've got many bilingual movies (Eng+French) and I wish I could watch
> them in French while everybody else I'm watching them with is
> listening to the English track.
> For instance, so that I could have my French track channeled to my
> headphones and the English one channeled to the speakers for my
> friends.
> Searching for a solution, I
> addressed matroska-users at lists.matroska.org
> They recommended me to try GStreamer. That's why I'm asking this
> question here.
> Can GStreamer do this kind of channeling? Is it practicable?
> I'm using an E-MU sound card with multiple outputs.
> Looking forward to reading back from you.

Sure, that should be doable, e.g. with something like:

  gst-launch-0.10 uridecodebin uri=file:///path/to/foo.mkv name=d \
      d.video_00 ! queue ! autovideosink \
      d.audio_00 ! queue ! pulsesink \
      d.audio_01 ! queue ! pulsesink

Now, that would output both audio tracks simultaneously, which isn't
what you want of course, and the names (numbers) of the audio pads might
also differ in your case, but that's not a problem if you write some
code.

How to hook up the two audio tracks depends a bit on the details of your
sound card and sound setup, and what you are using for output
(pulseaaudio? alsa?)

In the easiest case you just have, say, different alsa devices for the
speakers and the headphones (I don't know if this is something that can
be achieved with .asoundrc fiddling or not), then you can just use
alsasink device=foo . It might also be possible to do something clever
with pulseaudio/pulsesink here to force routing one way or another.

If it's the same device, then you would probably have to interleave the
two stereo streams into a single four-channel stream or so? This can be
done with two deinterleave elements and an interleave element, something
like this (completely untested): 

  gst-launch-0.10 uridecodebin uri=file:///path/to/foo.mkv name=d \
      d.video_00 ! queue ! autovideosink \
      d.audio_00 ! deinterleave name=split_00 \
      d.audio_01 ! deinterleave name=split_01 \
      interleave name=combine ! alsasink \
      split_00.src0 ! queue ! combine.sink0 \
      split_00.src1 ! queue ! combine.sink1 \
      split_01.src0 ! queue ! combine.sink2 \
      split_01.src1 ! queue ! combine.sink3

You can replace alsasink with fakesink to see if it works in principle.

Good luck, let us know how it goes.

 Cheers
  -Tim





More information about the gstreamer-devel mailing list