Changes between Version 1 and Version 2 of Encode/YouTube


Ignore:
Timestamp:
Dec 8, 2012, 6:15:18 AM (5 years ago)
Author:
llogan
Comment:

add content

Legend:

Unmodified
Added
Removed
Modified
  • Encode/YouTube

    v1 v2  
    11= How to Encode Videos for !YouTube and other Video Sharing Sites = 
    22 
    3 This is a reminder for llogan to finish this stub. 
     3Since !YouTube, Vimeo, and other similar sites will re-encode anything you give it the best practice is to provide the highest quality video that is practical for you to upload. Uploading the original content is the first recommendation, but this is not always a choice due to file size or bandwidth limitations, so re-encoding may be required. This guide will show you how to create a high quality video using `ffmpeg`. 
     4 
     5First read the [[x264EncodingGuide|FFmpeg and x264 Encoding Guide]]; specifically the section on CRF. The examples below use the same method as shown in the encoding guide but optimized for !YouTube. 
     6 
     7== Basic Examples == 
     8Re-encode the video and copy the audio. The output should be a similar quality as the input and will hopefully be a more manageable size. 
     9{{{ 
     10ffmpeg -i input -c:v libx264 -preset slow -crf 18 -c:a copy output.mkv 
     11}}} 
     12 
     13Same as above, but also re-encode the audio instead of copying it: 
     14{{{ 
     15ffmpeg -i input -c:v libx264 -preset slow -crf 18 -c:a libvorbis -q:a 5 output.mkv 
     16}}} 
     17 
     18Create a video with a still image (`input.png`) and an audio file (`audio.ogg`): 
     19{{{ 
     20ffmpeg -loop 1 -r 2 -i input.png -i audio.ogg -c:v libx264 -preset medium -tune stillimage -crf 18 -c:a copy -shortest output.mkv 
     21}}} 
     22 
     23== Examples with `drawtext` == 
     24Create a video with a colored background using the [[http://ffmpeg.org/ffmpeg.html#color_002c-nullsrc_002c-rgbtestsrc_002c-smptebars_002c-testsrc|color]] video source and add text with the [[http://ffmpeg.org/ffmpeg.html#drawtext-1|drawtext]] filter showing song title: 
     25{{{ 
     26ffmpeg -f lavfi -i color=c=orange:s=1280x720:r=2 -i audio.ogg -c:v libx264 \ 
     27-preset medium -tune stillimage -crf 18 -vf "drawtext=fontfile=Vera.ttf: \ 
     28text='Song Title'" -c:a copy -shortest output.mkv 
     29}}} 
     30 
     31  '''Note:''' `fontfile` requires the full path to the font file, such as `/usr/share/fonts/TTF/Vera.ttf`. 
     32 
     33Same as above, but embiggen the text, color it yellow, and put it in a blue box with 80% opacity, and center it: 
     34{{{ 
     35ffmpeg -f lavfi -i color=c=orange:s=1280x720:r=2 -i audio.wav -c:v libx264 \ 
     36-preset medium -tune stillimage -crf 18 -vf "drawtext=fontfile=Vera.ttf: \ 
     37fontsize=48: fontcolor=yellow@0.8: box=1: boxcolor=blue@0.8: text='Song Title': \ 
     38x=(w-text_w)/2: y=(h-text_h)/2" -c:a copy -shortest output.mkv 
     39}}} 
     40 
     41Position the text on the bottom right: 
     42{{{ 
     43ffmpeg -f lavfi -i color=c=orange:s=1280x720:r=2 -i audio.wav -c:v libx264 \ 
     44-preset medium -tune stillimage -crf 18 -vf "drawtext=fontfile=Vera.ttf: \ 
     45text='Song Title': x=w-text_w-line_h: y=h-text_h-line_h" -c:a copy -shortest output.mkv 
     46}}} 
     47 
     48Same as above, and use another `drawtext` to add author name: 
     49{{{ 
     50ffmpeg -f lavfi -i color=c=orange:s=1280x720:r=2 -i audio.wav -c:v libx264 \ 
     51-preset medium -tune stillimage -crf 18 -vf "drawtext=fontfile=Vera.ttf: \ 
     52text='Song Title': x=w-text_w-ascent: y=h-text_h-(line_h*2),drawtext=fontfile=Vera.ttf: \ 
     53text='Artist Name': x=w-text_w-ascent: y=h-text_h-line_h" -c:a copy -shortest output.mkv 
     54}}} 
     55 
     56Use the [[http://ffmpeg.org/ffmpeg.html#mandelbrot|mandelbrot]] filter instead of a boring colored background: 
     57{{{ 
     58ffmpeg -f lavfi -i mandelbrot=s=1280x720:r=ntsc -i audio.mp3 -c:v libx264 \ 
     59-preset medium -crf 18 -vf "drawtext=fontfile=Vera.ttf:text='Song Title'" \ 
     60-c:a copy -shortest output.mkv 
     61}}} 
     62 
     63Other interesting video sources to try include `cellauto`, `mptestsrc`, and `life`. See [[FancyFilteringExamples|Fancy Filtering Examples]]. 
     64 
     65== FAQ == 
     66 
     67=== Encoding is too slow. What should I do? === 
     68Use a faster `-preset` value. See the [[x264EncodingGuide|FFmpeg and x264 Encoding Guide]] for more information. 
     69 
     70=== My video colors are messed up in my computer's media player. Now what? === 
     71Try adding `-pix_fmt yuv420p` as an output option although !YouTube will probably re-encode the video properly without this option.