Transcoding 100+ files from H.264 to H.265 I am in a process of transcoding 100+ High Quality Bitrate 720p MKVs containing H.264 (x264) to H.265 (x265 / HEVC).

I do this with HandBrake software under Linux Debian 9 on Intel Xeon E3-1225 v3 3.2GHz 4-core.

Various versions follow.

Kernel:

4.8.0-1-amd64


HandBrake:

0.10.5 (x86_64)


x265:

2.1-2
using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2


I have these settings applied, according to mediainfo:

Encoding settings: wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=3 / tu-inter-depth=3 / me=3 / subme=4 / merange=57 / rect / amp / max-merge=4 / temporal-mvp / no-early-skip / rskip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / open-gop / no-temporal-layers / interlace=0 / keyint=240 / min-keyint=24 / scenecut=40 / rc-lookahead=40 / lookahead-slices=0 / bframes=8 / bframe-bias=0 / b-adapt=2 / ref=5 / limit-refs=1 / limit-modes / weightp / weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=6 / psy-rd=2.00 / rdoq-level=2 / psy-rdoq=1.00 / log2-max-poc-lsb=8 / no-rd-refine / signhide / deblock=0:0 / sao / no-sao-non-deblock / b-pyramid / cutree / no-intra-refresh / rc=crf / crf=21.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ipratio=1.40 / pbratio=1.30


In short I have applied Constant Quality RF21 and at veryslow preset.

Originals are all at fixed 2 GiB size. The sizes my encodes differ (you can deduce how much time it took too from the file list):

494M Dec  7 07:02 S05E16.mp4
551M Dec  7 00:14 S05E17.mp4
654M Dec  6 16:11 S05E18.mp4
668M Dec  6 08:10 S05E19.mp4


The original files have these settings applied:

Encoding settings: cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=12 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=2pass / mbtree=1 / bitrate=5670 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00


The question is, is the CPU time well spent? I mean, can I do any obvious optimizations to speed things up without having lower quality and / or larger files as a result?

EDIT1:

Citation from the official source:


  x265 has ten predefined --preset options that optimize the trade-off between encoding speed (encoded frames per second) and compression efficiency (quality per bit in the bitstream). The default preset is medium. It does a reasonably good job of finding the best possible quality without spending excessive CPU cycles looking for the absolute most efficient way to achieve that quality. When you use faster presets, the encoder takes shortcuts to improve performance at the expense of quality and compression efficiency. When you use slower presets, x265 tests more encoding options, using more computations to achieve the best quality at your selected bit rate (or in the case of –crf rate control, the lowest bit rate at the selected quality).  


EDIT2:  

Hardware configuration



Type: Dedicated server of mine. Currently used only to transcode videos.

CPU: Intel Xeon E3-1225 v3 3.2GHz 4-core

GPU: No dedicated card, only integrated

RAM: 32GB ECC 1600MHz

Disks:


SSD; used for system
HDDs in RAID6; used for writing the output videos
RAMDisk 20GB; used for reading the source videos


EDIT3:

With regard to the comment about swapping the memory, I have had set vm.swappiness = 1.
The whole one day I dedicated to testing various scenarios. The following applies to this particular series in this particular quality, so I don't say it applies generally. So in this case the following applies:


file sizes at the very same settings with only medium and veryslow preset changed vary negligibly: ~ -10 MiB on average in favor of veryslow preset
visual quality at a very close look is rather the same in either medium or veryslow preset


One thing solved. I have changed the preset to medium.




at a very close look, the source videos are not in such a high quality as I thought, that explains why x265 compresses to almost 1/4 of the original size


Another mystery solved.

Provided I now transcode at 25 fps, I have raised the RF to 20.




RAMDisk does not provide benefit in this case, both for medium and veryslow preset; I ended up with RAID6 as the source and SSD as the output drive


The inconvenience of moving files to RAMDisk solved.



To answer the question, the CPU time was not spent well at all.