Skip to content

Instantly share code, notes, and snippets.

@JonnoFTW
Last active November 14, 2017 04:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonnoFTW/f24613308d845406a2741bdad9355f2d to your computer and use it in GitHub Desktop.
Save JonnoFTW/f24613308d845406a2741bdad9355f2d to your computer and use it in GitHub Desktop.
Stream to youtube live
#!/bin/sh
VBR="2500k"
FPS="30"
QUAL="ultrafast"
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" #
KEY="supersecret-key"
ffmpeg \
-video_size 1920x1080 -f x11grab -i :0.0+1920,10 -deinterlace \
-f alsa -i default \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -q:v 3 -b:a 712000 -bufsize 512k \
-f alsa "$YOUTUBE_URL/$KEY"
@JonnoFTW
Copy link
Author

$ ./stream_yt.sh 
ffmpeg version N-83701-g70ebc05 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --prefix=/scratch/package/install --pkg-config-flags=--static --extra-cflags='-I/scratch/package/install/include:/scratch/package/install/usr/include' --extra-ldflags='-L/scratch/package/install/lib:/scratch/package/install/usr/lib:/usr/lib' --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      55. 47.100 / 55. 47.100
  libavcodec     57. 81.101 / 57. 81.101
  libavformat    57. 66.102 / 57. 66.102
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
[x11grab @ 0x37cb900] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0+1920,10':
  Duration: N/A, start: 1510634871.481461, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1920x1080, 29.97 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, alsa, from 'default':
  Duration: N/A, start: 1510634871.536741, bitrate: 1536 kb/s
    Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Codec AVOption preset (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0 (rtmp://a.rtmp.youtube.com/live2/...) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Codec AVOption g (set the group of picture (GOP) size) specified for output file #0 (rtmp://a.rtmp.youtube.com/live2/...) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
[alsa @ 0x37f5660] sample format 0x15001 is not supported
Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented
Stream mapping:
  Stream #1:0 -> #0:0 (pcm_s16le (native) -> mp3 (libmp3lame))
    Last message repeated 1 times

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