samirkumardas / opus-to-pcm

Decode raw opus packet to PCM without using any external library in your browser.
Other
73 stars 15 forks source link

Delay of arround 1 sec while playing decoded audio. #8

Closed kuldeepmore closed 4 years ago

kuldeepmore commented 5 years ago

Hello I have used this opus decoding code and integrated in my application to play encoded opus audio. Audio is decoding properly and I am getting clear audio. But the problem is it is playing audio 1 sec late as compared to video. I have audio and video data coming on web sockets in java-script and I am decoding both but audio lagging behind video exactly 1 sec. I have also tried only playing audio with decoding and playing in java-script and compared with VLC audio of same stream ans I have noticed around 1 sec delay. Any help would be appreciated.

Thanks, Kuldeep.

samirkumardas commented 5 years ago

how are you playing pcm data eventually? Using the example pcm player?

Could you please try adjusting flush time of the pcm player as that could create a small delay

kuldeepmore commented 5 years ago

I am using the sample player given your code as below. audio_Decoder1.on('decode', function(pcmData) { console.log("play audio data"); player.feed(pcmData); });

Also as you mentioned I have changed the, this.flushingTime = 0;
with values 100,10 and even 0 but does not have any effect.

samirkumardas commented 5 years ago

I don't think this delay is created by opus-to-pcm then. At least I had not got any delay to my cases. Are you getting both audio and video data simultaneously?