One of the main concerns here is that X265 drinks up a lot of your CPU in exchange for giving a very good clear video file.
I have done a lot, and when I say a lot, literally months (4 months = ~120 days) of comparison with different types of x265 and x264 settings.
And at the end what software do I use to encode episodes? FFMPEG
Yup, it's as simple as that. Though older versions won't work out, the recent one's have latest x265 features after all. Just download it from google.
Look, I'm not going to waste your time to read all the stuff I want to say and I'll just give you the settings.
Here is the settings that I wrote on my python script:
{ 'c:a': 'aac', 'c:v': 'libx265', 'b:a': '192k', 'profile:v': 'main', 'x265-params': ':'.join([ 'me=2', 'rd=4', 'subme=7', 'aq-mode=3', f'aq-strength=1', f'deblock=1,1', f'psy-rd=1', f'psy-rdoq=1', 'rdoq-level=2', 'merange=57', 'bframes=8', 'b-adapt=2', 'limit-sao=1', 'frame-threads=3', 'no-info=1', ]), 'crf': 24.2, 'preset': 'slow', 'pix_fmt': 'yuv420p', 'vf': ','.join([ 'smartblur=1.5:-0.35:-3.5:0.65:0.25:2.0', 'scale=1920:1080:spline16+accurate_rnd+full_chroma_int' ]), 'metadata': 'Encoder Settings=Redacted, CPU - 2xAMD EPYC 7282 32 cores/64 threads, GPU - None used', 'color_range': 1, 'color_primaries': 1, 'colorspace': 1, 'color_trc': 1, }
And converting it into command line arguments:
ffmpeg -i input.mkv -map 0:v -map 0:a -b:a 192k -c:a aac -c:v libx265 -color_primaries 1 -color_range 1 -color_trc 1 -colorspace 1 -crf 24.2 -map 0:s? -pix_fmt yuv420p -preset slow -profile:v main -vf smartblur=1.5:-0.35:-3.5:0.65:0.25:2.0,scale=1920:1080:spline16+accurate_rnd+full_chroma_int -x265-params me=2:rd=4:subme=7:aq-mode=3:aq-strength=1:deblock=1,1:psy-rd=1:psy-rdoq=1:rdoq-level=2:merange=57:bframes=8:b-adapt=2:limit-sao=1:frame-threads=3:no-info=1 output.mp4 -y
Now if you have spare time to read my rantings about what I found when I was researching.
First of all you see that frame-threads over there? If you are running only one instance of ffmpeg command on your pc then no need of that. But yea having frame-threads to 3 gives you extra space threads/cores to encode more episodes parallelly (if you have equal or more than 16 total threads and on linux) if you have enough free threads/cores available. With the CPU I was using 2 x AMD EPYC 7282, 32 cores 2.8GHz 64 threads (I swear it was $260 when I bought it, during Covid rate changes in a blink of an eye) most of the time 90% of CPU was taken by FFMPEG when it was encoding 5 episodes at the same time. Others were for NGINX and Webserver.
You probably didn't notice it
About the parameters inside x265-params, you can study it here: https://x265.readthedocs.io/en/3.4/cli.html
To make the encoding faster:
Hiding Information about encoding parameters:
What about the other parameters inside x265-params?
Video Parameters:
- libx265 obviously. Since NVENC encoder is not even an option to consider as it worsens quality.
- Do not control the bitrate. Anime episodes should have variable bitrates, putting any kinds of limits will kill the colors in some awesome scenes, like I messed up SAO Alicization when I was encoding it on my local PC. It will also put banding on video.
- slow is the best possible value for preset.
- 24.2 is the overall best value for CRF. I have sometimes used 23 or 22 if the file size was too small and not of good quality. 25 or 25.4 if the file size was going too large. Higher than 25.4 is not recommended as it worsens the quality of the video at places you can't imagine.
- main gave the best results for profile of video, I don't remember about other profiles.
- yuv420p standard pixel format for any anime video.
- Color Parameters:
- color_range, color_primaries, colorspace, color_trc was something I started using on a whim when I found out about it on an old anime forum, didn't see any significant differences but definitely felt like color loss after encoding was lesser when using it rather than when not using it.
- Remove metadata, it's unrelated if you have any.
- vf
- scale parameter is used for scaling (1080p,720p,480p)
- 480p: scale=848:480:spline16+accurate_rnd+full_chroma_int
- 720p: scale=1280:720:spline16+accurate_rnd+full_chroma_int
- 1080p: scale=1920:1080:spline16+accurate_rnd+full_chroma_int
- smartblur I found this value on a forum: https://forum.videohelp.com/threads/389480-Need-help-with-FFMpeg-and-detail-enhancement-sharpening#post2523233
Audio parameters:
https://github.com/m-ab-s/media-autobuild_suite
- Best Quality Lossless (recommended) - greater or equal to 192k
- Better Quality - greater or equal to 160k and less than 192k
- Above Average Quality - greater or equal to 128k and less than 160k
- Average Quality - greater or equal to 112k and less than 128k
- Low Quality (Small File Size) - greater or equal to 96k and less than 112k
- Lowest Quality (Smaller File Size) - greater or equal to 64k and less than 96k
- Worst Quality (File Size Negligible) - lesser or equal to 64k