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
12.18k stars 1.53k forks source link

raw query for the publisher not available in hooks #2483

Closed zeridon closed 1 year ago

zeridon commented 1 year ago

Which version are you using?

v1.1.1-32-g9de6423

Which operating system are you using?

Describe the issue

We are streaming via RTMP and consuming via HLS. We are using external authentication. RTMP itself starts to stream to rtmp://server.com:1935/some/path?token=xoxo-token

This leads to starting a path called some/path

When the path is ready to be streamed by clients (HLS) we want to runOnReady a script.sh which does some internal housekeeping and additional notifications. For this we need query to be available in some form (similar to externalAuthenticationURL is perfect).

Describe how to replicate the issue

externalAuthenticationURL: http://127.0.0.1:8085/auth
rtsp: no
webrtc: no
srt: no
rtmp: yes
rtmpAddress: 0.0.0.0:1935
rtmpEncryption: "no"

hls: yes
# encryption is enabled

paths:
  "~^(some|not-some|test)/(path|other)(.*)":
    source: publisher
    runOnReady: /usr/local/bin/notis-send.sh started $G2 $G1 $G3
  1. start the server
  2. publish with: ffmpeg -re -i src.flv -c copy -f flv rtmp://server.com:1935/some/path?token=xoxo-token&internal_param=xxx
  3. read with: does not matter

G3 capture group does not exists. There is also nothing in the env, there are no additional (usable) vars in the invocation of the script

Did you attach the server logs?

no

Did you attach a network dump?

no

aler9 commented 1 year ago

Hello, Regarding the presence of G1, G2, G3, i created this script:

#!/bin/sh

echo $1
echo $2
echo $3

env

and i ran it with the configuration you provided:

paths:
  "~^(some|not-some|test)/(path|other)(.*)":
    source: publisher
    runOnReady: ./my_script.sh started $G2 $G1 $G3

The script worked correctly and printed the arguments:

started
path
some

and then the entire environment:

MTX_SOURCE_TYPE=rtmpConn
HOSTNAME=alex
SHLVL=1
MTX_PATH=some/path/tte
HOME=/root
G1=some
RTSP_PATH=some/path/tte
G2=path
G3=/tte
MTX_SOURCE_ID=24ef314c-0fe2-4603-adf5-638c4bfd0b68
_=/usr/local/go/bin/go
TERM=xterm
PATH=/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
PWD=/s
RTSP_PORT=8554
GOLANG_VERSION=1.20.10

So i could not found any bug here.

Regarding the possibility of using query parameters in hooks, i'll add an additional environment variable that contains query parameters. Next time please create two separate issues.

zeridon commented 1 year ago

Correct. If streaming to rtmp://server.com:1935/some/path/otherthings?token=xoxo-token&internal_param=xxx G3 is populated. Probably i misunderstood how path is being consumed by mediamtx.

Thanks for #2522 that was exactly what i needed.

aler9 commented 1 year ago

added in v1.2.1

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