Below in comments, I'll put various prompts with ChaGPT about compressing videos with libx265
to have MP4 videos encoded with H.265
compression.
Conversation Summary:
To convert .mkv
files to .mp4
with H.265 using FFmpeg, you can write a script that runs in a terminal and processes files in the current directory, saving them to a date-named subfolder. To speed up the process, use the -threads 0
option to leverage all CPU cores, as FFmpeg doesn't always use all threads by default. You can also use GPU acceleration (e.g., hevc_nvenc
for NVIDIA) for faster encoding or adjust the preset (e.g., fast
) for quicker processing. To run conversions in parallel for multiple files, use GNU Parallel. Quality adjustments can be made using the -crf
option, with values like 21 or 22 providing a balance between quality and file size.
I Prompted ChatGPT: In terms of video compression, what's "crf"?
The
-crf
(Constant Rate Factor) is a parameter in FFmpeg that controls the quality of the video when using lossy compression (such as H.265 or H.264). It sets the balance between video quality and file size.Here’s how it works:
For H.265, the typical CRF range is 18–28:
In the example script,
-crf 23
is used because it's often considered a good trade-off for retaining quality without excessively increasing file size. You can adjust it based on your preference for quality vs. size.I Prompted ChatGPT: Is the quality difference of compression with
-crf 23
noticeable in any way?Response:
In most cases, the quality difference at
-crf 23
is not noticeable to the human eye, especially for general viewing purposes. Here's why:If you're concerned about quality, you can lower the
-crf
value (e.g.,-crf 18
or-crf 20
) to maintain more detail, though this will result in larger files.I Prompted ChatGPT: Give me example of the difference in file size of a 1GB high motion video between all different crf qualities.
Response:
The file size of a video depends on several factors, including the CRF value, the resolution, frame rate, and video content. Here's an estimated comparison of the file size differences for a 1GB high-motion video at various CRF values using the H.265 codec:
Key Points:
This table gives rough estimates, as actual file sizes can vary depending on the specific content of the video.
Comments on ChatGPT's Response:
I used CRF 22 on a video, and 1 hour of content of a high motion, 40 FPS video used up to 4GB of space.
I Prompted ChatGPT: Can I do crf 22 or 21? Do you recommend it as an in-between option?
Response:
Yes, you can use CRF 21 or 22 as in-between options. The CRF scale is continuous, meaning you can choose any value between 0 (lossless) and 51 (worst quality). Using CRF 21 or 22 offers a slightly higher quality than CRF 23 with a moderate increase in file size, making them good choices if you're looking for a better balance between quality and compression.
Why choose CRF 21 or 22?