Using FFMPEG to stream my WebCam's video to YouTube

Indes picture Indes · Nov 13, 2015 · Viewed 24k times · Source

I've been trying to use ffmpeg to stream my webcam's video to YouTube and so far all I've managed was an "acknowledgement" from YouTube saying 'Starting' in green. However it quickly goes gray and the actual stream never actually changes from offline.

I'm using this command to try to stream it:

ffmpeg -rtbufsize 1500M -r 25 -f dshow -s 1280x720 -i video="USB2.0 HD UVC WebCam" -vcodec h264 -b:a 600k -acodec libfaac -ab 128k -f flv "rtmp://a.rtmp.youtube.com/live2/user.useruser.codecodecode"

CMD

I've managed to stream videos to YouTube with ffmpeg, its just the camera that won't work. Any idea what I might be doing wrong?

This is the command I'm using now ffmpeg -r 18 -f dshow -s 1280x720 -i video="USB2.0 HD UVC WebCam":audio="Microphone (Realtek High Definition Audio)" -vcodec h264 -b:v 1800k -acodec aac -strict experimental -f flv "rtmp://a.rtmp.youtube.com/live2/useruser.useruser.codecodecodecode"

I'm now using -acodec aac instead of libfaac or libfdk_aac since I was getting "Unknown encoder" errors

It is streaming a few seconds however, now I'm getting these errors: WriteN, RTMP send error 10053

Any idea what these mean, or how to fix them?

Answer

aergistal picture aergistal · Nov 13, 2015

There are a few things wrong with your command:

  • You don't have an audio stream. When using dshow you also need to specify audio as explained here.

    ffmpeg -f dshow -i video="Integrated Camera":audio="Microphone name here"

    If you don't intend to capture audio then put a silent audio track.

  • -b:a is the same thing as -ab - the audio bitrate. You must use -b:v to specify the video bitrate. 600k is too low for a 1280x720px @ 25fps H.264 video stream.

    YouTube recommends:

    720p

    Video Bitrate Range: 1,500 - 4,000 Kbps

    You should put at least 1800k.

  • Concerning the audio you're using libfaac. For the best results when encoding AAC it's recommended to use libfdk_aac