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.41k stars 1.45k forks source link

WebRTC is unable to serve av1 content #2058

Closed Managor closed 1 year ago

Managor commented 1 year ago

Which version are you using?

v0.23.7

Which operating system are you using?

Describe the issue

When I try serve av1 content with WebRTC, MediaMTX outputs mediamtx[1781]: 2023/07/14 13:25:06 INF [WebRTC] [session 4b744ce8] closed (the stream doesn't contain any supported codec, which are currently H264, VP8, VP9, G711, G722, Opus) into journalctl. I send the av1 data to MediaMTX using ffmpeg -re -stream_loop -1 -i Videos/av1test.mp4 -f rtsp rtsp://localhost:8554/usbcamera. I've downloaded MediaMTX through AUR which I assume is up to date enough.

I assumed it should work out of the box since it's listed in the documentation and there was bi documentation on how to enable it.

Describe how to replicate the issue

  1. Install MediaMTX through AUR
  2. publish with ffmpeg -re -stream_loop -1 -i Videos/av1test.mp4 -f rtsp rtsp://localhost:8554/usbcamera
  3. read with any browser

Did you attach the server logs?

no

Did you attach a network dump?

no

Managor commented 1 year ago

The sample video I used is https://github.com/SPBTV/video_av1_samples/blob/master/spbtv_sample_bipbop_av1_960x540_25fps.mp4

zapf2000 commented 1 year ago

The sample video I used is https://github.com/SPBTV/video_av1_samples/blob/master/spbtv_sample_bipbop_av1_960x540_25fps.mp4

Which browser do you use? Currently av1 in webrtc is not supported by firefox and others, but it should work on chrome. I ingest with vdo.ninja and WHIP. using WHEP player, it works, but with some audio issues on chrome (see my other issues). interesting on that issue: firefox can play av1 inside a webm container without problems (when using icecast as a server). if mediamtx could remux av1 in a webm container, it could be played by all av1 capable browsers at this time.

Managor commented 1 year ago

I have tested with chrome and firefox and with several file types. There is a separate error message for client side lack of support. This error that is mentioned in the OP is a serverside issue. I'll edit the client side error message here once I get back to it.

zapf2000 commented 1 year ago

Oh, I also see that the audio codec in that mp4 is AAC, but AAC is not supported by webrtc (only Opus).

Managor commented 1 year ago

Ah I see. I'll test that later. Thanks.

The error message still needs to be changes so that it includes AV1

Managor commented 1 year ago

The error message for when a browser doesn't support the codec is [WebRTC] [session f6d01866] closed (unable to start track, codec is not supported by remote)

I tested with a test file that has stripped audio and the mediamtx[3904]: 2023/07/17 09:26:23 INF [WebRTC] [session 5ed5599c] closed (the stream doesn't contain any supported codec, which are currently H264, VP8, VP9, G711, G722, Opus) error still appears.

https://github.com/bluenviron/mediamtx/assets/42655600/4a304b1b-d620-492f-9a75-cffd97a396f5

aler9 commented 1 year ago

Hello, the command you posted:

ffmpeg -re -stream_loop -1 -i Videos/av1test.mp4 -f rtsp rtsp://localhost:8554/usbcamera

doesn't send an AV1 video to the server since you're missing the -c copy flag:

ffmpeg -re -stream_loop -1 -i Videos/av1test.mp4 -c copy -f rtsp rtsp://localhost:8554/usbcamera

What happens instead is that FFmpeg converts the video into the default codec, which is MPEG 4 video (aka H263), which is an old codec not supported by WebRTC.

Next time please take a look at server logs and attach them as instructed to, since in both server logs and FFmpeg logs it's clearly written that the codec is wrong:

Stream mapping:
  Stream #0:1 -> #0:0 (av1 (native) -> mpeg4 (native))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Managor commented 1 year ago

I case anyone stumbles upon this issue through a search engine: At the current date ffmpeg does not support av1 over rtsp. You should use gstreamer instead. This is an example command that I used to make it work: gst-launch-1.0 filesrc location=Videos/av1noaudio.mp4 ! qtdemux ! av1parse ! rtspclientsink location=rtsp://localhost:8554/usbcamera

github-actions[bot] commented 7 months 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.