bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
11.69k stars 1.47k forks source link

Missing audio in webrtc stream produced by the server #1443

Closed dev-svk-flbs closed 1 year ago

dev-svk-flbs commented 1 year ago

Which version are you using?

v0.21.1

Which operating system are you using?

Describe the issue

I am producing astream using ffmpeg and sending it to the rtsp simple server. The following is the ffmpeg configuration I am using to send the stream:

command = ['ffmpeg', '-y', '-re', '-f', 'rawvideo', '-thread_queue_size', '1024', # May help https://stackoverflow.com/questions/61723571/correct-usage-of-thread-queue-size-in-ffmpeg '-vcodec','rawvideo', '-pix_fmt', 'bgr24', '-s', "{}x{}".format(width, height), '-r', str(fps), '-i', '-', '-vn', '-f', 'dshow', '-i', 'audio=Microphone (Realtek(R) Audio)', '-rtbufsize', '3041280', # Get the audio stream without using OpenCV '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-preset', 'ultrafast', '-c:a', 'aac', # Select audio codec '-bufsize', '128M', # Buffering is probably required '-b:v', '6000K', '-flush_packets', '0', '-f', 'rtsp', rtsp_server]

The input comes from opencv. This command received opencv frames, and combines with audio captured from webcam and stream to rtsp server. the rtsp, hls and webrtc streams all work fine except the webrtc stream has no audio. when I open rtsp stream from vlc at localhost:8554/mystream, it works like a charm. When I go tolocalhost:8888/mystream, works fine, I can see and hear everython, expect there is 11 seconds delay (expected with hls)

However, when I go to localhost:8889/mystream, I can see the stream but audio seems to be disabled.

Describe how to replicate the issue

  1. start the server
  2. publish with ffmpeg command above
  3. read the stream at localhost:8889/mystream(the default)

Did you attach the server logs?

2023/02/03 09:55:19 INF rtsp-simple-server v0.21.1 2023/02/03 09:55:19 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP) 2023/02/03 09:55:19 INF [RTMP] listener opened on :1935 2023/02/03 09:55:19 INF [HLS] listener opened on :8888 2023/02/03 09:55:19 INF [WebRTC] listener opened on :8889 (HTTP) 2023/02/03 09:55:57 INF [RTSP] [conn [::1]:51604] opened 2023/02/03 09:55:57 INF [RTSP] [session 74e02b36] created by [::1]:51604 2023/02/03 09:55:57 INF [RTSP] [session 74e02b36] is publishing to path 'mystream', with UDP, 2 tracks (H264, MPEG4-audio)
2023/02/03 09:56:28 INF [WebRTC] [conn [::1]:51614] opened 2023/02/03 09:56:29 INF [WebRTC] [conn [::1]:51614] peer connection established, local candidate: host/udp/192.168.150.1/55889, remote candidate: prflx/udp/192.168.150.1/50164 2023/02/03 09:56:29 INF [WebRTC] [conn [::1]:51614] is reading from path 'mystream', 1 track (H264) 2023/02/03 09:56:43 INF [WebRTC] [conn [::1]:51614] closed (websocket error: websocket: close 1001 (going away))

As you can see I successfully established the stream, and accessed the webrtc stream from google chrome browser v109.0.5414.120, and then closed it.

yes

Did you attach a network dump?

no

aler9 commented 1 year ago

As clearly stated in the README, the AAC codec is not supported by WebRTC. You have to re-encode the audio track by using the Opus codec.

github-actions[bot] commented 1 year ago

This issue is being locked automatically because it has been closed for more than 6 months. Please open a new issue in case you encounter a similar problem.