You are viewing a single comment's thread from:

RE: LeoThread 2024-09-21 06:33

in LeoFinance2 months ago

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.

Sort:  

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:

  • Lower CRF values mean higher quality (and larger file sizes).
  • Higher CRF values mean lower quality (and smaller file sizes).

For H.265, the typical CRF range is 18–28:

  • 18: Almost lossless quality (very high quality, large file size).
  • 23: Default and good balance between quality and size.
  • 28: Lower quality (smaller file size).

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:

  • CRF 23 is typically considered a good balance between quality and compression. It preserves most of the visual details while reducing the file size.
  • For most content, like movies or TV shows, you'll likely not notice any difference compared to the original.
  • However, if you're dealing with high-motion content (like sports or fast-paced action scenes) or you're viewing the video on a very large screen, there might be a slight loss of fine details.

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:

CRF ValueApproximate File Size
CRF 18~1.2 GB (larger than the original, near lossless)
CRF 20~900 MB to 1GB (similar to original, high quality)
CRF 23~700 MB to 800 MB (slightly reduced file size, good quality)
CRF 25~600 MB to 700 MB (noticeably smaller file size, still decent quality)
CRF 28~400 MB to 500 MB (significant reduction, quality loss may be visible)

Key Points:

  • CRF 18 results in larger files because it prioritizes quality over compression.
  • CRF 23 tends to reduce the file size by around 20–30% with minimal quality loss.
  • CRF 28 and higher values result in smaller files, but visual artifacts may become noticeable, especially in high-motion scenes.

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?

  • CRF 21: Provides almost imperceptible quality loss with slightly larger file sizes than CRF 23. Ideal if you're concerned about maintaining higher quality in fast-motion content.
  • CRF 22: Just a bit closer to CRF 23 but still leans toward better quality without a significant file size increase.