简体   繁体   中英

How can i do Facebook Live (page) using FFMPEG

SOLVED & EDITED -

Catch: Doing live stream on Facebook with FMMPEG.

In past it was easy i did many times as facebook was using rtmp. But now facebook is using RTMPS so i am getting different errors i have tried 100 commands. I have a image test.png and a audio file test.m4a (its a podcast) and facebook stream key is 1234. ( i have tried 100 types of commands so cant post here and cant post errors aswell.) so please can someone help me to go live on my facebook page with image+m4a file. i prefer centos but i will manage ubuntu if you prefer. Regards..

Solved: See my answer might help someone.

SOLVED Hope it will be useful for someone.

I was trying with all possible results from google and stackoverflow. nothing worked. Then i did my own way and it worked after 2 hour. i will stream video out.mp4 from my server on Facebook.

  1. Install FFMPEG4 ( older version has issue with rtmps )
  2. ffmpeg -re -y -i out.mp4 -c:a copy -ac 1 -ar 44100 -b:a 96k -vcodec libx264 -pix_fmt yuv420p -tune zerolatency -f flv -maxrate 2000k -preset veryfast "rtmps://live-api-s.facebook.com:443/rtmp/key"

You can stream on as many platforms as you want.

PS. if you want to stream image+audio replace our.mp4. but i used ffmpeg to make video from m4a file ( it will stream without lag) & buffer)

If you are on CentOS or Redhat, you may find it difficult to intall ffmpeg. Or your installation can miss some of the libraries/protocols required by ffmpeg to be able to do FB live. For this purpose, running docker image would be a great idea:

  1. Install docker and pull ffmpeg docker image
  2. Run docker ffmpeg image with necessary arguments

For Installing docker, run following commands:

  1. remove older version of docker if installed

    sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

  2. install docker yum repository

    sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

  3. install docker and start/enable docker service

    sudo yum install docker-ce docker-ce-cli containerd.io
    sudo systemctl start docker
    sudo systemctl enable docker

Reference: https://docs.docker.com/engine/install/centos/

  1. To run ffmpeg for FB live, run following command:

    docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg -re -y -i [VIDEO_FILE] -c:a copy -ac 1 -ar 44100 -b:a 96k -vcodec libx264 -pix_fmt yuv420p -tune zerolatency -f flv -maxrate 2000k -preset veryfast "rtmps://live-api-s.facebook.com:443/rtmp/[KEY]"

replace [VIDEO_FILE] with the file you want to stream live to fb and [KEY] with the stream key from facebook. Reference: https://hub.docker.com/r/jrottenberg/ffmpeg/

Please note that you need to visit facebook live page ( https://www.facebook.com/live/producer/ ) before you can run the above command.

Thanks Mate for your answer. even you are late anyway i did something similar.

I have already figured it by using DOCKER. using Restreamer: https://datarhei.github.io/restreamer/ It work on both centos & Ubuntu

Aslo i tried it manually it was very difficult to install and setup but i did that and will not recommended.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM