Thursday, September 11, 2014

VP9 + Opus = WebM: How to Upload THE BEST QUALITY YouTube Videos with the SMALLEST FILES!

I try to keep myself up-to-date with the latest video codecs (such as ARRI's new 3.2K ProRes) and containers. And it is time again for some new codecs and containers to take the field. With HTML5 large and in charge, online video will quickly become a bottleneck issue...


H.264
The H.264 codec has been, and still is, a huge staple for video compression. Whether it be for video cameras or a Blu-ray disc, H.264 provides great compression with great quality. There have been licensing issues that have sprung up, but moreorless, H.264 has become the standard for video compression everywhere.

The New Standards
As with DVD to Blu-ray, H.264 could only last so long as demands for better compression that sustain high quality video will and are needed. One of the most obvious reasons for this is online video. While web hosting can be purchased at inexpensive rates, adding more storage can be extremely costly. And if you are constantly loading up videos, even H.264 won't be able to help that budget. YouTube is a great alternative, but some may want to host their own video files.

HTML5
HTML5 is meant to have already been standardized this year [July], and it is now widely accepted across browser platforms. Even sites like YouTube have "experimental" HTML5 video interfaces. The one thing HTML5 needed though was faster video to go along with it...

H.265 vs. VP9
The new codecs that are coming to the aid of video compression are H.265 and VP9. Both are meant to drastically reduce compression size while still maintaining high quality. They are still in their infancy stages, but are already a forced to be reckoned with.

H.265 is said to be better - in quality - than VP9. It is the obvious successor of H.265, and from what test stills I have seen, it looks amazing! Compression rates can supposedly reach 1/4th the size of H.264. The H.265 stills I previewed were nearly impossible to tell from the H.264 stills. I could only recall one still that seemed slightly worse than the H.264 still. That being said, many are worried that H.265 will have the same licensing issues that plagued H.264, but there is talk of it being free, however unlikely that may be.

VP9 is from Google and is free. I have done a few tests and it is just as amazing as H.265, in my opinion. I have had varied results in comparing compression size of VP9 videos over uncompressed videos I have outputted (such as a short intro at .5% or a full-length video at 12.5%), but they have always come out just as perfect as the uncompressed video itself.

NOTE: I am not mentioning Daala as I have do not have a way of testing this, and I don't believe the codec is widely support yet.


Great! So, where can I put this?
If you have your own website and hosting, you could use an HTML5 video player for VP9, as many of the latest browsers are able to decode it. The same should go for H.265. For those of you using free websites, or even those with paid hosting but little storage is available, YouTube has you covered if you go the VP9 route!

Can you contain me? Can you hear me?
VP9 is just a video codec, what about the container and audio codec? What will YouTube accept?

WebM is a container that will happily accept VP9. It is supported for HTML5. As far as audio, Opus seems to work with VP9 in my tests, and is of excellent quality (if that is a worry). It too is supported by HTML5, and both are supported by YouTube (I did not find Opus officially mentioned on their site, however). There, the secret's half-way out!

Why Should I Use This?
I had a couple reasons to use this that may or may not apply to you. My first was to simply get used to dealing with VP9. It's the future, and I intend to be ready for it. Another reason was that I had an old green screen video that would always look horrendous when uploaded to YouTube. I am hopeful that this method will fix this.

And maybe most importantly, I currently reside in a part of the world where Internet is slow and still costly. I can spend less time by encoding to VP9 and then uploading to a cloud service or YouTube, rather than trying to upload an uncompressed or high-quality H.264 MP4 video.

A final reason, that I'll go into detail below, is that it seems that less compression is had when using VP9 in YouTube. Of course VP9 is a form of compression, but the quality is so incredibly high for such a low file size that it is impossible for even me to see the difference between an uncompressed and VP9 video - when done right.

How to Convert Your Video to WebM (VP9 + Opus) for FREE!
This technique will show you how to quickly and easily convert your video to WebM using the VP9 and Opus codecs. While you can change the settings, doing so may cause issues in playback, and could greatly increase your time for processing.

Here are the steps:
  1. Output your video in whatever format you desire, but uncompressed may be best if possible.
  2. Download Hybrid, which is free.
  3. Install Hybrid, you can leave the install settings as-is.
  4. Open Hybrid.
  5. From the Main tab, choose "VP8/P9" for "Video handling" (the H.265 tab should change to VP8/9).
  6. Ignore this step if you do not have audio. Choose "custom" for "Audio handling". (An Audio tab should now appear.)
  7. In the upper-right, click the man walking out the door with a right arrow icon.
  8. Select your video.
  9. In the middle-right, click the man walking in the door with a left arrow icon.
  10. Select your folder and put in a file name with the extension ".webm".
  11. Click the VP8/9 tab.
  12. Choose "VP9" for "Codec".
  13. Choose "good" for "Basic speed control".
  14. Set "CPU utilization modifier" to the number of cores your CPU has. For example, 6-cores equates to a 5, while a single core equates to 0.
  15. You can leave "Encoding mode" as-is, but I recommend changing the bitrate to at least 6,000kbps (10,000kbps optimal), especially if the video has any titles or credits.
  16. Click the Audio tab. (Skip to step #20 if you have a silent video.)
  17. Check off "Reencode".
  18. Choose "opus" for "Audio format". (You can mess with other audio quality settings, but it is unnecessary, and may not work.)
  19. There are two "+" icons, click the one on the far right with up and down arrow icons below it.
  20. Click the Config tab.
  21. Clikc the Internals tab from the second row of tabs.
  22. Check off "Always use Avisynth".
  23. Click the Filtering tab.
  24. Click the Avisynth tab from the second row of tabs.
  25. Click the Misc tab from the third row of tabs.
  26. Check off "LibavVideoSource instead of FFmpegsource".
  27. Click the Jobs tab (only necessary if you have done this process before, otherwise skip to step #23).
  28. Highlight all "jobs" already in the queue.
  29. Right-click.
  30. Select "remove".
  31. Click the Main tab.
  32. Click the man shoveling with a small box containing a "+" icon.
Note: If for some reason your video outputs upside-down, go to Config > Input and check off "Flip raw rgb" under Decoding. This should only occur if you have a video that was made in a raw RGB format.

Give It Time!
My 2:56 minutes music video took less than an hour with the above settings. This will obviously extend the longer your source video is.

Playback?
I found that many video players would not play the file correctly. I normally use VLC, and the current 2.1.5 version already supports VP9, but for some reason will not play these files. I have been told that the new nightly builds will. However, MPC-HC plays the files just fine.

But That's All the Drawbacks, Right?
Well, that really depends on your settings. If you follow the settings above, then yes. But if you begin changing them, you could incur other drawbacks.

If someone were to choose "Best" instead of "good" for "Basic speed control", a short 3-minute video would take a few days to process! Or if someone were to choose 0 for "CPU utilization modifier", then it could take a lot longer to process since only a single core would be in use. And if someone were to leave "LibavVideoSource instead of FFmpegsource" unchecked, their video could come out with a stuttering effect.

Premiere Pro Users
If you are a Premiere Pro user, there is an option available to you to compress your video to WebM as VP9 in-program. Here is the free plug-in for that. Here is a free plug-in, from the same person, for Theora; if you have any use for it. Place these in the "Plug-ins" folder of where your Adobe Premiere Pro folder is. If you still don't know what to do, there are plenty of articles on the web explaining how to place Premiere Pro plug-ins.

The reason I am not going into detail on how to use Premiere Pro for VP9 is that I successfully attempted this and was able to get it going easily. But after 4 days, it seemed the progress bar got stuck, and soon after, I had a power outage and lost all the progress. It seems the maker of the plug-in admits there are still issues, and I did find at least one post about the same problem I encountered.

You are able to use two cores if you follow the plug-in maker's instructions, but this is for best quality and will slow down the process further!

Examples
I have made three examples from the music video I tested this with. All three are in 1080p and uploaded to YouTube:

Uncompressed (16GB+) - On My Mind
H.264 (3.5GB+) - On My Mind
VP9 (123MB) - On My Mind

YouTube MP4 Download Size
Uncompressed - 76MB+
H.264 - 75MB+
VP9 - ≈79MB

I have a slow Internet speed, and am constantly using up my bandwidth, so each upload was a long wait for me. But for those with speeds triple 3-4Mbps, it should be a breeze.

YouTube Compression Percentages
You'll notice, if trying to download these videos as MP4, that the uncompressed, H.264, and VP9 videos are all practically the same size after YouTube compression.

Some simple math tells us that the VP9 video is about 3.5% of the entire size of the H.264 video. One might incorrectly think that the YouTube compression size should then be equally proportionate, but it isn't. The VP9 MP4 size is actually about 105% of the H.264 (and uncompressed) MP4 video. If we compare the MP4 sizes to their original counterparts we get almost .5% for uncompressed, around 2.14% for H.264, and 64.23% for VP9. This is a good thing as we want as little compression done by YouTube as possible in order to maintain high quality.

Music Video
The footage was all shot on a Panasonic Lumix GH2 hacked to use MJPEG (.MOV @ 30fps) at 80-100Mbps, utilizing mostly Canon FD lenses. I used Premiere Pro to edit and Da Vinci Resolve Lite to color grade. I did add a few effects in Premiere Pro as well.

This was the first day of using my GH2, and I was rushing to learn how to use and hack it. I should've been able to achieve the same bitrates with AVCHD, but something wasn't right. I couldn't experiment more as I was losing sun. We shot our guerrilla-styled music video in about 2-3 hours.

Thumbnail Tidbit
One last odd thing I noticed from YouTube was despite being the exact same music video, the VP9 version had different thumbnail choices than the other two. Why? I don't know...

Conclusion
VP9 quality is superb, and the compression is as amazing as it is made out to be. Once VP9 has gone through its trials and gains more support, I am sure it will be one of the best codecs for uploading, sending, or displaying video.

1 comment:

  1. Opus is the best file size when it comes to Audio File Compression there are many free online tools to convert to this format like https://davidclews.com/article/95.html which will allow you to extract the audio stream from a video file.

    ReplyDelete