3

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?

5

1 Answer 1

1

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'
5
  • Still not working, outputs at low framerate. can you help. Nov 17, 2016 at 18:20
  • 1
    @bhargavjoshi If you don't have audio add silence -f lavfi -i anullsrc & -c:a aac (might be BS but some seem to expect or require audio). You also may need to use YUV 4:2:0, so add -pix_fmt yuv420p as an output option, and try using -re with your inputs.
    – llogan
    Nov 17, 2016 at 19:03
  • @bhargavjoshi Can you output to a file to verify that the output is 5 FPS and not 30? And can you show the order of your parameters? The -r 30 needs to be after the specification of STDIN and before the output URL.
    – Brad
    Nov 17, 2016 at 20:51
  • @bhargavjoshi did you figure this out?
    – bumpkin
    Feb 11, 2018 at 16:15
  • 1
    @bumpkin yes it required to add some audio and then it worked. Feb 14, 2018 at 3:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.