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
23 comments:
Missing u SSA... Thanks for this
Do you stop now making subs?
thanx
i dont understand anything, but thanks for your hardwork.
I wonder who will be inheriting SSA's way of encoding...
I too will miss your subs. And also would like to know if you have ant recommendations for new groups to follow for subs?
My PC isn't as beefy as it use to be and it takes about an hour to encode an episode, but the space savings are totally worth it.
Thank you so much for all the effort you've done over the months running SSAnime and for the magical script you've provided that does everything we need. My old re-encode setup required manually remuxing the new video back into the MKV �� and your way is infinitely preferable.
Once again, thank you so much and good luck in your future endeavours!
It seems there's an error in the command line - the option '-map 0:s?' shouldn't have the question mark - at least it only worked when I removed it. I too would like to thank SSAnime for all the hard work and great encodes, and I will miss you
Thank you for releasing your encoding technique (was thinking you would release the whole project including site and subsplease/nyaa torrent scraping, but beggars cant be choosers).
The encoding code above indeed works though I see why a powerful dedicated server is required. It took me 2h30m to do a single episode of reborn assassin averaging +/-5fps with my cores maxed out. Once again the fact you lasted so long popping out over $300 per month is admirable and I am greatful SSA even existed. Take of your self.
you will be greatly missed
Have you really stopped uploading content? Can anyone else confirm this?
hey SSA What about boruto naruto net generations are you going to stop uploading it too since im downloading it from you and i can't stop at ep 220 whats wrong that he stop uploading? Jahy sama too its not finished yet
Just wanna say thank you for doing this work & making how you encode public.
Would you be willing to share the python script (for personal use)? Or will I have to try to do some coding by myself?
Thanks for your hard work, the encoding info, and sorry to see you go. Best luck in the future!
would've been best if subsplease learned from you and did small encodes
youre a legend
Sad that none of the present encoders ever took up SSA's way of encoding... :(
I'm a bit befuddled as to why you'd limit sao, in my experience it's detrimental to do so, and it's even specifically recommended in kokomin's article you link to to not limit it for high CRFs (which 24.2 absolutely qualifies as).
For my personal encodes I ended up adopting setting deblock, merange and the smartblur filter (though weaker, 1.5:-0.25:-3.5:0.65:0.20:2.0), that combined with rc-lookahead 250, crf 24 and using opus instead of aac gave me smaller size, slightly faster encodes and yet also better quality according to ssim and psnr. (b-frames, aq-mode and psy-rd was already the same)
I read FFMPEG encode faster using NVIDIA GPU. Anyone knows how to do that? The current SSA settings uses CPU
I used your preset in HandBrake, 408 Mbytes output mkv from a 1.8 Gbytes input file from PuyaSubs, 1080p. Thank you.
I made an Image Comparison https://slow.pics/c/YPbAZx59
Post a Comment