Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
snippets/ffsubshot/ffsubshot
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
28 lines (20 sloc)
655 Bytes
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 | |
# ffsubshot: Take a screenshot at the given timestamp, with subtitles. | |
set -eo pipefail | |
# By default, assume subtitles are baked into the input. | |
# Users can override this to use an external subtitle file. | |
SUB_FILE="${SUB_FILE:-${1}}" | |
function help { | |
echo "Usage: ffsubshot <input> <timestamp> <output>" | |
exit | |
} | |
function installed { | |
cmd=$(command -v "${1}") | |
[[ -n "${cmd}" ]] && [[ -f "${cmd}" ]] | |
return ${?} | |
} | |
[[ $# -eq 3 && -f $1 && -n $2 && ! -f $3 ]] || help | |
installed ffmpeg || { >&2 echo "Missing ffmpeg."; exit 1; } | |
ffmpeg -ss "${2}" -copyts \ | |
-i "${1}" -vf subtitles="${SUB_FILE}" \ | |
-vframes 1 "${3}" |