6

I use the following ffmpeg command to share my screen streaming to Facebook.

enter image description here

ffmpeg -f avfoundation -r 10 -video_size 352x288 -i "0" -c:v h264 -f flv 
"rtmp://rtmp-api.facebook.com:80/rtmp/1269140699772419?ds=1&a=AaYsXcYcdHQrrrUF"

then I can see the video preview scenes enter image description here

however, once I press the 'Go Live' button, and go to my facebook page, I can find a post said I am Live Now. When I press the 'play button', there are only black scenes that last for 1~2 seconds, and the video ends.

enter image description here

And there is also a weird thing, the video can be played when I end up the live stream. When refreshing the page, I can find a post said I was Live, the video of this post can be played successfully.

Anyone knows why the video can be watched when previewing and finishing live but not the exact live moment?

[updated]

During the live streaming period, if I press the play button, there are only 1~2 seconds black scenes and the live stream ends. enter image description here

However if I press the video frame again, another modal pops up then I can see the live streaming. Is it a facebook bug? enter image description here

Hui-Yu Lee
  • 909
  • 8
  • 20
  • I suspect this has to do with codec support in your browser. What browser are you using? And, just to be clear, the preview is fine but you're unable to watch the actual video on your Facebook wall? – Brad Sep 10 '16 at 03:01
  • @Brad I use the update-to-date google chrome. And yes the preview works well but the video on my wall shows nothing during the streaming moment – Hui-Yu Lee Sep 11 '16 at 15:17
  • I am having similar preview issues. As the final recording is perfect, I figured it was a facebook bug. However, I am also using chrome so now wonder if next time I should give a different browser a try.. – Mike Versteeg Nov 16 '16 at 08:04
  • Thanks, but how did you confirmed that it is a facebook bug, did you report to Facebook? BTW I also tried Safari and FireFox desktop, neither worked. – Hui-Yu Lee Nov 17 '16 at 09:44
  • I said figured, not confirmed. But there are more of these issued (like fb taking several minutes to detect the stream has ended) so it feels kinda beta to me. I did discuss this with them and there response was to use the API to properly mark the stream ended. I explained them I am not allowed to use their API (as I can stream to multiple hosts) and that other CDNs have no issue at all detecting the end of the stream. Their response was, er, not helpful. – Mike Versteeg Jan 07 '17 at 11:05

2 Answers2

3

When you view the video as live see in inspect panel for Chrome if there is anything there. Could be some warnings or errors why video is not going through. I had the same issue when working with WebRTC through wss.

Another thing to try for ffmpeg command is to add: -c:v libx264 -profile:v baseline -level 3.1 -pix_fmt yuv420p

to be: ffmpeg -f avfoundation -r 10 -i "0" -c:v libx264 -profile:v baseline -level 3.1 -pix_fmt yuv420p -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/1269140699772419?ds=1&a=AaYsXcYcdHQrrrUF"

You can see the video after live event as encoding happens to save it and it is viewable in the browser and testable. For live streams only copy happens and you have play with ffmpeg arguments to make it viewable on that page.

  • thanks. I checked the console but there is nothing wrong related to the live streaming. And I tried the parameters still cannot view when live. But if you press the video the video can be played(I update my post for some screenshots, is that a bug of facebook?) – Hui-Yu Lee Sep 29 '16 at 03:36
2

I also encountered the same problem. In my case, I was looping over images to make video and stream it to facebook without sending any audio stream.

As per the guidelines of facebook, the live video stream must contain the audio stream in it, otherwise the live video is considered as over.

Make sure that the input file that you are streaming to fb contains audio stream. In case, it doesn't have any audio stream, you can still use any other audio stream along with it and then you can see your video live after pressing go live button.

ffmpeg -loop 1 -re -y -f image2 -i "image_path" -i "silent_audio_or_any_other_audio" -codec:a aac -ac 1 -ar 44100 -b:a 128k -pix_fmt yuv420p -profile:v high -s 1280x720 -vb 400k -maxrate 400k -minrate 400k -bufsize 600k -deinterlace -vcodec libx264 -preset veryfast -g 30 -r 30 -strict -2 -f flv "rtmp_link"

I am still using this code and this works perfectly for me :)

Hope, this may help someone.

Aakash Gupta
  • 756
  • 4
  • 16
  • 1
    Yes! You got the point! I also refer to http://stackoverflow.com/questions/32017827/ffmpeg-create-silent-ogg-audio-file to add silent audio, so my command becomes: ffmpeg -f lavfi -i anullsrc -f avfoundation -r 10 -video_size 352x288 -i "0" -f flv "rtmp_stream_url", I will updated your answer a bit. – Hui-Yu Lee Jan 24 '17 at 03:16