Last active
August 29, 2015 13:55
-
-
Save mislav/8723348 to your computer and use it in GitHub Desktop.
ffmpeg wrapper script to transcode select portions of original file as h264. WARNING: I have no idea what I'm doing [insert dog meme here]
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
#!/bin/bash | |
# Usage: h264 <infile> <HH:MM:SS-HH:MM:SS> [<outfile>] | |
set -e | |
infile="$1" | |
fromto="$2" | |
if [ -n "$3" ]; then | |
outfile="$3" | |
else | |
outfile="${infile%.*}.mov" | |
fi | |
seconds() { | |
local parts=( ${1//:/ } ) | |
while [ "${#parts[@]}" -lt 3 ]; do parts=( 0 ${parts[*]} ); done | |
echo $(( parts[2] + parts[1] * 60 + parts[0] * 3600 )) | |
} | |
from="$(seconds "${fromto%-*}")" | |
to="$(seconds "${fromto#*-}")" | |
duration=$(( to - from )) | |
exec ffmpeg -loglevel warning -ss "$from" -i "$infile" -to "$duration" "$outfile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment