Skip to content

Instantly share code, notes, and snippets.

@kuntau
Last active February 14, 2024 19:30
Show Gist options
  • Star 89 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save kuntau/a7cbe28df82380fd3467 to your computer and use it in GitHub Desktop.
Save kuntau/a7cbe28df82380fd3467 to your computer and use it in GitHub Desktop.
YIFY's Quality Encoding

For those that want to keep the YTS going (No, IDGAF about people that don't care for YTS quality) get HandbrakeCLI https://handbrake.fr/downloads... and use the following settings:

user@user:~$HandBrakeCLI -i /file/input.mp4 -o /file/out.mp4 -E fdk_faac -B 96k -6 stereo -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

Reason to use CLI over GTK has to do with lack of support for advanced settings for Handbrake GTK

** Don't Re-encode already shitty encodes...get good source!**

@pmsoltani
Copy link

can you also post the ffmpeg version? tnx

@CannonballSkippy
Copy link

FFMPEG version of this would be awesome!

@jamxbit
Copy link

jamxbit commented Oct 28, 2017

Got preset for MKV format please? I really like the "d3g" and "MeGusta" releases group i found in IPTorrents
And this is for 720 or 1080?

@Abhinav1217
Copy link

What would be a good x265 version of this? Like one used by PSArips.

@gabyu
Copy link

gabyu commented Feb 24, 2018

It did not work for me... i got an error with the audio encoder. it said

ERROR: Invalid audio encoder (fdk_faac)

Instead I used -E ffaac instead of -E fdk_faac

@nfjodor
Copy link

nfjodor commented Mar 21, 2018

Changed HandbrakeCli:

HandBrakeCLI -i input.mkv -o output.mkv -E ffaac -B 128k --all-subtitles --all-audio --mixdown 5point1 -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

This is the ffmpeg version:

ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0 output.mkv

I modded some things. This keep all audio, video and subtitle tracks. The max audio channels number is 5.1.

Okay, the file size a little bit larger, but I think, the audio tracks and channels is more important than ~150 mb save.

I tested both codes and got same filesize with same quality. The only one problem is the x264 so you will need a super strong CPU to transcode movies (my test configuration had a Core i7-4720HQ and the transcoding speed ~0.5x and the movie was 1080p)

I tested the nvenc (nvidia hardware accelerated transcoding), but I can't modify deeply enough the configuration. The result was ~same file size, but poor quality :(

@sacazo
Copy link

sacazo commented Apr 5, 2018

Can someone please tell me how to import these presets into Handbrake?
I see the presets are in json format.

Thank you

@mahfuz10
Copy link

mahfuz10 commented Sep 1, 2018

In ubuntu 18.04,
I found this error:

ERROR: Invalid audio encoder (fdk_faac)
Failed to initialize job

I changed the audio encoder:

I used -E ffaac instead of -E fdk_faac

I used this command:

HandBrakeCLI -i ./Project-1.mp4 -o ./Project-1-yifi.mp4 -E ffaac -B 96k -6 stereo -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

It works. Thanks.

@azarezade
Copy link

azarezade commented Feb 12, 2020

Dose anyone have RARBG settings by chance?
Those encoding that have RARBG-AAC in their name and with size about 2 or 3Gig usually.

@jump912
Copy link

jump912 commented May 26, 2020

It did not work for me... i got an error with the audio encoder. it said

ERROR: Invalid audio encoder (fdk_faac)

Instead I used -E ffaac instead of -E fdk_faac

This works. Thanks!

@Enriquetnt
Copy link

Changed HandbrakeCli:

HandBrakeCLI -i input.mkv -o output.mkv -E ffaac -B 128k --all-subtitles --all-audio --mixdown 5point1 -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

This is the ffmpeg version:

ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0 output.mkv

I modded some things. This keep all audio, video and subtitle tracks. The max audio channels number is 5.1.

Okay, the file size a little bit larger, but I think, the audio tracks and channels is more important than ~150 mb save.

I tested both codes and got same filesize with same quality. The only one problem is the x264 so you will need a super strong CPU to transcode movies (my test configuration had a Core i7-4720HQ and the transcoding speed ~0.5x and the movie was 1080p)

I tested the nvenc (nvidia hardware accelerated transcoding), but I can't modify deeply enough the configuration. The result was ~same file size, but poor quality :(

Thanks, that ffmepg script yields some very VERY good results for a light movie to watch in my laptop, heck up to 32 inches it looks acceptable, i reduced a 6 gig bdrip to 1.8 gigs mp4, sure i can go smaller reducing resolution but thats less than a third the size at 90% the quality

@Enriquetnt
Copy link

Also i got a corei7 3770k overclocked to 4.5 ghz and i pot around 0.6x transcoding speed from a 1080p source

@nfjodor
Copy link

nfjodor commented Sep 8, 2020

Also i got a corei7 3770k overclocked to 4.5 ghz and i pot around 0.6x transcoding speed from a 1080p source

It's absolutely normal because x264 has no hardware boost. If you want to convert a lot of movies you will need a server park :(

@bitappend
Copy link

these settings are for a X.mp4 file. what about a DVD ISO with the VOB etc.
with the gui i can just click on folder, then choose chapter selection(it sometimes auto selects a trailer instead of film). what arguments could be done with CLI. is this even possible esp if there are extras on the disk

@littlefico
Copy link

Changed HandbrakeCli:

HandBrakeCLI -i input.mkv -o output.mkv -E ffaac -B 128k --all-subtitles --all-audio --mixdown 5point1 -R 44.1 -e x264 -q 27 -x cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all

This is the ffmpeg version:

ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -c:a aac -ar 44100 -b:a 128k -map 0 output.mkv

I modded some things. This keep all audio, video and subtitle tracks. The max audio channels number is 5.1.

Okay, the file size a little bit larger, but I think, the audio tracks and channels is more important than ~150 mb save.

I tested both codes and got same filesize with same quality. The only one problem is the x264 so you will need a super strong CPU to transcode movies (my test configuration had a Core i7-4720HQ and the transcoding speed ~0.5x and the movie was 1080p)

I tested the nvenc (nvidia hardware accelerated transcoding), but I can't modify deeply enough the configuration. The result was ~same file size, but poor quality :(

i hope you are still active.
i tested this option and get a very nice result but i had to remove the VOBsub subtitle before, because there was an error. (Subtitle encoding cunently only possible from text to text or bitmap to bitmap)
i tested the file and both files still had 2 audiostreams. stero and 5.1
the 5.1 in the encoded file was horrible while the stereo sound was like the original file.
my question, because i cannot really read the ffmpeg command.

was my audio in stereo still in orig format or was it encoded?

@nfjodor
Copy link

nfjodor commented Jan 16, 2021

i hope you are still active.
i tested this option and get a very nice result but i had to remove the VOBsub subtitle before, because there was an error. (Subtitle encoding cunently only possible from text to text or bitmap to bitmap)
i tested the file and both files still had 2 audiostreams. stero and 5.1
the 5.1 in the encoded file was horrible while the stereo sound was like the original file.
my question, because i cannot really read the ffmpeg command.

was my audio in stereo still in orig format or was it encoded?

Hi! If you don't want audio encoding, just remove -c:a aac -ar 44100 -b:a 128k.

In this case, the ffmpeg looks like this:

ffmpeg -i input.mkv -c:v libx264 -crf 27 -x264-params cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all -map 0 output.mkv

@littlefico
Copy link

1.) thx for the ultra fast response
2.) with the -c:a aac -ar 44100 -b:a 128k active, did this touch both stereo AND 5.1 audio or just 5.1 audio?
3.) so removing the audio part means the same as -c:a ? is this right?
4.) is there a way to take the subtitle with me?

