arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.35k stars 3.51k forks source link

Dynamic Facebook Streamkey Supported? #1514

Open michaeltoohig opened 4 years ago

michaeltoohig commented 4 years ago

There are some issues already about this very question but without an answer spanning back a few years.

929

1190

1459

1397 (the conversation turned into stunnel configuration. which already works for me if I statically place the FB streamkey into the exec command.)

The $name variable does not seem to contain all of the query args included in a Facebook live stream key. Example key 1234878994578373?s_bl=4&s_ps=2&s_sw=1&s_vt=api-s&a=ANk-6kdQfURTY3ss. In the Nginx logs I see the following:

nginx-rtmp_1  | 2020/04/29 04:21:00 [info] 10#10: *38 connect: app='facebook' args='' flashver='LNX 9,0,124,2' swf_url='' tc_url='rtmp://localhost:1935/facebook' page_url='' acodecs=4071 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935

This is my rtmp application block. If I put the full key in the place of $name at the end of the exec call then it does work but there is no dynamic key support.

application facebook {
            live on;
            record off;
            allow publish all;

            # Transcode and push the stream to stunnel for FB Live RMTPS requirements
            exec ffmpeg -i rtmp://localhost:1935/facebook/$name
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline -f flv rtmp://stunnel:19350/rtmp/$name;
        }

Thank you for clearing this up if possible.

Devidian commented 3 years ago

You might have found a solution until you asked, but for all others, maybe this woks (i dont stream to fb yet)

        application facebook {
            live on;
            record off;
            allow publish all;

            # Transcode and push the stream to stunnel for FB Live RMTPS requirements
            exec ffmpeg -i rtmp://localhost:1935/facebook/$name
              -c:a libfdk_aac -b:a 128k -c:v libx264 -b:v 2500k -f flv -g 30 -r 30 -s 1280x720 -preset superfast -profile:v baseline -f flv rtmp://localhost:1935/fbpush/$name;
        }

        application fbpush {
                live on;
                on_publish http://myapi.host.com/fbpush; # response with 303 redirect to rtmp://stunnel:19350/rtmp/dynamic_key
        }