0

I am trying to transcode the rtmp stream into hls and provide multiple quality streams with FFMPEG. I am trying to run the transcoding script on push, which from my understanding should start once the streamer is authenticated, but it never executes. I am using the following Nginx config (envs get substitued at runtime in docker)

worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
    server {
        listen 1935;
        listen [::]:1935 ipv6only=on;
        ping 1m;

        application live {
            live on;
            exec_push /opt/ffmpeg.sh $name ${NAME_SERVER};
            on_publish ${AUTH_SERVER};
        }
    }
}
http {
    server {
        listen 80;
        listen [::]:80 ipv6only=on;
        location / {
            types {
                application/vnd.apple.mpegurl m3u8;
                application/octet-stream ts;
            }
            root /tmp/hls;
            add_header Cache-Control no-cache;
            add_header Access-Control-Allow-Origin *;
        }
    }
}

Here's the ffmpeg script (if it even matters)

KEY="$1"
URL="$2"
NAME=$(curl $URL -d "key=$KEY")
mkdir -p "/tmp/hls/$NAME"
/usr/local/bin/ffmpeg/ffmpeg -i "rtmp://localhost/live/$KEY" \
  -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:v:0 -map 0:a:0 -map 0:a:0 -map 0:v:0 \
  -c:v libx264 -crf 22 -c:a aac -ar 48000 \
  -filter:v:0 scale=w=480:h=360  -maxrate:v:0 600k -b:a:0 500k \
  -filter:v:1 scale=w=640:h=480  -maxrate:v:1 1500k -b:a:1 1000k \
  -filter:v:2 scale=w=1280:h=720 -maxrate:v:2 3000k -b:a:2 2000k \
  -filter:v:3 scale=w=1920:h=1080 -maxrate:v:3 6000k -b:a:3 4000k \
  -var_stream_map "v:0,a:0,name:360p v:1,a:1,name:480p v:2,a:2,name:720p v:3,a:3,name:1080p" \
  -preset fast -hls_list_size 10 -threads 0 -f hls \
  -hls_time 3 -hls_flags independent_segments \
  -master_pl_name "$NAME.m3u8" \
  -y "/tmp/hls/$NAME/$NAME-%v.m3u8"

Also, it logs publish after I stop streaming (doesn't execute at this point either): PUBLISH "live" "streamKey" "" - 10849538 529 "" "FMLE/3.0 (compatible; FMSc/1.0)"

I tried exec_push touch /tmp/hi and that didn't execute either. I'm not sure why this doesn't work. I put up a github issue but no one responded, I hope someone will be willing to help here :)

0 Answers0