Hui-Yu Lee
Hui-Yu Lee

Reputation: 989

Facebook live video can only be previewed while streaming my Mac screen

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

Upvotes: 6

Views: 2319

Answers (2)

Aakash Gupta
Aakash Gupta

Reputation: 756

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.

Upvotes: 2

Olga Khylkouskaya
Olga Khylkouskaya

Reputation: 495

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.

Upvotes: 3

Related Questions