Skip to content

Instantly share code, notes, and snippets.

@ximeg
Last active June 17, 2022 05:04
Show Gist options
  • Save ximeg/7e20096121efab07052154e990640523 to your computer and use it in GitHub Desktop.
Save ximeg/7e20096121efab07052154e990640523 to your computer and use it in GitHub Desktop.
.bashrc parallel ffmpeg video tools
# Video encoding. Arguments to ffmpeg should be passed in quotes
# Example
# ls *.avi | ff_avi2webm "-filter:v 'crop=in_w-100:in_h/2'"
ff_any2webm(){
parallel ffmpeg -i {} $1 -c:v vp9 {.}.webm
}
ff_whatsapp(){
# Convert specified videos to mp4 that are compatible with whatsapp
parallel ffmpeg -i {} $1 -c:v libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p {.}-whatsapp.mp4
}
# https://unix.stackexchange.com/a/437044
ff_side_by_side(){
# Takes two input files in any format and places them side by side, output in webm format
ffmpeg -i "$1" -i "$2" -filter_complex "[0:v][1:v]hstack=inputs=2[v]" -map "[v]" -c:v vp9 "$3".webm
}
# https://stackoverflow.com/a/33764934
ff_side_by_side4(){
# Takes two pairs of files in any format, makes vertical pairs, and places them side by side, output in VP9 webm format
ffmpeg -i $1 -i $2 -i $3 -i $4 -filter_complex "[0:v][1:v]hstack=inputs=2[top];[2:v][3:v]hstack=inputs=2[bottom];[top][bottom]vstack=inputs=2[v]" -map "[v]" -c:v vp9 "$5".webm
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment