Skip to content

Instantly share code, notes, and snippets.

@parnexcodes
Last active May 11, 2024 03:51
Show Gist options
  • Save parnexcodes/601df332dd06effea254be38132b9c61 to your computer and use it in GitHub Desktop.
Save parnexcodes/601df332dd06effea254be38132b9c61 to your computer and use it in GitHub Desktop.
Note : These are the settings i wrote by observing the Mediainfo of RARBG Encodes , these might not be 100% identical to RARBG Encodes.
These are FFMPEG Settings.
See comment below to see the code
@parnexcodes
Copy link
Author

720p x264

ffmpeg -i input.mkv -vn -ac 6 -ar 48000 -ab 224k -c:a aac -codec:v libx264 -pix_fmt yuv420p -b:v 1500k -minrate 1200k -maxrate 1800k -bufsize 5000k -vf scale=-2:720 output.mp4

1080p x264

ffmpeg -i input.mkv -vn -ac 6 -ar 48000 -ab 224k -c:a aac -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -minrate 2000k -maxrate 3000k -bufsize 5000k -vf scale=-2:1080 output.mp4

x265 Later

@a-raccoon
Copy link

a-raccoon commented Aug 21, 2022

Can you explain the minrate and maxrate settings, because all 1080p.H264.AAC-RARBG/VXT rips are spot on 2500 kbit, +/-1 kbit?
For us n00bs still groping in the dark, can you explain the choice of settings and what they do, and how they translate from RARBG's MediaInfo?

Here's a 1980's anime:

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings : CABAC / 4 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 4 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 1 h 43 min
Bit rate : 2 500 kb/s
Width : 1 920 pixels
Height : 1 036 pixels
Display aspect ratio : 1.85:1
Frame rate mode : Constant
Frame rate : 23.976 (23976/1000) FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.052
Stream size : 1.81 GiB (92%)
Writing library : x264 core 152 r2851M ba24899
Encoding settings : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15
 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3
 / threads=16 / lookahead_threads=4 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0
 / bframes=3 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25
 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=2pass / mbtree=1 / bitrate=2500 / ratetol=1.0 / qcomp=0.60 / qpmin=0
 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / vbv_maxrate=31250 / vbv_bufsize=31250 / nal_hrd=none / filler=0
 / ip_ratio=1.40 / aq=3:1.00
Encoded date : UTC 2022-07-xxx
Tagged date : UTC 2022-07-xxx
Codec configuration box : avcC

Audio
ID : 2
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 1 h 43 min
Bit rate mode : Constant
Bit rate : 224 kb/s
Channel(s) : 2 channels
Channel layout : L R
Sampling rate : 48.0 kHz
Frame rate : 46.875 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 166 MiB (8%)
Language : English
Default : Yes
Alternate group : 1
Encoded date : UTC 2022-07-xxx
Tagged date : UTC 2022-07-xxx

What are all these other settings and are they just ffmpeg's defaults?

@cmirza
Copy link

cmirza commented Jun 24, 2023

The -vn flag specifies only audio should be encoded. Should be removed. I think the following should be a bit closer to RARBG/ION10 settings, but welcome any improvement:

1080p

$ ffmpeg -i input.mkv -ac 6 -ar 48000 -ab 224k -c:a aac -codec:v libx264 -pix_fmt yuv420p -b:v 2500k -vf "scale=1920:trunc(ow/a/2)*2" output.mp4

720p

$ ffmpeg -i input.mkv -ac 6 -ar 48000 -ab 224k -c:a aac -codec:v libx264 -pix_fmt yuv420p -b:v 1500k -vf "scale=1280:trunc(ow/a/2)*2" output.mp4

480p
$ ffmpeg -i input.mkv -ac 2 -ar 48000 -ab 256k -c:a aac -codec:v libx264 -pix_fmt yuv420p -b:v 1100k -vf "scale=720:trunc(ow/a/2)*2" output.mp4

@iojeda
Copy link

iojeda commented Aug 5, 2023

Hi Guys thanks a lot for providing this magnificent insight into encoding parameters.
Could any of you please provide libx265 parameters for 1080p and 4k?
I would like to encode my library and was hoping to use tested parameters instead of doing a lot of trial and error.
Thanks

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