Search code examples
audioffmpegcommandrtsprtmp

Send RTSP + Audio to RTMP server with ffmpeg


I successfully sent an rtsp video stream to rtmp server (facebook) but have not been able to use audio using ffmpeg.

If I play RTSP from camera locally audio works fine.

This is the command I use (ubuntu server 16.0.4 LTS - ffmpeg 2.8.11):

sudo ffmpeg -f lavfi -i anullsrc -rtsp_transport tcp -i "rtsp://admin:admin@192.168.1.2/mode=real&idc=1&ids=1" -tune zerolatency -vcodec libx264 -g 60 -keyint_min 60 -r 30 -pix_fmt + -b:v 4000k -acodec copy -ar 44100 -b:a 128k -strict experimental -f flv  "rtmp://live-api.facebook.com:80/rtmp/STREAM-KEY"

Here the full log: https://www.dropbox.com/s/vo05n0kehs75iba/ffmpeg-20180207-100549.log?dl=0


Solution

  • -acodec copy -ar 44100 -b:a 128k -strict experimental is mutually exclusive. You are asking ffmpeg to copy and mux the audio format from source but at the same time you are attempting to encode it. It should be either -acodec copy to copy without transcoding or -acodec {codec} {additional audio params} to transcode.

    Facebook accepts only H.264 + AAC combination, see Live Video Specs at https://www.facebook.com/facebookmedia/get-started/live while you are actually copying audio format from anullsrc which is PCM. You should transcode to AAC with -acodec aac -ar 44100 -b:a 128k -strict experimental