Changes between Version 16 and Version 17 of Encode/H.265


Ignore:
Timestamp:
Mar 2, 2020, 11:15:13 PM (6 months ago)
Author:
llogan
Comment:

added lossless, intra, toc, title

Legend:

Unmodified
Added
Removed
Modified
  • Encode/H.265

    v16 v17  
    1 = FFmpeg and H.265 Encoding Guide =
     1{{{
     2#!html
     3<h1 style="font-size: 22px;">
     4H.265/HEVC Video Encoding Guide
     5</h1>
     6}}}
    27
    3 ffmpeg has support for H.265 / HEVC encoding using the [http://x265.org/ x265 encoder].
     8[[PageOutline(1, Contents)]]
    49
    5 `libx265` can offer around 25–50% bitrate savings compared to H.264 video encoded with `libx264`, while retaining the same visual quality. These gains will be most pronounced at resolutions of 1080p and higher.
     10This guide focuses on the encoder libx265 which can offer around 25–50% bitrate savings compared to H.264 video encoded with libx264, while retaining the same visual quality. These gains will be most pronounced at resolutions of 1080p and higher.
    611
    7 == Getting ffmpeg with libx265 support ==
     12See [[HWAccelIntro]] for information on supported hardware H.265/HEVC encoders.
    813
    9 ffmpeg needs to be built with the `--enable-gpl` `--enable-libx265` configuration flag and requires `x265` to be installed on your system. The [[CompilationGuide|Compilation Guides]] show you how to do that.
     14= Getting ffmpeg with libx265 support =
    1015
    11 You can also [http://ffmpeg.org/download.html download a static build], all of which bundle libx265.
     16ffmpeg needs to be built with the `--enable-gpl` `--enable-libx265` configuration flags and requires `x265` to be installed on your system. The [[CompilationGuide|Compilation Guides]] show you how to do that.
    1217
    13 == Encoding ==
     18You can also [https://ffmpeg.org/download.html download a static build], all of which bundle libx265.
     19
     20= Viewing options =
     21
     22You can list [https://ffmpeg.org/ffmpeg.html#AVOptions private options] available in this encoder with `ffmpeg -h encoder=libx265`.
     23
     24= Rate control modes =
    1425
    1526Similar to x264, the x265 encoder has multiple rate control algorithms, including:
     
    2132In this guide we are going to focus on CRF and Two-Pass encoding, as 1-pass target bitrate encoding is not recommended.
    2233
    23 === Constant Rate Factor (CRF) ===
     34== Constant Rate Factor (CRF) ==
    2435
    2536Use this mode if you want to retain good visual quality and don't care about the exact bitrate or filesize of the encoded file. The mode works exactly the same as in x264, so please read the [[H.264#crf|H.264]] guide for more info.
     
    3142* Choose a preset. The default is `medium`. The preset determines how fast the encoding process will be at the expense of detail. Put differently, if you choose `ultrafast`, the encoding process is going to run fast, and the file size will be smaller when compared to `medium`. The visual quality will not be as good. Slower presets use more memory.  Valid presets are `ultrafast`, `superfast`, `veryfast`, `faster`, `fast`, `medium`, `slow`, `slower`, `veryslow` and `placebo`.
    3243
    33 * Choose a tune. By default, this is disabled, and it is generally not required to set a tune option. x265 supports the following `-tune` options: `psnr`, `ssim`, `grain`, `zerolatency`, `fastdecode`. They are rexplained in the [[H.264#crf|H.264 guide]].
     44* Choose a tune. By default, this is disabled, and it is generally not required to set a tune option. x265 supports the following `-tune` options: `psnr`, `ssim`, `grain`, `zerolatency`, `fastdecode`. They are explained in the [[H.264#crf|H.264 guide]].
    3445
    3546For example:
     
    3950}}}
    4051
    41 This example uses AAC audio at 128 kBit/s. This uses the ffmpeg-internal encoder, but under [[AAC]] you will find info about more options.
     52This example uses AAC audio at 128 kBit/s. This uses the native FFmpeg AAC encoder, but under [[AAC]] you will find info about more options.
    4253
    43 === Two-Pass Encoding ===
     54== Two-Pass Encoding ==
    4455
    4556This method is generally used if you are targeting a specific output file size and output quality from frame to frame is of less importance. This is best explained with an example. Your video is 10 minutes (600 seconds) long and an output of 200 MiB is desired. Since `bitrate = file size / duration`:
     
    7586As with CRF, choose the slowest `-preset` you can tolerate, and optionally apply a `-tune` setting. Note that when using faster presets with the same target bitrate, the resulting quality will be lower and vice-versa.
    7687
    77 === Passing Options ===
     88= Passing Options =
    7889
    79 Generally, options are passed to x265 with the `-x265-params` argument. For fine-tuning the encoding process, you can therefore pass any option that is listed in the [http://x265.readthedocs.org/en/default/ x265 documentation]. Keep in mind that fine-tuning any of the options is generally not necessary, unless you absolutely know what you need to change.
     90Generally, options are passed to x265 with the `-x265-params` argument, as in `-x265-params "keyint=1:lossless=1"`. For fine-tuning the encoding process, you can therefore pass any option that is listed in the [https://x265.readthedocs.io/en/default/ x265 documentation]. Keep in mind that fine-tuning any of the options is generally not necessary, unless you absolutely know what you need to change.
    8091
    81 === Setting Profiles ===
     92= Lossless encoding =
     93
     94Use the `-x265-params lossless=1` option. Adding `-crf 0` is not required.
     95
     96You can verify lossless encoding by looking for `x265 [info]: lossless compression ratio` in the console output from your encoding command, or refer to the [https://ffmpeg.org/ffmpeg-formats.html#hash hash demuxer].
     97
     98= Intra encoding =
     99
     100Use the `-g 1` option for FFmpeg 4.3 (currently release pending) and newer or if you're using a build from the git master branch. Older versions must use `-x265-params keyint=1`.
     101
     102= Setting Profiles =
    82103
    83104Profiles can be set via the `-profile:v` option, similar to libx264.
    84105
     106= Further Info =
    85107
    86 == Further Info ==
    87 
    88 * [http://x265.readthedocs.org/en/default/ x265 API documentation]
     108* [https://x265.readthedocs.io/en/default/ x265 API documentation]
    89109* [https://medium.com/netflix-techblog/a-large-scale-comparison-of-x264-x265-and-libvpx-a-sneak-peek-2e81e88f8b0f Netflix Tech Blog — A Large-Scale Comparison of x264, x265, and libvpx] ([https://www.spiedigitallibrary.org/conference-proceedings-of-spie/9971/997116/A-large-scale-video-codec-comparison-of-x264-x265-and/10.1117/12.2238495.short?SSO=1 link to paper])
    90 * P. Hanhart et al., Subjective quality evaluation of the upcoming HEVC video compression standard ([http://infoscience.epfl.ch/record/180494/files/hanhart_SPIE2012_1.pdf PDF])
     110* P. Hanhart et al., Subjective quality evaluation of the upcoming HEVC video compression standard ([https://infoscience.epfl.ch/record/180494/files/hanhart_SPIE2012_1.pdf PDF])