deepch / RTSPtoWebRTC

RTSP to WebRTC use Pion WebRTC
MIT License
1.55k stars 413 forks source link

Garbled audio when streaming live rtsp source from ffmpeg #86

Open benbullnz opened 3 years ago

benbullnz commented 3 years ago

Hi,

I am getting very garbled audio when streaming a live input from ffmpeg. The stream in question plays fine in ffplay and everywhere else that I try, but once in RTSPtoWebRTC, audio becomes very broken.

When streaming from a file via ffmpeg, audio in RTSPtoWebRTC is great.

Both the file based rtsp stream and live audio rtsp stream are using opus codec at 64kb/s and are being proxied using rtsp-simple-server.

SDP for garbled audio below:

v=0 o=- 0 0 IN IP4 127.0.0.1 s=Stream c=IN IP4 0.0.0.0 t=0 0 m=audio 0 RTP/AVP 96 b=AS:64 a=rtpmap:96 opus/48000/2 a=fmtp:96 sprop-stereo=1 a=control:trackID=0

Attached is the broken audio. Garbled OPUS RTSP.m4a.zip

benbullnz commented 3 years ago

This seems to be related to Opus frame sizes. It seems as if RTSPtoWebRTC only supports OPUS encoded frame size of 20ms. Is there anyway to support 5ms and 10ms?

JJ995 commented 3 years ago

Hi!

I think i'm facing a similar problem: converting a rtsp stream via ffmpeg: ffmpeg -i 'rtsp://127.0.0.1:554/tdaudio' -codec:a pcm_mulaw -f rtsp -rtsp_transport tcp 'rtsp://localhost:8554/tdaudio' and serving it via rtsp-simple-server. Playback is fine via VLC but completely muffled when streamed via WebRTC...

Did you find any solution?

JJ995 commented 3 years ago

fyi: i was able to solve to problem by encoding directly with the libopus codec - audio is clear now :)

ffmpeg -i 'rtsp://127.0.0.1:554/tdaudio' -codec:a libopus -f rtsp -rtsp_transport tcp 'rtsp://localhost:8554/tdaudio'