@nfjodor
Copy link

nfjodor commented Jan 16, 2021

1.) thx for the ultra fast response
2.) with the -c:a aac -ar 44100 -b:a 128k active, did this touch both stereo AND 5.1 audio or just 5.1 audio?
3.) so removing the audio part means the same as -c:a ? is this right?
4.) is there a way to take the subtitle with me?

  1. You are welcome 😄
  2. I think only the 5.1 audio but I'm not sure
  3. No, if you want to copy without transcoding, need to add -c:a copy see here: https://ffmpeg.org/ffmpeg.html#Main-options
  4. Yes, but I don't know how 😃

@alfrenovsky
Copy link

There's a nvenc ffmpeg version?

@nfjodor
Copy link

nfjodor commented May 31, 2021

There's a nvenc ffmpeg version?

No, sadly nVidia hardware accelerated conversion can't be well configured, however it is very fast.

@PriamX
Copy link

PriamX commented Jan 7, 2022

4.) is there a way to take the subtitle with me?

I'm no ffmpeg expert, but I think you just add -c:s copy to the options.

@br441
Copy link

br441 commented Mar 9, 2022

can anyone convert the x264-params (in the ffmpeg version) into the x265-params equivalent?

@AlekseyMalakhov
Copy link

It did not work for me... i got an error with the audio encoder. it said

ERROR: Invalid audio encoder (fdk_faac)

Instead I used -E ffaac instead of -E fdk_faac

Thank you, sir! I had the same problem, it helped!

@sethfoxen
Copy link

sethfoxen commented Jul 30, 2023

I've tweaked these a little bit, and I've been using this preset to encode EVERYTHING to 720p. TV Shows and Movies, shorts, Youtube rips (lmao I know they're shite quality to begin with, but I can't tell the difference during playback as long as the base resolution is above 720)
Handbrake has had a few updates since this main post, and the advanced settings are more exposed in the GUI now, so the extra options can just be copied and pasted into the advanced sections.
I've bumped the audio bitrate a bit, and tightened the CRF slider slightly, and I'm getting within 5-10 megs difference of MODERN YTS encodes, so I'm happy to use it to encode movies that haven't been posted, and of course encoding TV Shows.
I'll tack the json onto the end of this post, just make sure to set the tuning to the correct source, and tweak the filters yourself if you're starting with interlaced media and such. For a BD Rip or even a 1080p+ webrip, these settings are real nice. For classic cartoons, no matter the starting resolution, I drop the resolution down to 480, ultralite and animation tune for denoise with NLMeans, and drop the audio down to 96kbps.

