Changes between Version 1 and Version 2 of Encode/YouTube

Dec 8, 2012, 6:15:18 AM (5 years ago)

add content


  • Encode/YouTube

    v1 v2  
    11= How to Encode Videos for !YouTube and other Video Sharing Sites = 
    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`. 
     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. 
     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. 
     10ffmpeg -i input -c:v libx264 -preset slow -crf 18 -c:a copy output.mkv 
     13Same as above, but also re-encode the audio instead of copying it: 
     15ffmpeg -i input -c:v libx264 -preset slow -crf 18 -c:a libvorbis -q:a 5 output.mkv 
     18Create a video with a still image (`input.png`) and an audio file (`audio.ogg`): 
     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 
     23== Examples with `drawtext` == 
     24Create a video with a colored background using the [[|color]] video source and add text with the [[|drawtext]] filter showing song title: 
     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 
     31  '''Note:''' `fontfile` requires the full path to the font file, such as `/usr/share/fonts/TTF/Vera.ttf`. 
     33Same as above, but embiggen the text, color it yellow, and put it in a blue box with 80% opacity, and center it: 
     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 
     41Position the text on the bottom right: 
     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 
     48Same as above, and use another `drawtext` to add author name: 
     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 
     56Use the [[|mandelbrot]] filter instead of a boring colored background: 
     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 
     63Other interesting video sources to try include `cellauto`, `mptestsrc`, and `life`. See [[FancyFilteringExamples|Fancy Filtering Examples]]. 
     65== FAQ == 
     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. 
     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.