Skip to content

Instantly share code, notes, and snippets.

@zipizap
Created August 17, 2014 09:01
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 zipizap/05dbfbb93b3486186287 to your computer and use it in GitHub Desktop.
Save zipizap/05dbfbb93b3486186287 to your computer and use it in GitHub Desktop.
compress a video using avconv
#!/bin/bash
[[ -r $1 ]] || { echo "Usage: $0 <videofile-to-be-resized> [<videofile2> ...]"; exit 1; }
for INPUT_FILE in "$@"; do
OUTPUT_MP4_FILE=$(echo "$INPUT_FILE" | sed 's/\.[^.]*$/_resized.mp4/g')
#See https://trac.ffmpeg.org/wiki/x264EncodingGuide
avconv -y -i "$INPUT_FILE" -threads auto -c:v libx264 -preset medium -b:v 988k -pass 1 -an -f mp4 /dev/null && \
avconv -i "$INPUT_FILE" -threads auto -c:v libx264 -preset medium -b:v 988k -pass 2 -c:a libmp3lame -b:a 192k "$OUTPUT_MP4_FILE"
rm -f av2pass* &>/dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment