Skip to content

Instantly share code, notes, and snippets.

@lene
Last active August 30, 2022 11:38
Show Gist options
  • Save lene/0573537444abe4be6b2ca9b9358f65d1 to your computer and use it in GitHub Desktop.
Save lene/0573537444abe4be6b2ca9b9358f65d1 to your computer and use it in GitHub Desktop.
re-encode videos to H.265, specifying source and target container format (fish shell)
set FROM_EXT mp4
set TO_EXT mkv
set ABR 128k
set CRF 22
for i in *.$FROM_EXT
set BASENAME (basename $i .$FROM_EXT)
set DIRNAME (dirname $i)
nice -n 19 time ffmpeg -i "$DIRNAME/$BASENAME.$FROM_EXT" -vcodec libx265 -crf $CRF -ac 2 -c:a libmp3lame -b:a $ABR output.$TO_EXT; and \
mv output.$TO_EXT "$DIRNAME/$BASENAME.$TO_EXT"; and \
rm "$i"
end
@lene
Copy link
Author

lene commented Aug 30, 2022

Audio is recoded too - target audio is hardcoded to mp3 stereo here (-ac 2: 2 channels, -c:a libmp3lame: use mp3lame encoder for audio).

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