Skip to content

Instantly share code, notes, and snippets.

@fractal-fumbler
Last active July 13, 2021 00:11
Show Gist options
  • Save fractal-fumbler/802a8699985ee5d96333c082e6b2489d to your computer and use it in GitHub Desktop.
Save fractal-fumbler/802a8699985ee5d96333c082e6b2489d to your computer and use it in GitHub Desktop.
ffmpeg bluray encoding (libx264 + x265 + svtav1)
bluray video/audio/subtitle info
ffprobe -show_entries stream=index,codec_type:stream_tags=language -of compact \
bluray:"/path/to/bluray/folder" 2>&1 | { while read line; do if $(echo "$line" |\
grep -q -i "stream #"); then echo "$line"; fi; done; while read -d $'\x0D' line; \
do if $(echo "$line" | grep -q "time="); then echo "$line" | awk '{ printf "%s\r", $8 }'; fi; done; }

#todo map -d? map -t?

libx264
ffmpeg -analyzeduration 2000M -probesize 2000M -fix_sub_duration \
-i bluray:"/path/to/bluray/folder" \
-map_metadata 0 -movflags use_metadata_tags -map 0:v:0 -map 0:a:0 \
-metadata:s:a:0 language=spa -map 0:a:1 -metadata:s:a:1 language=rus \
-map 0:s:0 -metadata:s:s:0 language=eng -map 0:s:1 -metadata:s:s:1 language=spa \
-max_muxing_queue_size 8192 -c copy -codec:v:0 libx264 \
-x264-params "cabac=1:rc-lookahead=250:bframes=16:b-bias=0:b-adapt=2:b-pyramid=2:\
ref=16:mixed-refs=1:deblock=1,0,0:ipratio=1.41:keyint=250:min-keyint=25:open_gop=0:\
qpmin=10:qpmax=51:qpstep=4:aq-mode=2:weightb=1:weightp=2:analyse=0x3,0x133:me=umh:\
subme=10:psy=1:merange=24:mvrange=511:subq=9:8x8dct=1:trellis=2:no-fast-pskip=1:\
chroma-qp-offset=-2:direct=auto:partitions=all:scenecut=40:cplxblur=20:qblur=0.5:no-mbtree=0" \
-threads 12 /tmp/bluray_x264.mkv -y

libx265
ffmpeg -analyzeduration 2000M -probesize 2000M -fix_sub_duration \
-i bluray:"/path/to/bluray/folder" \
-map_metadata 0 -movflags use_metadata_tags -map 0:v:0 -map 0:a:0 \
-metadata:s:a:0 language=spa -map 0:a:1 -metadata:s:a:1 language=rus \
-map 0:s:0 -metadata:s:s:0 language=eng -map 0:s:1 -metadata:s:s:1 language=spa \
-max_muxing_queue_size 8192 -c copy -codec:v:0 libx265 \
-x265-params "svt=1:ssim=0:psnr=0:pools="*,+":wpp=1:frame-threads=6:pmode=1:\
slices=2:ref=5:limit-refs=0:allow-non-conformance=1:limit-modes=1:\
rect=1:amp=1:fast-intra=0:b-intra=1:tskip-fast=1:rd=5:rd-refine=1:\
rdoq-level=2:tskip=1:rdpenalty=2:ssim-rd=1:max-merge=5:me=star:\
subme=4:merange=57:weightp=1:weightb=1:analyze-src-pics=1:\
constrained-intra=1:splitrd-skip=1:psy-rd=2.0:psy-rdoq=1.0:\
keyint=500:ctu=32:min-cu-size=16:rc-lookahead=120:\
lookahead-slices=2:lookahead-threads=4:b-adapt=2:bframes=8:\
b-pyramid=1:sao=1:tu-intra-depth=3:tu-inter-depth=3:max-tu-size=32:\
limit-tu=2:aq-mode=3:aq-strength=1.0:aq-motion=1:scenecut=40:\
cutree=1:strict-cbr=0:opt-qp-pps=1:opt-ref-list-length-pps=1:\
opt-cu-delta-qp=1" -threads 12 /tmp/bluray_x265.mkv -y

libsvtav1
ffmpeg -analyzeduration 1000M -probesize 1000M -fix_sub_duration \
-i bluray:"/path/to/bluray/folder" \
-map_metadata 0 -movflags use_metadata_tags -map 0:v:0 -map 0:a:0 \
-metadata:s:a:0 language=spa -map 0:a:1 -metadata:s:a:1 language=rus \
-map 0:s:0 -metadata:s:s:0 language=eng -map 0:s:1 -metadata:s:s:1 language=spa \
-max_muxing_queue_size 8192 -c copy -codec:v:0 libsvtav1 \
-la_depth 20 -rc cqp -qp 26 -preset 6 -movflags +faststart \
/tmp/bluray_svtav1.mkv -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment