Reputation: 151
I am trying to stream a webpage to Facebook Live video using ffmpeg. I know I can use OBS, but I'm trying to do it from a server, so I can't go with OBS. It works fine when I'm previewing, but as soon as I press 'Go live', at first it seems like it's starting, but then when it takes me to the live view it just says that the video has ended. I even checked the error of the video log using Graph API, nothing. I'm using PhantomJS to pipe screenshots to ffmpeg:
phantomjs phantom.js | ffmpeg -y -c:v mjpeg \
-f image2pipe \
-r 5 -i \
- -c:v libx264 \
-x264-params keyint=5 \
-b:v 1000k -minrate 1000k -maxrate 1000k -bufsize 500k \
-f flv 'rtmp://rtmp-api.facebook.com:80/rtmp/xxxxxxxxxxxxxxxx'
As I said, it's working fine in the preview of the live stream on Facebook, but just ends immediately when I go live. I added the bitrate options to try to keep a constant bitrate as mandated by Facebook (https://developers.facebook.com/docs/videos/live-video/production-broadcasts), and I have a keyframe every 5 frames (rather low frame rate at 5fps) so that requirement is fulfilled as well.
I'm not sending any audio, could that cause a problem?
Upvotes: 3
Views: 6585
Reputation: 163568
Facebook Live requires a frame rate of 30 FPS. You're sending it 5, so you'll need to convert up. You also need a keyframe interval of 2 seconds max. Try adding an output frame rate:
phantomjs phantom.js | ffmpeg -y -c:v mjpeg \
-f image2pipe \
-framerate 5 \
-i - \
-r 30 \
-c:v libx264 \
-x264-params keyint=60 \
-b:v 1000k -minrate 1000k -maxrate 1000k -bufsize 500k \
-f flv 'rtmp://rtmp-api.facebook.com:80/rtmp/xxxxxxxxxxxxxxxx'
Upvotes: 1