Created
April 6, 2018 14:33
-
-
Save TylerTemp/36095340c37619e6c854ecb517449365 to your computer and use it in GitHub Desktop.
Converting video to webm/ogv by ffmpeg. You need to install ffmpeg first like `apt-get install ffmpeg`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
#-*- coding: utf-8 -*- | |
set -e | |
source_file="$1" | |
# echo "$source_file" | |
format="$2" | |
echo 1 "$format" | |
target_dir=$(dirname "$source_file") | |
filename=$(basename "$source_file") | |
echo "filename: $filename" | |
echo "folder: $target_dir" | |
# echo $filename | |
# # extension="${filename##*.}" | |
basename="${filename%.*}" | |
# | |
#echo "$source_file -> $basename.$format" | |
echo 2 $format | |
if [[ "$format" == "ogv" ]]; then | |
echo 3 ogv | |
elif [[ "$format" == "webm" ]]; then | |
echo 3 webm | |
fi | |
# exit | |
if [[ $format == "ogv" ]]; then | |
ffmpeg -i "$source_file" -c:v libtheora -c:a libvorbis -q:v 6 -q:a 5 "$target_dir/$basename.ogv" | |
elif [[ $format == "webm" ]]; then | |
ffmpeg -i "$source_file" -codec:v libvpx -quality good -cpu-used 0 -b:v 500k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -threads 4 -vf scale=-1:-1 -codec:a libvorbis -b:a 128k "$target_dir/$basename.webm" | |
else | |
echo "Usage: $0 <file> (ogv|webm)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment