datarhei / restreamer

The Restreamer is a complete streaming server solution for self-hosting. It has a visually appealing user interface and no ongoing license costs. Upload your live stream to YouTube, Twitch, Facebook, Vimeo, or other streaming solutions like Wowza. Receive video data from OBS and publish it with the RTMP and SRT server.
https://docs.datarhei.com/restreamer/
Apache License 2.0
3.92k stars 448 forks source link

Change address of the network source via API #668

Closed sara990099 closed 10 months ago

sara990099 commented 10 months ago

How can I change the address of the network source for a stream via API?

curl -X 'GET' \
  'http://127.0.0.1:8080/api/v3/process/restreamer-ui:ingest:***' \
  -H 'accept: application/json' \
  -H 'Authorization: ***'

{ "id": "restreamer-ui:ingest:", "type": "ffmpeg", "reference": "", "created_at": 1704051711, "updated_at": 1704051711, "config": { ... }

curl -X 'PUT' \
  'http://127.0.0.1:8080/api/v3/process/restreamer-ui:***/playout/input_0/stream' \
  -H 'accept: text/plain' \
  -H 'Content-Type: text/plain' \
  -d 'http://***.m3u8' \
  -H 'Authorization: ***'

{"code":404,"message":"Unknown process or input","details":["no playout for input ID 'input_0' and process 'restreamer-ui:***'"]}

ioppermann commented 10 months ago

In order to change the network source for a stream via API, you have to modify the config object, that is returned by the GET /api/v3/process/restreamer-ui:ingest:*** command.

Change the network source in config.input[0].address to http://***.m3u8. Then make a PUT to /api/v3/process/restreamer-ui:ingest:*** with the contents of the config object, e.g.

curl http://127.0.0.1:8080/api/v3/process/restreamer-ui:ingest:*** \
   -H 'accept: application/json' \
   -H 'Content-Type: application/json' \
   -H 'Authorization: ***' \
   -X PUT \
   -d '{
         "id": "restreamer-ui:ingest:***",
         "input": [
            {
               "address": "http://***.m3u8",
               ...
            }
         ],
         ...
      }'

You might need to adjust the input's options as well if you change protocol. After successfully updating the process, it will restart in case it was already running.

Please also check the documentation for the process API: https://docs.datarhei.com/core/api-ffmpeg/process and the Beginner's guide at https://docs.datarhei.com/core/guides/beginner#id-3.-main-process