2024-09-17 12:27:52 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
# Neural Network Deinterlacer weights file
|
|
|
|
|
NNEDI_WEIGHTS="/usr/share/nnedi3/nnedi3_weights.bin"
|
|
|
|
|
# Constant Rate Factor / Global Quality
|
|
|
|
|
CRF=18
|
|
|
|
|
# Encoding Preset. Veryslow == TU1 QSV
|
|
|
|
|
PRESET=veryslow
|
|
|
|
|
# Lookahead depth, used for QSV h.264
|
|
|
|
|
LA_DEPTH=40
|
|
|
|
|
|
|
|
|
|
# PAL, high, nnedi3
|
|
|
|
|
PAL_VFILTERS="-color_primaries bt470bg -color_trc gamma28 -colorspace bt470bg -vf nnedi=weights=${NNEDI_WEIGHTS}:nns=n128 -c:v libx265 -preset ${PRESET} -crf ${CRF} -x265-params aq-mode=3:aq-strength=0.9:psy-rd=1.2:deblock=-1,-1,level=4.1:colorprim=bt470bg:transfer=bt470bg:colormatrix=bt470bg:limit-sao=1 -pix_fmt yuv420p10le"
|
|
|
|
|
|
|
|
|
|
# NTSC, high, nnedi3
|
|
|
|
|
NTSC_VFILTERS="-color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -vf nnedi=weights=${NNEDI_WEIGHTS}:nns=n128 -c:v libx265 -preset ${PRESET} -crf ${CRF} -x265-params aq-mode=3:aq-strength=0.9:psy-rd=1.2:deblock=-1,-1,level=4.1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:limit-sao=1 -pix_fmt yuv420p10le"
|
|
|
|
|
|
|
|
|
|
# NTSC, high, HQ Yadif
|
|
|
|
|
YNTSC_VFILTERS="-color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -vf yadif=0:deint=0 -c:v libx265 -preset ${PRESET} -crf ${CRF} -x265-params aq-mode=3:aq-strength=0.9:psy-rd=1.2:deblock=-1,-1,level=4.1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:limit-sao=1 -pix_fmt yuv420p10le"
|
|
|
|
|
|
|
|
|
|
# NTSC, high, ivtc
|
|
|
|
|
IVTC_VFILTERS="-color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m -vf fieldmatch,yadif=deint=interlaced,decimate -c:v libx265 -preset ${PRESET} -crf ${CRF} -x265-params aq-mode=3:aq-strength=0.9:psy-rd=1.2:deblock=-1,-1,level=4.1:colorprim=smpte170m:transfer=smpte170m:colormatrix=smpte170m:limit-sao=1 -pix_fmt yuv420p10le"
|
|
|
|
|
|
|
|
|
|
# Intel QSV, TU1, Rate control: ICQ, LA_ICQ (not yet) supported, but suggested for future-proofness...
|
|
|
|
|
QSV_VFILTERS="-c:v hevc_qsv -preset ${PRESET} -global_quality:v ${CRF} -look_ahead:v 1 -g 251"
|
|
|
|
|
|
|
|
|
|
# Intel QSV h.264, TU1, Rate control: LA_ICQ
|
|
|
|
|
QSV_AVC_VFILTERS="-c:v h264_qsv -preset ${PRESET} -global_quality:v ${CRF} -look_ahead:v 1 -look_ahead_depth ${LA_DEPTH} -extra_hw_frames ${LA_DEPTH} -g 251"
|
|
|
|
|
|
|
|
|
|
# Copy All Audio streams
|
2024-09-17 12:30:26 +02:00
|
|
|
#AFILTERS="-c:a copy -map 0"
|
2024-09-17 12:27:52 +02:00
|
|
|
|
|
|
|
|
# Lossless Compression
|
2024-09-17 12:30:26 +02:00
|
|
|
AFILTERS="-c:a flac -compression_level:a 12"
|
2024-09-17 12:27:52 +02:00
|
|
|
|
|
|
|
|
# Lossy, not compatible with players, transparent
|
|
|
|
|
#AFILTERS="-c:a libopus -b:a 192k"
|
|
|
|
|
|
|
|
|
|
# Lossy, most compatible, low quality
|
|
|
|
|
# AFILTERS=""
|
|
|
|
|
|
|
|
|
|
PAL_FILTERS="${PAL_VFILTERS} ${AFILTERS}"
|
|
|
|
|
NTSC_FILTERS="${NTSC_VFILTERS} ${AFILTERS}"
|
|
|
|
|
YNTSC_FILTERS="${YNTSC_VFILTERS} ${AFILTERS}"
|
|
|
|
|
IVTC_FILTERS="${IVTC_VFILTERS} ${AFILTERS}"
|
|
|
|
|
QSV_FILTERS="${QSV_VFILTERS} ${AFILTERS}"
|
|
|
|
|
QSV_AVC_FILTERS="${QSV_AVC_VFILTERS} ${AFILTERS}"
|
|
|
|
|
|
|
|
|
|
# Conversion sous-titres
|
|
|
|
|
#ffmpeg -sub_charenc UTF-8 -i ep01.srt ep01.ass
|
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
|
echo "Usage: $0 infile outfile"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
ffmpeg -i "$1" ${QSV_FILTERS} "$2"
|