Minion
Minion

Reputation: 135

how to play two different songs on different earphones at the same time through Gstreamer?

We have tried playing two songs at the same time using interleave plugin.

> gst-launch
    filesrc location=/home/test.mp3
        ! decodebin ! audioconvert ! "audio/x-raw-int,channels=2"
        ! alsasink 
    filesrc location=/home/song.mp3
        ! decodebin ! audioconvert ! audio/x-raw-int,channels=2
        ! deinterleave name=d
    interleave name=i ! audioconvert  ! alsasink
    d.src0 ! queue ! audioconvert ! i.sink1
    d.src1 ! queue ! audioconvert ! i.sink0

i can hear two song together on both left and right earplugs.but i want test.mp3 to be played in right channel and song.mp3 to be played in left channel. If in above pipeline I change channels=1 instead of 2 it says

Setting pipeline to PAUSED ... Pipeline is PREROLLING ... And i can hear nothing.

can anyone suggest me the correct pipeline structure for this?

Upvotes: 2

Views: 2798

Answers (1)

max taldykin
max taldykin

Reputation: 12898

Before interleaving two songs you need to convert them to mono. It's possible to do this with audioconvert. Just set channels to 1.

audioconvert ! "audio/x-raw-int,channels=1"

Then just interleave them into one stream:

$ gst-launch                                                      \
    interleave name=i ! alsasink                                  \
    filesrc location=07.\ No\ Woman\,\ No\ Cry.mp3                \
        ! decodebin ! audioconvert ! "audio/x-raw-int,channels=1" \
        ! i.sink1                                                 \
    filesrc location=11.\ Sun\ Is\ Shining.mp3                    \
        ! decodebin ! audioconvert ! "audio/x-raw-int,channels=1" \
        ! i.sink0

Upd: Oh, my! It's almost the same pipeline on the interleave page here. Try to read some docs before asking next time. It's not that hard.

Upvotes: 2

Related Questions