arut / nginx-rtmp-module

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

Push transcoded video to different RTMP servers #1286

Open RAcbd opened 6 years ago

RAcbd commented 6 years ago

Hi everyone, I'm trying to stream on Twitch (720p) and Facebook Live (1080p/default on OBS)

Problem:

Facebook Live accepts 6000 bitrate and doesn't buffer. Twitch buffers at anything more than 2500 bitrate.

I want to use the ffmpeg option to force the twitce transcoding on a slower bitrate. Here's what I did.

`rtmp { server { listen 1935; chunk_size 4096;

    application live {
        live on;
        record off;

        allow publish all;
        allow play all;

        # 6000 bitrate for Facebook
        push rtmp://127.0.0.1:1935/facebook;

        # 2500 bitrate for Twitch
        on_publish ffmpeg -i rtmp://127.0.0.1:1935/live/$name -b:v 2500k -minrate 2500k -maxrate 2500k -bufsize 2500k -threads 1 -vcodec flv -acodec copy -s 1280x720 -f flv rtmp://127.0.0.1:1935/facebook;
    }

    application twitch {
        live on;
        record off;

        push rtmp://live-hkg.twitch.tv/app/STREAMKEY;
    }

    application youtube {
        live on;
        record off;

        push rtmp://live-api.facebook.com:80/rtmp/STREAMKEY;
    }
}

}`

Any help would be appreciated! Thank you!

MasterEvilAce commented 6 years ago

You've got a lot of problems, here. Your two directives in LIVE are both trying to push to facebook. You don't even have a facebook application, just twitch and youtube. vcodec should probably be libx264, not FLV.

You shouldn't need separate applications if you're not doing anything special with them.. So I imagine something like this would work, or at the very least, this is what I'd start with:

rtmp {
server {
listen 1935;
chunk_size 4096;

    application live {
        live on;
        record off;

        allow publish all;
        allow play all;

        # 6000 bitrate for Facebook
        push rtmp://live-api.facebook.com:80/rtmp/STREAMKEY;

        # 2500 bitrate for Twitch
        exec ffmpeg -i rtmp://127.0.0.1:1935/live/$name -b:v 2500k -minrate 2500k -maxrate 2500k -bufsize 2500k -threads 1 -vcodec libx264 -acodec copy -s 1280x720 -f flv rtmp://live-hkg.twitch.tv/app/STREAMKEY;
    }
}
}
RAcbd commented 6 years ago

The youtube application was changed to facebook, it works (kinda). Just doesn't seem to use the exec/on_publish command and use a different bitrate for facebook/youtube application.

Also, I'll try that out.

EDIT: Forgot to say that the exec command doesn't work on Windows. Might be the problem for it.

EDIT 2: Getting this from the log

2018/06/29 00:53:50 [emerg] 7092#12872: no "events" section in configuration

FIXED EDIT 2 Issue. Going back to old issue.