Changes between Version 5 and Version 6 of EncodingForStreamingSites
- Timestamp:
- Jan 26, 2017, 6:35:17 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
EncodingForStreamingSites
v5 v6 34 34 Use a 2 second GOP (Group of Pictures), so simply multiply your output frame rate * 2. For example, if your input is `-framerate 30`, then use `-g 60`. 35 35 36 == MP3 or AAC ==37 38 If you compiled `ffmpeg` with support for `libfdk_aac`, then you can use that for your audio. If not, then use `-acodec libmp3lame -ar 44100` as shown in many of these examples. MP3 in FLV is limited to specific audio rates, but you can omit `-ar` if you are encoding to AAC. See the [[AACEncodingGuide|FFmpeg and AAC Encoding Guide]] for more information.39 40 36 ---- 41 37 … … 48 44 {{{ 49 45 $ ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -framerate 30 -video_size 1280x720 \ 50 -i :0.0+0,0 - vcodeclibx264 -preset veryfast -maxrate 1984k -bufsize 3968k \46 -i :0.0+0,0 -c:v libx264 -preset veryfast -maxrate 1984k -bufsize 3968k \ 51 47 -vf "format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100 \ 52 48 -f flv rtmp://live.twitch.tv/app/<stream key> … … 59 55 {{{ 60 56 $ ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -framerate 30 -video_size 1680x1050 \ 61 -i :0.0+0,0 - vcodeclibx264 -preset veryfast -maxrate 3000k -bufsize 3000k \57 -i :0.0+0,0 -c:v libx264 -preset veryfast -maxrate 3000k -bufsize 3000k \ 62 58 -vf "scale=1280:-1,format=yuv420p" -g 60 -c:a aac -b:a 128k -ar 44100 \ 63 59 -f flv rtmp://live.twitch.tv/app/<stream key> … … 77 73 [1:v]scale=120:-1,setpts=PTS-STARTPTS[fg]; \ 78 74 [bg][fg]overlay=W-w-10:10,format=yuv420p[out]" 79 -map "[out]" -map 2:a - vcodeclibx264 -preset veryfast \75 -map "[out]" -map 2:a -c:v libx264 -preset veryfast \ 80 76 -maxrate 3000k -bufsize 4000k -c:a aac -b:a 160k -ar 44100 \ 81 77 -f flv rtmp://live.twitch.tv/app/<stream key> … … 98 94 [bg][fg]overlay=W-w-10:10[bg2]; \ 99 95 [bg2][3:v]overlay=W-w-10:H-h-10,format=yuv420p[out]" 100 -map "[out]" -map 2:a - vcodeclibx264 -preset veryfast \96 -map "[out]" -map 2:a -c:v libx264 -preset veryfast \ 101 97 -maxrate 3000k -bufsize 4000k -c:a aac -b:a 160k -ar 44100 -b:a 128k \ 102 98 -f flv rtmp://live.twitch.tv/app/<stream key> … … 108 104 109 105 {{{ 110 $ ffmpeg -re -i input.mkv - vcodeclibx264 -preset veryfast -maxrate 3000k \106 $ ffmpeg -re -i input.mkv -c:v libx264 -preset veryfast -maxrate 3000k \ 111 107 -bufsize 6000k -pix_fmt yuv420p -g 50 -c:a aac -b:a 160k -ac 2 \ 112 108 -ar 44100 -f flv rtmp://live.twitch.tv/app/<stream key> … … 118 114 119 115 {{{ 120 $ ffmpeg -i input.mkv - vcodeclibx264 -preset medium -maxrate 3000k -bufsize 6000k \121 -vf "scale=1280:-1,format=yuv420p" -g 50 - acodec libmp3lame-b:a 128k -ac 2 -ar 44100 file.flv116 $ ffmpeg -i input.mkv -c:v libx264 -preset medium -maxrate 3000k -bufsize 6000k \ 117 -vf "scale=1280:-1,format=yuv420p" -g 50 -c:a aac -b:a 128k -ac 2 -ar 44100 file.flv 122 118 }}} 123 119 124 120 Then [http://ffmpeg.org/ffmpeg.html#Stream-copy stream copy] it to the streaming service: 125 121 {{{ 126 $ ffmpeg -re -i file.flv -codec copy -f flv rtmp://live.twitch.tv/app/<stream key> 122 $ ffmpeg -re -i file.flv -c copy -f flv rtmp://live.twitch.tv/app/<stream key> 123 }}} 124 125 === Outputting to multiple streaming services & local file === 126 127 You can use the [https://ffmpeg.org/ffmpeg-formats.html#tee-1 tee muxer] to efficiently stream to multiple sites and save a local copy if desired. Using tee will allow you to encode only once and send the same data to multiple outputs. Using the `onfail` option will allow the other streams to continue if one fails. 128 129 {{{ 130 $ ffmpeg -i input -map 0 -c:v libx264 -c:a aac -muxrate 1000k -bufsize 2000k -g 50 -f tee \ 131 "[f=flv:onfail=ignore]rtmp://facebook|[f=flv:onfail=ignore]rtmp://youtube|local_file.mkv" 127 132 }}} 128 133 … … 131 136 == Notes == 132 137 133 * Youcan use `xwininfo | grep geometry` to select the target window and get placement coordinates. For example, an output of `-geometry 800x600+284+175` would result in using `-video_size 800x600 -i :0.0+284,175`. You can also use it to automatically enter the input screen size: `-video_size $(xwininfo -root | awk '/-geo/{print $2}')`.138 * Linux users can use `xwininfo | grep geometry` to select the target window and get placement coordinates. For example, an output of `-geometry 800x600+284+175` would result in using `-video_size 800x600 -i :0.0+284,175`. You can also use it to automatically enter the input screen size: `-video_size $(xwininfo -root | awk '/-geo/{print $2}')`. 134 139 135 140 * The [http://ffmpeg.org/ffmpeg-devices.html#pulse-1 pulse input device] (requires `--enable-libpulse`) can be an alternative to the [http://ffmpeg.org/ffmpeg-devices.html#alsa-1 ALSA input device], as in: `-f pulse -i default`.
