115 points · by janandonly · 5y ago · 119 comments
Also H.264 and H.265 are just formats; there are many encoders of varying quality which can generate such files and each encoder has tons of settings. I don't know which encoder macOS uses but ffmpeg includes state-of-the-art H.264 encoder (x264). Simply reencoding video from H.264 to H.264 using ffmpeg can give you better quality/size ratio than the original file.
> H.264 codec (or MPEG-4 Part 10), once upon a time know in the scene as DIVX.
No, DivX refers to MPEG-4 Part 2 which is a completely different codec.
It's actually even more complicated than that. Each encoder has multiple settings on how much CPU to spend on the compression. Live screen recording (which this was) usually has the setting set to spend little CPU and get little compression. So like you said you don't need to change which format you use to get better compression, but you also often don't even need to change what encoder you use, you can just change the compression setting to use extra CPU (which might not be possible on a live recording).
That is incorrect and bothered me enough that I scoured the web trying to find old scene release standards. Fascinatingly, there's a whole Wikipedia article on those[1] and it's still possible to find the original .nfos in strange corners of the internet[2].
But long story short, a DivX release was standardized to DivX 3.11, which was actually a reverse-engineered Microsoft codec and not actually MPEG-4 compatible[3]. But later DivX versions implemented MPEG-4 Part 2[4] -- that is still a completely different thing than MPEG-4 Part 10[5] though, which describes H.264 (but calls it AVC).
[1]: https://en.wikipedia.org/wiki/Standard_(warez) [2]: http://lunamoth.biz/pe.kr/cgi-bin/gm/archives/tdx2k2.nfo [3]: https://en.wikipedia.org/wiki/DivX [4]: https://en.wikipedia.org/wiki/MPEG-4_Part_2 [5]: https://en.wikipedia.org/wiki/Advanced_Video_Coding
Reencoding the same input file as h264 again but using FFmpeg defaults would probably yield similar file size reductions.
This is just a bogus post without knowing what parameters were used to encode the original h264.
I then used that as a source to transcode with x264 crf 23. New filesize 2.0M. ~26%
ffmpeg -i input.mov -c:v libx264 -crf 23 x264.mp4
Next, I used the same 7.5MB source to transcode with x265 crf 28. New filesize 968KB. ~13%
ffmpeg -i input.mov -c:v libx265 -crf 28 x265.mp4
CRF values were taken from [0] which states x265 crf28 should produce same visual quality of x264 crf23, but at half the size. That holds true.
[0]https://trac.ffmpeg.org/wiki/Encode/H.265
Edit: forgot link
So, I don't think the author's post is bogus. They just lose points for not showing their work (not that they did it, but you know).
Edit 2: I have no idea what the author of the post used for encode settings. I picked 2 based on the vendor's claim the 2 settings should look the same at half the bit rate. I easily could have changed the values to lower the bitrate to get from 50% to 94%. I just assumed the reader would be able to make the mental leap
Video codecs have lots of options and trade-offs. Its not just quality and file size, but also cpu usage. I suspect the original was encoded in minimize cpu usage while keeping quality constant, and the new one was minimize file size while keeping quality constant and use as much cpu as you want.
I strongly suspect that the difference here is between real-time compression that runs while capturing the screen recording, and less time-constrained offline compression during transcoding.
You mean for a given CRF ("crf" isn't an official term, it's what x264/x265 call their fixed quality mode). "Bitrate" is literally how big the file is.
That being said, H265 definitely does improve filesizes.
[0] https://developer.nvidia.com/video-encode-and-decode-gpu-sup... [1] https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video#Hardwar...
But I don't think desktops are the problem anyway as opposed to laptops/tablets. Desktop cpus are perfectly capable of decoding h265 in real time without acceleration
I don't think the steam hardware survey is a good sample of the wider computer market though - the majority of people using youtube/netflix/etc on x86 devices are probably using Intel laptop chips with integrated graphics, not $500+ dedicated GPUs.
(Although presumably this is probably becoming less true over time, those low end users are moving more and more to mobile devices and smart TVs/chromecast/console, leaving workstation/gaming systems to be a larger percentage of the market)
On the Apple end of things, h265 hardware decode has been supported since the A9 (iPhone 6S, introduced 2015)
They also list hardware decode support on Macs as of Intel 6th gen CPUs (Skylake, introduced 2015).
The mobile market I have no idea about.
EDIT: I was wrong about AMD - see replies.
Ryzen 4750U on a T14 reporting in:
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Mesa Gallium driver 20.3.4 for AMD RENOIR (DRM 3.40.0, 5.11.4-arch1-1, LLVM 11.1.0)
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileVC1Simple : VAEntrypointVLD
VAProfileVC1Main : VAEntrypointVLD
VAProfileVC1Advanced : VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointVLD
VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
VAProfileH264Main : VAEntrypointEncSlice
VAProfileH264High : VAEntrypointVLD
VAProfileH264High : VAEntrypointEncSlice
VAProfileHEVCMain : VAEntrypointVLD
VAProfileHEVCMain : VAEntrypointEncSlice
VAProfileHEVCMain10 : VAEntrypointVLD
VAProfileHEVCMain10 : VAEntrypointEncSlice
VAProfileJPEGBaseline : VAEntrypointVLD
VAProfileVP9Profile0 : VAEntrypointVLD
VAProfileVP9Profile2 : VAEntrypointVLD
VAProfileNone : VAEntrypointVideoProc
mpv also reports "Using hardware decoding (vaapi)." when I try to play an HEVC file.Most smartphone has also HEVC decode in the past 4 years.
Basically the adoption hurdle has nothing to do with Hardware. Only the two A in FAANG are supportive of JVET or MPEG standard. Others prefer their "patent free" ( cough ) AV1 codec.
Also, I’m not criticizing the authors English (which is much better than my Dutch), but some of those mistakes were almost poetic:
> Some more Ducking made me aware that using '-tag:v hvc1' in FFmpeg creates files that QuickTime can eat.
Same applies to H.264.
I think the main reason for OP’s observation, the codecs optimized for real time streaming (including the hardware codecs inside GPUs) don’t have enough time (both CPU time, and maximum allowed encoder latency) to achieve what ffmpeg does when asked to re-encode a video clip from hard drive.
Converting video from a lossy format to another lossy format with these settings will significantly degrade the quality. For a desktop recording that could be problematic, still frames could be unreadable.
Going from a lossless video file to both h264 and h265 will typically have h265 files about 30% smaller at the same quality, but this comes with significant tradeoffs for transcoding time. And there is some nuance to getting the best quality, generally there are more resources on how to do this with h264. And h265 hardware support isn't quite universal, many older mobile devices do not support it for instance.
...but you still have to record-and-save it in H.264 first then reload into QuickTime, and for some reason the H.265 quality isn't great. This is still the case even when using GPU VideoToolbox via ffmpeg/Handbrake, and it's something I've never figured out why.
As an aside, for more serious recordings (and if you don't want to use paid software), I recommend using OBS instead, as it gives you a lot more recording flexibility that the native macOS screen recorder lacks.
Maybe i'm wrong, but the comparision is stupid without having ffmpeg re-encode the video with the same codec. Otherwise its just apples to oranges.
Can you please share the full ffmpeg syntax used for converting the H.264 files to H.265?
-preset slower
# You control the tradeoff between video encoding speed and compression
# efficiency with the -preset options.
# ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow.
# Default is medium.> "what if I convert my screen recordings from H.264 to H.265?" Well, two things happend: My files shrink to 6% (not a type)
Sounds like the difference can be huge.
Sorry for my lame English. I really should not write blogs after midnight... Anyways, a lot of you are asking for what command-line options I used for FFMPEG.
So here it is:
ffmpeg -i input1.mov -c:v libx265 -tag:v hvc1 output1.mp4
- The use of the term "Ducked" instead of "searched" or "looked up" which is clearly forced and I guess trying to promote DuckDuckGo. - "Brew.SH" The program is called Homebrew and it is odd to capitalize the website like that. I have never seen someone say Duck.COM. - FFMPEG should be FFmpeg - photos.app should be Photos.app like Terminal.app that he mentioned earlier. - macOS is capitalized a different way literally every time is used.
For any one of these I wouldn't have thought twice, people make up new capitalization for names all the time. It seems to give the writing a condescending tone (helped by comments like "command line for non-Appleonians").
With the current title, I thought maybe there were 2 formats that differed in name only by a dot, and that this post was about clearing up that confusion between the nearly identical names.
typoception
Knowing this makes it less annoying to do it as you don’t have 4 keys combinations.
199x called, it wants its human interface guidelines back
I feel like it's the year of 4K. Greater than 24 inch, 4K monitors and 4k TV's are getting somewhat standard/affordable.
But looking at EZTV only around 18% of torrents are released as H265, which is disappointing.
I wonder which hardware accelerates h265 encoding on Linux.
Sorry for my lame English. I really should not write blogs after midnight... Anyways, a lot of you are asking for what command-line options I used for FFMPEG.
So here it is:
ffmpeg -i input1.mov -c:v libx265 -tag:v hvc1 output1.mp4
I have paid h265 on the windows store for 1 symbolic dollar and I'm sure you can find a license for cheaper, people should respect the media they consume not using h265 for regular video consumers is nonsensical. And no vp9 is inferior and av1 too in addition to the absence of hardware acceleration for av1. H266 has been released last summer, I can't wait for it to become widespread and push the boundaries of the user experience.