Skip to content

Instantly share code, notes, and snippets.

@kuntau
Last active May 11, 2024 03:52
Show Gist options
  • 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!**

@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