Skip to content

Commit

Permalink
add fix_timecode
Browse files Browse the repository at this point in the history
intends to set timecode track to 00:00:00;00
  • Loading branch information
dericed committed Jan 13, 2017
1 parent 9f82293 commit cf566c3
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions fix_timecode
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# left 2 stereo mix
VERSION=1.1
unset DEPENDENCIES
DEPENDENCIES=(ffmpeg ffprobe)

SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ;};

_usage(){
echo
echo "$(basename "${0}") ${VERSION}"
echo "This application takes an input video file(s) and produces output that sets the timecode to 00:00:00;00"
echo "Dependencies: ${DEPENDENCIES[@]}"
echo "Usage: $(basename "${0}") file1 [ file2 ...]"
echo
exit
}
[ "${#}" = 0 ] && _usage
_check_dependencies "${DEPENDENCIES[@]}"

_cleanup(){
_log -a "Process quit"
exit 1
}

# local variables
SUFFIX="_timecode0"

trap _cleanup SIGHUP SIGINT SIGTERM

while [ "${*}" != "" ] ; do
SOURCEFILE="${1}"
unset FFMPEG_OPTS
FFMPEG_OPTS+=(-c:v copy)
FFMPEG_OPTS+=(-c:a copy)
FFMPEG_OPTS+=(-map 0:v)
FFMPEG_OPTS+=(-map 0:a)
FFMPEG_OPTS+=(-metadata timecode='00:00:00;00')
EXTENSION=$(echo "${SOURCEFILE##*.}")
echo "s ${SOURCEFILE%.*} s ${SUFFIX} e ${EXTENSION}"
OUTPUT_MOVIE="${SOURCEFILE%.*}${SUFFIX}.${EXTENSION}"
if [ -f "${OUTPUT_MOVIE}" ] ; then
_report -wt "The intended output of $(basename "${0}") already exists. Skipping for now. Please delete ${OUTPUT_MOVIE} and rerun or figure out why you are trying to do this."
else
_report -dt "Generating ${OUTPUT_MOVIE} ... with these options ${FFMPEG_OPTS[*]}"
ffmpeg -i "${SOURCEFILE}" "${FFMPEG_OPTS[@]}" "${OUTPUT_MOVIE}"
_report -dt "$(basename "${0}") is done with $(basename "${SOURCEFILE}")."
fi
shift
done

0 comments on commit cf566c3

Please sign in to comment.