I use the following ffmpeg command to share my screen streaming to Facebook.
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
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.
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.
However if I press the video frame again, another modal pops up then I can see the live streaming. Is it a facebook bug?
Check your internet connection: If your internet connection is slow, try restarting your router or modem (internet connection device). If you're using Wi-Fi, try reconnecting to your network or connecting to a different network.
1. Go to your group page where you plan to do your live stream. 2. Scroll down until you see Group Settings on the left panel > click Privacy > select your preferred privacy setting (Public or Private) > hit Save.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With