Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks not working (runOnRead,runOnUnread,runOnRecordSegmentCreate,runOnRecordSegmentComplete) #3372

Closed
1 of 13 tasks
Byorun opened this issue May 19, 2024 · 5 comments
Closed
1 of 13 tasks

Comments

@Byorun
Copy link

Byorun commented May 19, 2024

Which version are you using?

v1.8.1

Which operating system are you using?

  • Linux amd64 standard
  • Linux amd64 Docker
  • Linux arm64 standard
  • Linux arm64 Docker
  • Linux arm7 standard
  • Linux arm7 Docker
  • Linux arm6 standard
  • Linux arm6 Docker
  • Windows amd64 standard
  • Windows amd64 Docker (WSL backend)
  • macOS amd64 standard
  • macOS amd64 Docker
  • Other (please describe)

Describe the issue

I am trying to use several hooks in order to automate/track some things of the stream, but several hooks won't get triggered.
Only runOnReady and runOnNotReady are working

  • runOnRead : no execution, no logs even on debug (I am trying to capture the current viewer count with that)
  • runOnUnread: no execution, no logs even on debug (I am trying to capture the current viewer count with that)
  • runOnRecordSegmentCreate: [path livestream/byorun] runOnRecordSegmentCreate command launched in logs but the script is not executed
  • runOnRecordSegmentComplete: [path livestream/byorun] runOnRecordSegmentComplete command launched in logs but the script is not executed

All scripts are basically the same, only the final webhook url changes

#!/usr/bin/bash

WEBHOOK_URL="https://HOSTNAME/mediamtx/webhook/on-stream-ready"

curl -s -d "{\"MTX_PATH\":\"${1}\", \"MTX_QUERY\":\"${2}\", \"MTX_SOURCE_TYPE\":\"${3}\", \"MTX_SOURCE_ID\":\"${4}\"}" -H "Content-Type: application/json" -X POST $WEBHOOK_UR

If I start a stream the runOnReady hook is triggered (which can be confirmed by the mediamtx log and and the webserver log)
If I stop a stream the runOnNotReady hook is triggered (which can be confirmed by the mediamtx log and and the webserver log)
The rest does nothing.

Describe how to replicate the issue

  1. start the server
  2. configure external http auth
authHTTPExclude:
- action: playback
- action: read
- action: api
- action: metrics
- action: pprof

I disabled read and playback auth calls due to heavy server load due to too many auth post requests in case of LL-HLS streams

paths:
  # example:
  # my_camera:
  #   source: rtsp://my_camera
  "~^livestream/([a-z0-9]+)$":
    record: yes
    runOnReady: /usr/local/bin/mediamtx_on_stream_ready $MTX_PATH $MTX_QUERY $MTX_SOURCE_TYPE $MTX_SOURCE_ID $G1
    runOnNotReady: /usr/local/bin/mediamtx_on_stream_not_ready $MTX_PATH $MTX_QUERY $MTX_SOURCE_TYPE $MTX_SOURCE_ID $G1
    runOnRead: /usr/local/bin/mediamtx_on_stream_read $MTX_PATH $MTX_QUERY $MTX_READER_TYPE $MTX_READER_ID $G1
    runOnUnread: /usr/local/bin/mediamtx_on_stream_unread $MTX_PATH $MTX_QUERY $MTX_READER_TYPE $MTX_READER_ID $G1
    runOnRecordSegmentCreate: /usr/local/bin/mediamtx_on_record_segement_created $MTX_PATH $MTX_SEGMENT_PATH $G1
    runOnRecordSegmentComplete: /usr/local/bin/mediamtx_on_record_segement_completed $MTX_PATH $MTX_SEGMENT_PATH $G1
  # Settings under path "all_others" are applied to all paths that
  # do not match another entry.
#  all_others:
  1. publish with obs
  2. read with web browser

Did you attach the server logs?

no useful output even on log level debug other than the two lines mentioned above

Did you attach a network dump?

no

@irg1008
Copy link

irg1008 commented Jun 16, 2024

Yep not working for me either

@irg1008
Copy link

irg1008 commented Jun 17, 2024

It's been a month without this pretty important feature. Does this mean it's not supported anymore, is this lib being abandonded? It's a deal breaker I think...., because the auth call for "ready" is not usable since it calls the url all the time while using LL-HLS....

@aler9
Copy link
Member

aler9 commented Jun 17, 2024

All problems reported in this issue are not bugs but misunderstandings about how the server works.

runOnRead : no execution, no logs even on debug (I am trying to capture the current viewer count with that)
runOnUnread: no execution, no logs even on debug (I am trying to capture the current viewer count with that)

In HLS there is no concept of reader and it's not technically possible to count readers, as explained in #962

runOnRecordSegmentCreate: [path livestream/byorun] runOnRecordSegmentCreate command launched in logs but the script is not executed
runOnRecordSegmentComplete: [path livestream/byorun] runOnRecordSegmentComplete command launched in logs but the script is not executed

you wrote "segement" instead of "segment" in the script name. It's impossible to assert for certainty if this solve your issue since you didn't attach server logs or configuration.

the auth call for "ready" is not usable since it calls the url all the time while using LL-HLS....

The "read" auth call (not the "ready" one which doesn't exist) is called for each HLS request if and only if you configure the server with external HTTP authentication. There are alternative ways to handle authentication, from JWTs to reverse proxies. The JWT method is described in the README.

@aler9 aler9 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2024
@irg1008
Copy link

irg1008 commented Jun 17, 2024

Would be great to have an auth call on client connect, the "read" can bloat the server

@aler9
Copy link
Member

aler9 commented Jun 17, 2024

Would be great to have an auth call on client connect, the "read" can bloat the server

as written in the previous post, there is not concept of "client" in HLS. BTW you're completely off topic here, so i'm forced to lock the issue.

@bluenviron bluenviron locked as off-topic and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants