简体   繁体   中英

Merging several audio streams into one in red5

I have several flash clients that send live audio stream 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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM