YouTube, 4K and H.265 uploads

UPDATE July 15, 2017: I have tried two H.265/HEVC uploads today and it is working now 🎉

This is going to be a very technical post, so bear with me for a couple of minutes because this information could help you make up your mind on which resolution, compression and quality to use when you upload a video to YouTube.

I want to share some videos online using YouTube, but I wasn’t sure which quality to use, 1080p or 4K, if you look up for the advice of the best YouTubers out there, the consensus is to go for the best quality, 4k… they argue that publishing 4K video could make your content last longer, but the YouTubers who are thriving are using just HD most of the time.

So I decided to try a 4K workflow first, I recorded some footage on the Xpo Comicon Guatemala 2016 in 4K using the DJI Osmo, then I had to choose which video editing software to use, Marques Brownlee and Casey Neistat use and recommend Final Cut Pro X because it is fast and easy to use, and indeed, it is extremely fast and this is because FCPX is always rendering all the video in background, so when it is time to export the video, the video is already rendered, the export time is only encoding time.

Final Cut Pro X is fast, easy to use, but I find quite difficult to copy some effects from one clip to other or the same color correction, also, the precision I can achieve on Adobe Premiere Pro when selecting some clip area isn’t something I can found in FCPX, so I used Premiere and when was time to export I used the “DNxHR HQ UHD” codec/format, the reason behind this decision was made knowing that the Adobe H.264 encoder is painfully slow and the quality is poor, plus, I know exactly how to encode a video with higher quality and low bandwidth which can be uploaded faster to YouTube, and exporting to DNxHR is extremely fast.

Using the command prompt (or Terminal if you are on OS X or Linux) I encoded the DNxHR 4K video to MP4/H.264/AAC using FFmpeg. Even using the great compression that can be achieved using FFmpeg/X264 the output file was huge, 2GiB, the video upload to YouTube using my poor 1Mbps internet connection took almost 5 hours, something unacceptable if you want to publish videos on a daily basis, here is the final result in YouTube:

https://youtu.be/KBI25aC9Kzc

After publishing the video I decided to check which could be the difference if I used 1080p video quality, and the results where astonishing, ¼ the original 4K video file size… and what if I used H.265 instead?

So here comes technical information, using again a 4K video captured with the DJI Osmo I ran some tests using only 1 minutes of video, here is the source file information:

Name...............: 01-Osmo_4K_source.mp4
Size...............: 429 MiB
Duration...........: 00:01:00.027
Resolution.........: 3840x2160
Codec..............: AVC High@L5.1
Chroma subsampling.: 4:2:0
Bit depth..........: 8
Bitrate............: 60.0 Mbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: English 64.0 Kbps CBR 2 chnls AAC LC 48000

Using Premiere I exported the video to DNxHR HQ UHD which takes 6.14GB of storage for just one minute of video, 876Mbps:

Using Premiere I exported the video to DNxHR HQ UHD which takes 6.14GB of storage for just one minute of video, 876Mbps:

Name...............: A01–4k_from_premiere.mxf
Size...............: 6.14 GiB
Duration...........: 00:01:00.060
Resolution.........: 3840x2160
Codec..............:
Chroma subsampling.: 4:2:2
Bit depth..........: 8
Bitrate............: 876 Mbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: 1 536 Kbps CBR 2 chnls PCM 48000

Crazy right, next using the following FFmpeg command, I encoded the DNxHR HQ UHD file to a simple and mundane MP4/H.264/AAC video:

ffmpeg \
-y \
-hide_banner \
-i A01–4k_from_premiere.mxf \
-pix_fmt yuv420p \
-vf "hqdn3d=1.5:1.5:6:6" \
-c:v libx264 \
-preset fast \
-crf 22 \
-x264opts "keyint=30:scenecut=-1" \
-c:a libfdk_aac \
-b:a 128k \
-ac 2 \
-ar 44100 \
-ac 2 \
-movflags +faststart \
A02-4K_H.264_from_ffmpeg.mp4

This command uses a constant rate factor of 22 which compress the video prioritizing the quality, the command also applies some noise reduction to the video, set a fixed GOP (group of pictures or keyframes) to make the video easily seekable, and use the “fast start” flag to make easy for YouTube to process the video when uploading, here is the frame analysis:

You can see that the file has a 54Mbps bitrate and uses 400MiB of storage, what if I used H265, here is the command I used with FFmpeg:

ffmpeg \
-y \
-hide_banner \
-i "A01-4k_from_premiere.mxf" \
-pix_fmt yuv420p \
-vf "hqdn3d=1.5:1.5:6:6" \
-c:v libx265 \
-preset medium \
-x265-params "crf=28:keyint=30:min-keyint=30" \
-ar 48000 \
-ac 2 \
-c:a libfdk_aac \
-profile:a aac_he_v2 \
-b:a 64k \
-movflags +faststart \
"A03-4K_H.265_from_ffmpeg.mp4"

Again, I used a noise reduction filter, a fixed GOP and a faststart flag, but X.264 and HE-AAC v2 for audio encoding, here is the file info and frame analysis:

Name...............: A03–4K_H.265_from_ffmpeg.mp4
Size...............: 78.4 MiB
Duration...........: 00:01:00.209
Resolution.........: 3840x2160
Codec..............: HEVC Main@L5@Main
Chroma subsampling.: 4:2:0
Bit depth..........: 8
Bitrate............: 10.9 Mbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: 64.0 Kbps CBR 2 / 1 / 1 chnls AAC LC-SBR-PS 48000 / 48000 / 24000

As you can see, the file uses only 10.72Mbps and it takes only 78MiB of storage, quite impressive, sadly YouTube at this moment doesn’t support H.265/HE-AAC uploads, but just imagine, a one minute of H.264 4K video takes 56 minutes be uploaded to YouTube having an internet connection that only supports 1Mbps of upstream, if YouTube supported H.265 it could take only 11 minutes, 5x faster uploads.

But what if I used 1080p videos instead? How much that decision could affect my upload time? Using the same source but exporting from Premiere to DNX HQ 1080p took only seconds to export, here is the output info:

Name...............: B01–1080p_from_premiere.mxf
Size...............: 1.58 GiB
Duration...........: 00:01:00.060
Resolution.........: 1920x1080
Codec..............: 
Chroma subsampling.: 4:2:2
Bit depth..........: 8
Bitrate............: 220 Mbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: 1 536 Kbps CBR 2 chnls PCM 48000

Using a 1080p video instad of a 4K video reduces the storage to just ÂĽ of the original file, something expected because 4K is 4X the amount of pixels of an HD 1080p video, so encoding the video to H.264 using the exact FFmpeg command that I used for the 4K video give me the following results:

Name...............: B02–1080p_H.264_from_ffmpeg.mp4
Size...............: 105 MiB
Duration...........: 00:01:00.107
Resolution.........: 1920x1080
Codec..............: AVC High@L4
Chroma subsampling.: 4:2:0
Bit depth..........: 8
Bitrate............: 14.5 Mbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: 128 Kbps CBR 2 chnls AAC LC 44100

Again, ÂĽ of the amount of data required for a 4K video, it would require just 15 minutes to be uploaded to YouTube, But what if YouTube accepted H.265 file uploads? Again, using the same FFmpeg command I used before to encode H.265 I got the following results:

Name...............: B03–1080p_H.265_from_ffmpeg.mp4
Size...............: 21.2 MiB
Duration...........: 00:01:00.209
Resolution.........: 1920x1080
Codec..............: HEVC Main@L4@Main
Chroma subsampling.: 4:2:0
Bit depth..........: 8
Bitrate............: 2 884 Kbps
Framerate..........: 29.970 fps
Aspect Ratio.......: 16:9
Audio..............: 64.0 Kbps CBR 2 / 1 / 1 chnls AAC LC-SBR-PS 48000 / 48000 / 24000

A 21.2MiB file, that’s right, just 22.2MiB for 1 minute of HD 1080p video, it could be uploaded in just 3 minutes to YouTube, imagine that.

tl;dr — conclusions

While 4K brings greater quality to your audience, capturing, archiving, storing, editing, exporting, encoding and uploading 4K video requires immense amounts of time, storage, bandwidth and patience, is it worth it? well, How much people have a 4K display and high bandwidth to watch your videos?

YouTube needs to adopt H.265 as soon as posible, they are encouraging people to become content creators, but not everyone has a super fast internet connection, using H.265 for video uploads can give creators lots of extra time for creating instead of waiting for the content to be uploaded.

Extra information

Video frame information made using plotframes.
Bandwidth time calculations made using BandwidthCalc.
Source code free and available for both projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

Releated

BT.2020 instead of Cinema Gamut? A fix for the EOS R5

As I shown on a previous article, the EOS R5 and R6 are unable to output C-Log 3 with Cinema Gamut through HDMI, even after setting Cinema Gamut as color space on the camera, HDMI will always output Rec/BT.2020. This presents a challenge when using custom LUTs while using the Atomos Ninja V, for instance, […]

No Cinema Gamut trough HDMI

May 3, 2024 Update: It appears that this is a Canon made limitation, some users have reported that the C70 is able to output C-Log 3 with Cinema Gamut trhough HDMI. The EOS cameras that have Cinema Gamut as a Color Space option, cannot output Cinema Gamut trough HDMI, I have covered this issue several […]