SA LP Tech Support Fort Wiki
Advertisement

As you certainly know, Youtube is an incredibly popular video host. However, Youtube has the tendency to lower the quality of your uploaded videos drastically, even if the source video is perfectly fine.

The Short Version[]

  • Resize your footage to even integer multiples with PointResize / Nearest Neighbor to get a resolution equal to or higher than 720 vertical or 1280 horizontal. If you want the absolute best quality you can also vertically pad non-standard resolution videos (such as emulator footage from many old consoles) to resolutions or multiples that Youtube supports.
  • Change your video's framerate to 30 FPS by dropping frames if you're not going HD. Youtube doesn't support higher framerates if your video's resolution is less than 720p and can do weird stuff with them. If you're playing an old 8/16 bit game, take a look at the 60 FPS Sprite Flickering section below.
  • And as always, encode to H.264 and AAC.

The higher video quality on Youtube is triggered exclusively by video resolution. For some bizarre reason, Youtube hates SD footage and destroys it on sight. Upload your videos in HD, and they will look fine.

If your video is already captured in HD, great, just encode like you always would and upload that. If not, we have to do some upscaling. Read on and look at some examples of how to properly upscale low resolution videos, and what happens if you don't.

The Exact Resolution[]

Experimentation suggests that the trigger for the HD encoding quality is having either 720 vertical pixels or 1280 horizontal pixels. 718 vertical or 1278 horizontal pixels do not trigger HD.

Test Case: 640 x 480[]

So how bad is Youtube's non-HD encoding, really? Let's find out:

 	Youtube_Encoding_Quality_640_x_480,_not_resized 	 			    	Youtube_Encoding_Quality_640_x_480,_Spline36Resize_to_960_x_720_(1.5x) 	 			    	Youtube_Encoding_Quality_640_x_480,_PointResize_to_1280_x_960_(2x) 	 			  

Here we have the exact same footage three times. The source video is 640 x 480, a typical SD resolution. The first video was left alone and uploaded just like that, the second was upscaled to 720p using Spline36Resize, and the third was upscaled to twice the source resolution with PointResize.

Let's take a look at a single frame from these uploaded Youtube videos:

Unresized 640 x 480 video: Youtube-no-resize

Spline36Resized 960 x 720 video: Youtube-Spline-720

PointResized 1280 x 960 video: Youtube-Point-2x

Source capture before encoding and uploading: Source-video-frame

As you can probably tell immediately, the original unresized video looks like garbage, while the rest looks fine. If you look closer, you can also see that the 2x Point version looks better than the 1.5x Spline one, but it's not as big of a difference there. (look at the red portion of the power indicator between the main game and build menu)

Additionally, although this is less obvious, HD videos get a higher audio bitrate on Youtube. SD gets 96kbps, HD gets 192kbps.

A recent theory suggests that this happens because Youtube no longer actually supports 480p videos and will only encode and provide the 360p version when uploading SD content, even when watching on the "480p" setting. But either way, it looks terrible, so do not upload footage that doesn't trigger the HD content pipeline. 

60 FPS Sprite Flickering[]

Many old 8 and 16 bit games fake transparency by flickering a sprite on and off each frame. Since those games usually run at 60 FPS, uploading a video of that to Youtube, which only supports 30 FPS videos if the resolution is less than 720p, breaks this effect: Either the sprite stays visible, or disappears completely.

As an example, take a look at the Rolling Shield from Mega Man X:

 	1024_x_896,_30Hz_flicker_effect_at_60_FPS,_MP4_Container 	 			  

To deal with this issue, smart people over at TASVideos have made TASBlend:

function TASBlend(clip c, float "ratio")  { 
        # reduces framerate to 1/2 but leaves flicker effects partly visible 
        # blends frame pairs with alternating opacity (default is 2/3+1/3;1/3+2/3) 
        # optional "ratio" is the opacity of the first frame out of the four 
        ratio    = default(ratio, 2.0 / 3) 
        opacity1 = round((1 - ratio) * 257) 
        opacity2 = round((    ratio) * 257) 
        c 
        Interleave(Layer(SelectEvery(4, 0), SelectEvery(4, 1), level=opacity1), 
        \          Layer(SelectEvery(4, 2), SelectEvery(4, 3), level=opacity2)) 
}

It's a special way of frameblending that aims to replicate the flicker effect at the provided 30 FPS. Here's how the previous clip looks with TASBlend applied:

 	1024_x_896,_30Hz_flicker_effect_with_TasBlend 	 			  

It works pretty well, but still has the general issues of frame blending: Moving stuff becomes blurry. So, ideally, you only apply TASBlend to sections of the video that need it.

video = AviSource("path/to/60fps/emulator/footage.avi")
blended = video.TASBlend()
video = video.ChangeFPS( video.framerate / 2 )

# replace video with blended video for each section that needs it
video = video.Replace(1000, 1200, blended)
video = video.Replace(4500, 5000, blended)
# etc.

Odd Resolutions[]

So we've now got pretty good looking SNES footage, but think about the resizing process a bit and you'll realize that Youtube resizes the nice 4x SNES resolution footage to a much more questionable ~3.21x SNES resolution. That doesn't sound right at all!

Youtube only supports very specific resolutions, all other uploads will get "standardized" to the next smallest. That means that to get a crisp encode, we have to provide a video that either already is in these resolutions, or resizes nicely to them. In case of SNES footage, this is fairly easy: Pad the 256 x 224 to 256 x 240 with 8 pixel black bars on the top and bottom. Resizing that to 4x gives us 1024 x 960, which downsizes nicely to exactly 3x at 768 x 720. Compare:

 	1024_x_896,_30Hz_flicker_effect_with_TasBlend 	 			    	1024_x_960,_30Hz_flicker_effect_with_TasBlend 	 			  

It's not a big difference, but if you look closely, the 896 version looks slightly more blurry than the 960 version. At this point we're kinda nitpicking really, but if you really want to get the best quality out of Youtube's encodes, pad non-standard resolution footage with black bars on the top/bottom to get a resolution (or exact multiple) that Youtube supports.

(The reason we're not resizing our SNES footage to 768 x 720 directly has to do with Chroma Subsampling, but admittedly might be wasted effort considering Youtube downsizes it anyway. Still, it's a good idea to provide Youtube with the best quality you can.)

Advertisement