0
votes

I am using nginx and rtmp module to stream live hls and mpeg-dash. here is my rtmp command in nginx .conf

rtmp {
server {
    listen 1936;


    application mypull {
    live on ;
    meta copy;
    allow play all;

    pull rtmp://184.72.239.149/vod/BigBuckBunny_115k.mov name=test live=1;


    exec_push   /usr/bin/ffmpeg -re -i rtmp://localhost:1936/mypull/$name -vcodec libx264 -acodec libmp3lame -f flv rtmp://localhost:1936/hls/$name;


}


application dash {
        live on;
        dash on;
        dash_path /tmp/dash;
        dash_nested on;
        dash_fragment 5s;
        dash_playlist_length 30s;
    }
     application hls {
        live on;
        hls on;
    hls_playlist_length 30s;
    hls_fragment 5s;
        hls_path /tmp/hls;
    }
}
}

but it is not playing. it seems that the ffmpeg command is not even running. and the hls and dash folders are empty. could anyone help me with it?

3
After replacing the variables with the actual streamID, does your ffmpeg command work from command line? - Gergely Lukacsy
this is the real id, my nginx.conf is exactly like this. it does not create any output. @GergelyLukacsy - evan
No. The stream ID is being substituted in the $name variable. When you open the stream, the URL looks like this: rtmp://server.com:1935/mypull/12345 where 12345 is your stream ID. I think you can substitute anything in this case, so try this is your console: ffmpeg -re -i rtmp://localhost:1936/mypull/123 -vcodec libx264 -acodec libmp3lame -f flv rtmp://localhost:1936/hls/123 Also, make sure the port is open in your firewall settings. Why are you using 1936 for RTMP? The default is 1935. - Gergely Lukacsy
Also, what part of the system does not work? You listed three different applications here. RTMP? HLS? HDS? - Gergely Lukacsy
my stream id is test. i declared it in name=test, and i also opened the port (1936). my hls application is not working and it seems like it is not making the segments and the m3u8 file, because when i try to play it on an online player, with F12 it gives the 404 for test.m3u8 @GergelyLukacsy - evan

3 Answers

3
votes

Edit your nginx.conf file and put in first line :

user  root;

This will run your command as root

0
votes

Put the ffmpeg command in a bash script. For example, my bash script is named ff.sh, and is stored in folder /files

Put the entire ffmpeg command in the script, and make it executable:

chmod +x /files/ff.sh

exec_push the script in nginx.conf

application origin {
live on;
 exec_push /files/ff.sh;
}

You might find that this works for you.

0
votes

Ensure that the user running nginx can execute commands. Often it has no shell assigned.