'Nginx Rtmp and FFMpeg | is it possible to make variable for ffmpeg settings?

I try to do variable for ffmpeg settings but always giving error! is it possible to add one variable for all different output

i set variable like this

set $ffmpegsettings "-c:a aac -ac 2 -ab 128k -ar 48000 -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 1200k -maxrate 1200k -bufsize 1000k -vf 'scale=-2:720' -f"

and use it at exec_static like this

exec_static ffmpeg -i http://myiptvlink $ffmpegsettings flv rtmp://localhost:1911/output/tv1;

exec_static ffmpeg -i http://myiptvlink $ffmpegsettings flv rtmp://localhost:1911/output/tv2;

exec_static ffmpeg -i http://myiptvlink $ffmpegsettings flv rtmp://localhost:1911/output/tv3;

exec_static ffmpeg -i http://myiptvlink $ffmpegsettings flv rtmp://localhost:1911/output/tv4;

i test nginx with configtest its "ok" but not creating hls. how to fix it?



Solution 1:[1]

If you want to forward a RTMP stream to multiple platform or servers, you'd better manage FFmpeg tasks by yourself, to use HTTP callback to start or stop task.

For example, you could use nodejs or Go as a backend server:

Nginx/MediaServer --HTTP-Callback--> BackendServer --> FFmpeg

It allows you to:

  1. Forward some streams, not all stream.
  2. Could restart the FFmpeg if config changed or process quit.
  3. You could deploy the backend server to another server.

Much better solution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Winlin