Gstreamer duplicate 2channel audio

若如初见. 提交于 2021-02-11 14:49:50

问题


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

  1. I tried mapping the output to 6 channels but using a channel-mask=0x1f.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!