Skip to content

Instantly share code, notes, and snippets.

@ip413
Last active December 2, 2020 07:32
Show Gist options
  • Save ip413/abd15f37ab0324dc321c509390e8166a to your computer and use it in GitHub Desktop.
Save ip413/abd15f37ab0324dc321c509390e8166a to your computer and use it in GitHub Desktop.
Resize video to 720p MP4 with sharpen effect
#!/bin/bash
if [ -z "$1" ]
then echo "
File name to process required. File name shouldn't contain any whitespace chars.
If you want to limit cpu use for example:
cpulimit -e ffmpeg -l 200 # every thread has 100 'points'
"
else
# This line is used for testing small chunks of the file
#ffmpeg -i $1 -ss 00:01:00 -to 00:01:10 -vf scale=-1:720,unsharp=3:3:1 -c:v libx264 -crf 29 -preset medium -c:a copy "$1-2.mkv" &&
ffmpeg -i $1 -vf scale=-1:720,unsharp=3:3:1 -c:v libx264 -crf 27 -preset fast -c:a copy "$1-2.mkv" &&
# mkv from ffmpeg seems to have some issue with seeking, mp4 is fine
ffmpeg -i "$1-2.mkv" -vcodec copy -acodec copy "$1.mp4" &&
rm "$1-2.mkv" &&
rename 's/\.mkv//' "$1.mp4";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment