Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to live stream on facebook via ffmpeg?

I am trying live streaming on facebook via ffmpeg but I get one error. As the error, I must use AAC instead of mp3. But I don't know how to do it.

Error: Bad audio codec 2 (MP3). Accepted audio codecs: AAC

Normally, I can run command below for youtube succesfully.

ffmpeg -i "rtmp://..." -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -r 30 -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv "rtmp://a.rtmp.youtube.com/live2/key"

But when I run command below with facebook rtmp, error gets.

ffmpeg -i "rtmp://..." -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -r 30 -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv "rtmp://rtmp-api.facebook.com:80/rtmp/key"

I am user of Ubuntu 14.04.

Thanks in advance.

like image 755
K. Talha Avatar asked Aug 17 '16 10:08

K. Talha


People also ask

How do I get RTMP live on Facebook?

There are three primary steps to setting up and using Custom RTMP with Facebook (use the links below to jump to that section of the article): Create the video event on Facebook and copy the RTMP values. Add the RTMP values to the Switcher Studio Dashboard. Initiate the Facebook livestream in Switcher Studio.


1 Answers

In your ffmpeg command, you have this:

-acodec libmp3lame

This is encoding the audio stream into MP3. You'll need to change that. You might need to use something like this:

-acodec libfdk_aac

https://trac.ffmpeg.org/wiki/Encode/AAC

To reference Facebook's "Live Video Specs" from https://www.facebook.com/facebookmedia/get-started/live:

The Live API accepts H264 encoded video and AAC encoded audio only.

like image 154
Zs File Avatar answered Sep 20 '22 07:09

Zs File