I am in a process of transcoding 100+ High Quality Bitrate 720p [MKV](https://en.wikipedia.org/wiki/Matroska)s containing [H.264 (x264)](https://en.wikipedia.org/wiki/X264) to [H.265 (x265 / HEVC)](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding).

I do this with [HandBrake](https://en.wikipedia.org/wiki/HandBrake) software under Linux [Debian](https://en.wikipedia.org/wiki/Debian) 9 on [Intel Xeon E3-1225 v3 3.2GHz 4-core](https://ark.intel.com/products/75461/Intel-Xeon-Processor-E3-1225-v3-8M-Cache-3_20-GHz).

Various versions follow.

Kernel:

```
4.8.0-1-amd64

```

[HandBrake](https://en.wikipedia.org/wiki/HandBrake):

```
0.10.5 (x86_64)

```

[x265](https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding):

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

```

I have these settings applied, according to [mediainfo](https://en.wikipedia.org/wiki/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](https://x265.readthedocs.io/en/default/presets.html#presets).

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](https://x265.readthedocs.io/en/default/presets.html#presets):

> 
> 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](https://ark.intel.com/products/75461/Intel-Xeon-Processor-E3-1225-v3-8M-Cache-3_20-GHz)

GPU: No dedicated card, only integrated

RAM: 32GB ECC 1600MHz

Disks:

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

**EDIT3**:

With regard to the comment about swapping the memory, I have had set [`vm.swappiness`](https://en.wikipedia.org/wiki/Swappiness) = 1.