{ "PresetList": [ { "AlignAVStart": true, "AudioCopyMask": [], "AudioEncoderFallback": "av_aac", "AudioLanguageList": [ "und" ], "AudioList": [ { "AudioBitrate": 128, "AudioCompressionLevel": 0, "AudioEncoder": "av_aac", "AudioMixdown": "stereo", "AudioNormalizeMixLevel": false, "AudioSamplerate": "44.1", "AudioTrackQualityEnable": false, "AudioTrackQuality": -1, "AudioTrackGainSlider": 0, "AudioTrackDRCSlider": 0 } ], "AudioSecondaryEncoderMode": true, "AudioTrackSelectionBehavior": "first", "ChapterMarkers": false, "ChildrenArray": [], "Default": true, "FileFormat": "av_mp4", "Folder": false, "FolderOpen": false, "Mp4HttpOptimize": true, "Mp4iPodCompatible": false, "PictureCropMode": 0, "PictureBottomCrop": 0, "PictureLeftCrop": 0, "PictureRightCrop": 0, "PictureTopCrop": 0, "PictureDARWidth": 0, "PictureDeblockPreset": "off", "PictureDeinterlaceFilter": "off", "PictureCombDetectPreset": "off", "PictureCombDetectCustom": "", "PictureDenoiseCustom": "", "PictureDenoiseFilter": "off", "PictureSharpenCustom": "", "PictureSharpenFilter": "off", "PictureSharpenPreset": "medium", "PictureSharpenTune": "none", "PictureDetelecine": "off", "PictureDetelecineCustom": "", "PictureColorspacePreset": "off", "PictureChromaSmoothPreset": "off", "PictureItuPAR": false, "PictureKeepRatio": true, "PicturePAR": "auto", "PicturePARWidth": 0, "PicturePARHeight": 0, "PictureWidth": 1280, "PictureHeight": 720, "PictureUseMaximumSize": true, "PictureAllowUpscaling": false, "PictureForceHeight": 0, "PictureForceWidth": 0, "PicturePadMode": "none", "PicturePadTop": 0, "PicturePadBottom": 0, "PicturePadLeft": 0, "PicturePadRight": 0, "PresetDescription": "YTS Quality Conversion", "PresetName": "YTS", "Type": 1, "SubtitleAddCC": false, "SubtitleAddForeignAudioSearch": false, "SubtitleAddForeignAudioSubtitle": false, "SubtitleBurnBehavior": "none", "SubtitleBurnBDSub": false, "SubtitleBurnDVDSub": false, "SubtitleLanguageList": [ "eng" ], "SubtitleTrackSelectionBehavior": "all", "VideoAvgBitrate": 0, "VideoColorMatrixCode": 0, "VideoEncoder": "x264", "VideoFramerate": "23.976", "VideoFramerateMode": "pfr", "VideoGrayScale": false, "VideoScaler": "swscale", "VideoPreset": "placebo", "VideoTune": "", "VideoProfile": "auto", "VideoLevel": "auto", "VideoOptionExtra": "cabac=1:ref=5:analyse=0x133:me=umh:subme=9:chroma-me=1:deadzone-inter=21:deadzone-intra=11:b-adapt=2:rc-lookahead=60:vbv-maxrate=10000:vbv-bufsize=10000:qpmax=69:bframes=5:b-adapt=2:direct=auto:crf-max=51:weightp=2:merange=24:chroma-qp-offset=-1:sync-lookahead=2:psy-rd=1.00,0.15:trellis=2:min-keyint=23:partitions=all", "VideoQualityType": 2, "VideoQualitySlider": 25, "VideoTwoPass": false, "VideoTurboTwoPass": false, "x264UseAdvancedOptions": false, "PresetDisabled": false, "MetadataPassthrough": false } ], "VersionMajor": 50, "VersionMicro": 0, "VersionMinor": 0 }

@Nostalgia2046
Copy link

Hello friends, a few quesitons :

Would that be possible to give us a small tutorial of how to launch that ? I'm guessing I need to do this through Linux command or is it possible through Pc ?

I'm asking cause there is a Handbrake Cli version on Pc but have no idea how to use this.

Thanks in advance !

@ScribbleGhost
Copy link

Hello friends, a few quesitons :

Would that be possible to give us a small tutorial of how to launch that ? I'm guessing I need to do this through Linux command or is it possible through Pc ?

I'm asking cause there is a Handbrake Cli version on Pc but have no idea how to use this.

Thanks in advance !

Just use Handbrake

@thedroidkid
Copy link

Does anyone have the 2160P string they use?

@lopes143
Copy link

Does anyone have the 2160P string they use?

I would like to know too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment