-
Notifications
You must be signed in to change notification settings - Fork 27
/
fix_rewrap
executable file
·58 lines (49 loc) · 1.68 KB
/
fix_rewrap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# this script takes one argument which is a video file. It then rewraps it to make a new file.
# version 1.2 swap from ffmbc to ffmpeg
VERSION=1.2
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 outputs through re-multiplexing all tracks of the input into a new container."
echo "Dependencies: ${DEPENDENCIES[@]}"
echo "Usage: $(basename "${0}") file1 [ file2 ...]"
echo
exit
}
[ "${#}" = 0 ] && _usage
_check_dependencies "${DEPENDENCIES[@]}"
_cleanup(){
_log -a "Process aborted"
exit 1
}
# local variables
SUFFIX="_rewrap"
trap _cleanup SIGHUP SIGINT SIGTERM
_log -b
while [ "${*}" != "" ] ; do
SOURCEFILE="${1}"
NAME=$(basename "${SOURCEFILE}")
_get_codectagstring
unset FFMPEG_OPTS
FFMPEG_OPTS+=(-map 0:v -map 0:a -c:v copy -c:a copy)
if [ "${CODEC_TAG_STRING}" = "mpeg" ] ; then
EXTENSION="mxf"
else
EXTENSION="mov"
fi
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 ${NAME}."
fi
shift
done
_log -e