Skip to content

Instantly share code, notes, and snippets.

@dhoko
Last active December 1, 2018 16:56
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 dhoko/ebe0084901c42f5e8555c5155d6fdfe8 to your computer and use it in GitHub Desktop.
Save dhoko/ebe0084901c42f5e8555c5155d6fdfe8 to your computer and use it in GitHub Desktop.
Resize a video (mp4/wmv) to HD (720p)
#!/bin/bash
set -eo pipefail
FILENAME=$(basename -- "$1");
EXT="${FILENAME##*.}";
NAME="${FILENAME%.*}";
OUTPUT=$(echo "$NAME-2.$EXT");
echo $FILENAME;
echo $OUTPUT;
if [[ "$EXT" = "wmv" ]]; then
ffmpeg -i "$FILENAME" -s hd720 -c:v libx264 -crf 23 -c:a aac -strict -2 "$NAME.mp4";
else
ffmpeg -i "$FILENAME" -filter:v scale=1280:-1 -c:a copy "$OUTPUT";
fi
@dhoko
Copy link
Author

dhoko commented Dec 1, 2018

if the height is not /2 there is this version

#!/bin/bash
set -eo pipefail

FILENAME=$(basename -- "$1");
EXT="${FILENAME##*.}";
NAME="${FILENAME%.*}";
OUTPUT=$(echo "$NAME-2.$EXT");

echo $FILENAME;
echo $OUTPUT;

if [[ "$EXT" = "wmv" ]]; then
    ffmpeg -i "$FILENAME" -s hd720 -c:v libx264 -crf 23 -c:a aac -strict -2 "$NAME.mp4";
else
    ffmpeg -i "$FILENAME" -filter:v scale=1280:-2 -c:a copy "$OUTPUT";
fi

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