问题
I would like to generate 2 audio tones using audiotestsrc but then duplicate those two channels across 16 channels (i.e 8channels of the one tone and 8channels of the other).
I have a command that generates 2 tones for 2 channels:
gst-launch-1.0 interleave name=i ! audioconvert ! wavenc ! filesink location=file.wav audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert ! "audio/x-raw,channels=1,channel-mask=(bitmask)0x1" ! queue ! i.sink_0 audiotestsrc wave=1 freq=150 volume=0.4 ! decodebin ! audioconvert ! "audio/x-raw,channels=1,channel-mask=(bitmask)0x2" ! queue ! i.sink_1
I also have a command that generates 1 tone across 16 channels:
gst-launch-1.0 audiotestsrc wave=0 freq=100 volume=0.4 ! audio/x-raw,rate=48000,format=S16BE ! queue ! capssetter caps="audio/x-raw,channels=16,rate=48000,channel-mask=(bitmask)0xffff" ! audioconvert ! audioresample ! wavenc ! filesink location=test.wav
So my question:
Is there a way to combine these two commands? I tried a few different options and assumed a bitmask of 0xaaaa and 0x5555 would be needed to "map" which channels get which tones.
But I keep running into syntax errors or
WARNING: erroneous pipeline: could not link capssetter0 to i
WARNING: erroneous pipeline: could not link queue0 to i
I feel like I'm close but not quite there.
any help would be greatly appreciated.
回答1:
Looks like I found a solution that works at least for an even output channel count:
gst-launch-1.0 interleave name=i audiotestsrc wave=0 freq=100 volume=0.4 ! decodebin ! audioconvert ! audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1 ! queue ! i.sink_0 audiotestsrc wave=2 freq=100 volume=0.4 ! decodebin ! audioconvert ! audio/x-raw,format=S16BE,channels=1,channel-mask=(bitmask)0x1 ! queue ! i.sink_1 i.src ! capssetter caps=audio/x-raw,format=S16BE,channels=6,channel-mask=(bitmask)0x3f ! audioconvert ! audioresample ! wavenc ! filesink location=test.wav
So the next trick would be to handle an odd output channel count. i.e 5
- I tried mapping the output to 6 channels but using a channel-mask=0x1f.
- Also tried mapping output to 6 channels then using:
! audioconvert ! capssetter caps="audio/x-raw,format=S16BE,channels=5,channel-mask=(bitmask)0x1f" !
neither of these worked.
来源:https://stackoverflow.com/questions/63884598/gstreamer-duplicate-2channel-audio