开发者

Merging several audio streams into one in red5

开发者 https://www.devze.com 2023-01-13 02:26 出处:网络
I have several flash clients that send live audio str开发者_Python百科eam to the Red5 server. Is it possible to combine all this audio streams together so that other clients could subscribe only to on

I have several flash clients that send live audio str开发者_Python百科eam to the Red5 server. Is it possible to combine all this audio streams together so that other clients could subscribe only to one audio stream and listen live audio from all publishers?


Is this possible yes, but only with red5, no. You will need to write your own library or use something like Xuggler. Red5 does not encode or decode audio or video data, so it is not able to merge or manipulate your stream in the way you would like.
Also be aware that if you do use a library to gain access to the audio stream, you will need to pay close attention when merging so that you don't get hiss'es and pops in your output audio. A more involved method, than the one below will be needed for more than two streams:

private short[] mixSamples(short[] samples1, short[] samples2) {
    short[] mixedSamples = new short[samples1.length];
    for (int s = 0; s < samples1.length; s++) {
        int sum = (samples1[s] + samples2[s]) / 2; 
        mixedSamples[s] = (short) (sum < Short.MIN_VALUE ? Short.MIN_VALUE : sum > Short.MAX_VALUE ? Short.MAX_VALUE : sum); 
    }
    return mixedSamples;
}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号