Skip to content

Instantly share code, notes, and snippets.

@laurenarcher
Created November 21, 2014 14:13
Show Gist options
  • Save laurenarcher/4644aacef51e734d33d5 to your computer and use it in GitHub Desktop.
Save laurenarcher/4644aacef51e734d33d5 to your computer and use it in GitHub Desktop.
Livestreaming to Youtube Live, Ubuntu, Linux FFMPEG
Terminal Commands:
One webcam:
ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -s 1280x720 -r 10 -i /dev/video1 -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -r 25 -g 20 -b:v 2500k -codec:a libmp3lame -ar 44100 -threads 6 -b:a 11025 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/YOURSTREAMNAMEHERE
Two webcam overlay:
ffmpeg -f alsa -ac 2 -i hw:1,0 -f v4l2 -s 1280x720 -r 10 -i /dev/video1 -f v4l2 -s 320x240 -r 10 -i /dev/video0 -filter_complex "[1:v]setpts=PTS-STARTPTS[bg]; [2:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=shortest=1 [out]" -map "[out]" -map 0:a -vcodec libx264 -pix_fmt yuv420p -preset veryfast -r 25 -g 20 -b:v 2500k -codec:a libmp3lame -ar 44100 -threads 6 -b:a 11025 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/YOURSTREAMNAMEHERE
Works as of Nov. 21 2014, with 14.04. As seen here: www.oldhomehandy.com
If you don't have FFMPEG installed use Jon Severinsson's FFmpeg PPA:
sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
@astrojuanlu
Copy link

Now the streams are key protected. Any hint on how to change this?

Copy link

ghost commented Mar 16, 2017

The options used here are incorrect, outdated, or suboptimal. See FFmpeg Wiki: Encoding for Streaming Sites for better examples.

@shrimpwagon
Copy link

Wow! Thank you. This pretty much worked as-is.

I just had to change the following options:

-i hw:0,0 -i /dev/video0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment