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

RTPM authentication using ffmpeg to post fails #2056

Closed sperezs95 closed 1 year ago

sperezs95 commented 1 year ago

Which version are you using?

v0.23.5

Which operating system are you using?

Describe the issue

Does not publish RMTP with authentication

Describe how to replicate the issue

  1. I have configured the authentication to post as follows in the mediamtx.yml file:

publishUser: "admin" publishPass: "admin"

  1. Start the server using executable mediamtx.exe
  2. Then, I tried to post a stream using the command:

ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f flv rtmp://admin:admin@localhost:1935/mystream

I got the following error in the console:

[aost#0:1/copy @ 00000273a836a580] Error submitting a packet to the muxer: Error number -10054 occurred [out#0/flv @ 00000273a83648c0] Error muxing a packet [flv @ 00000273a8364cc0] Failed to update header with correct duration. [flv @ 00000273a8364cc0] Failed to update header with correct filesize. [out#0/flv @ 00000273a83648c0] Error writing trailer: Error number -10054 occurred [out#0/flv @ 00000273a83648c0] Error closing file: Error number -10054 occurred [out#0/flv @ 00000273a83648c0] video:2671kB audio:37kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown frame= 83 fps= 37 q=-1.0 Lsize= 2409kB time=00:00:02.70 bitrate=7286.0kbits/s speed=1.22x

While in the mediamtx log I got the following:

2023/07/13 19:14:21 INF [RTMP] [conn [::1]:51906] opened 2023/07/13 19:14:23 INF [RTMP] [conn [::1]:51906] closed (invalid credentials)

  1. If I publish an rtsp stream it does work:

ffmpeg -re -stream_loop -1 -i file.mp4 -c copy -f rtsp rtsp://admin:admin@localhost:8554/mystream

  1. Read with VLC and RTSP is ok.

Did you attach the server logs?

no, the logs are in the description

Did you attach a network dump?

no

I'm relatively new to this. I hope I'm not making any obvious mistakes. I appreciate any help!

aler9 commented 1 year ago

Hello, when using RTMP, you have to pass credentials through query parameters:

rtmp://localhost/mystream?user=myuser&pass=mypass

The standard way of passing credentials doesn't work since an RTMP client passes those credentials to the server before telling the server whether it wants to publish or read a stream, and therefore we couldn't distinguish between publishUser and readUser.

This was written in the README until some time ago but i recently rewrote the README from scratch and i just found out that this information has gone missing. I've added a specific note: #2057

sperezs95 commented 1 year ago

Thank you very much for your help! I already managed to publish!

Hello, when using RTMP, you have to pass credentials through query parameters:

rtmp://localhost/mystream?user=myuser&pass=mypass

The standard way of passing credentials doesn't work since an RTMP client passes those credentials to the server before telling the server whether it wants to publish or read a stream, and therefore we couldn't distinguish between publishUser and readUser.

This was written in the README until some time ago but i recently rewrote the README from scratch and i just found out that this information has gone missing. I've added a specific note: #2057

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