Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LukasKnuth/40c53447ff0c980297c010939a6b9cdd to your computer and use it in GitHub Desktop.
Save LukasKnuth/40c53447ff0c980297c010939a6b9cdd to your computer and use it in GitHub Desktop.
Encode to H265, no quality loss
#!/bin/bash
function encode {
# Add a "?" at the end of a "map" to say "if available"
# For a preview: add "-ss 0" before "-i" and "-t 120" before the output file. This gives a 2min sample
ffmpeg -hide_banner \
-i "$1" \
-map_metadata 0 \
-map_chapters 0 \
-metadata title="$2" \
-map 0 \
-map 0:s? \
-c copy \
-c:v libx265 -preset ultrafast -x265-params \
crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 \
"out/$3.1080p.h265.DTS.mkv"
}
function encode720 {
# Add a "?" at the end of a "map" to say "if available"
# On "-vf scale", the -n says "fit aspect ratio". The n says "but correct to have choosen number be dvisible by this number"
ffmpeg -hide_banner \
-i "$1" \
-vf scale=-2:720 \
-map_metadata 0 \
-map_chapters 0 \
-metadata title="$2" \
-map 0 \
-map 0:s? \
-c copy \
-c:v libx265 -preset ultrafast -x265-params \
crf=22:qcomp=0.8:aq-mode=1:aq_strength=1.0:qg-size=16:psy-rd=0.7:psy-rdoq=5.0:rdoq-level=1:merange=44 \
"out/$3.720p.h265.DTS.mkv"
}
date
echo "---------- START -------------"
encode "file.mkv" "Movie Title (20xx)" "file_name"
echo "---------- END ---------------"
date
#shutdown -h now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment