Skip to content

Instantly share code, notes, and snippets.

@numpde
Last active October 6, 2021 08:26
Show Gist options
  • Save numpde/31e1726dcce83cf10b7d429051578b07 to your computer and use it in GitHub Desktop.
Save numpde/31e1726dcce83cf10b7d429051578b07 to your computer and use it in GitHub Desktop.
Nautilus script: compress mp4 file
#!/bin/bash
function x {
mv "$1" "$1.original.mp4"
ffmpeg -i "$1.original.mp4" -vcodec libx264 -crf 40 "$1" -vf scale=640:-1 -preset veryslow \
&& mv "$1.original.mp4" "$1.done.mp4"
notify-send "$1 compression done."
}
# https://stackoverflow.com/questions/11003418/calling-shell-functions-with-xargs
export -f x
echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | xargs -I {} bash -c 'x "$@"' _ {}
# Put in ~/.local/share/nautilus/scripts/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment