The service suggests the following command:
exec_publish ffmpeg -i rtmp://127.0.0.1/live/name -async 1 -vsync 1 -c copy -f flv "rtmp://live.cdn.asset.aparat.com:443/event/<stream key>";
Let's understand the command above:
rtmp://127.0.0.1/live/name - This is a block on your nginx settings. So you must to create a server block listening the localhost, port 1935, because 1935 is the default rtmp protocol port, or you can change to any other port and append this port to the command above, like this:
rtmp://127.0.0.1:port/live/name
rtmp://127.0.0.1/live/name - This is the publishing point and your nginx publish block inside the server block above (this name can be anything that you wish) but it must to exists otherwise the nginx server will drop the connection.
rtmp://127.0.0.1/live/name - This is your streaming name (this name can be anything that you wish) like the publish name above.
Ok. Now you have a new rtmp server block, listening localhost connections, using the port that you wish, the publish name that you wish and the streaming name that you wish. Now, inside this block you must to re-encode your streaming using ffmeg if required by the service destination (aparat) and send it to the stunnel proxy or simply push the stream to the stunnel proxy because this service requires RTMPS. Something like this:
rtmp {
server {
listen 127.0.0.1:1935;
# or 127.0.0.1:yourPort;
application live {
live on;
# i will push the stream name to the stunnel proxy,
# without re-encoded it because i believe you can adjust the broadcaster
# software to send it as your service requires it.
# Understand that stunnel proxy will be listening localhost connections
# under the port 1936 or change it to your stunnel settings
push rtmp://127.0.0.1:1936/event/streamkey
}
}
}
Now, let's understand the push stunnel proxy url:
push rtmp://127.0.0.1:1936/event/streamkey
rtmp://127.0.0.1:1936/event/streamkey - This part is the url where stunnel will listen connections, server(127.0.0.1) and port(1936).
rtmp://127.0.0.1:1936/event/streamkey - This is the path where stunnel will publish your stream on then service destination (aparat).
Now, stunnel will simply replace the 127.0.0.1:1936 by the host and port required by the service (443) and send your stream using RTMPS.
Below, my sugestion for the stunnel.conf:
pid = /var/run/stunnel4/stunnel.pid
output = /var/log/stunnel4/stunnel.log
setuid = stunnel4
setgid = stunnel4
# https://www.stunnel.org/faq.html
socket = r:TCP_NODELAY=1
socket = l:TCP_NODELAY=1
debug = 4
[aparat-live]
client = yes
accept = 127.0.0.1:1936
connect = rtmp.cdn.asset.aparat.com:443
verifyChain = no
Now, on your default pusblish block on your server, add this line, replacing the first command suggested by your remote service:
push rtmp://127.0.0.1:1935/live/name;
The command above inside your default publish block will push the stream to the server block (localhost:1935) and this will send the stream to the stunnel proxy.
Understand that you don't need the new server block to send the stream directly to the stunnel proxy. This is an explanation for your question using the command that you posted.
You can just replace that command by this on your default publish block, and it will send the stream to the stunnel proxy:
Replace
exec_publish ffmpeg -i rtmp://127.0.0.1/live/name -async 1 -vsync 1 -c copy -f flv "rtmp://live.cdn.asset.aparat.com:443/event/<stream key>";
By
push rtmp://127.0.0.1:1936/event/<streamkey>;
You only need a stunnel proxy working fine.
Done, restart nginx and stunnel services and happy stream.