K. Talha
K. Talha

Reputation: 83

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.

Upvotes: 7

Views: 18530

Answers (2)

mint
mint

Reputation: 355

The encoder 'aac' is experimental but experimental codecs are not enabled, to add acc add '-strict -2'

So replace libmp3lame with aac -strict -2

Upvotes: 0

Zs File
Zs File

Reputation: 21

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.

Upvotes: 2

Related Questions