muxsa-pngaac2mp4 allow unsafe filenames in .concat
This commit is contained in:
parent
073c5b8cd8
commit
496816ae65
@ -38,41 +38,94 @@
|
|||||||
|
|
||||||
echo "This is muxsa-pngaac2mp4."
|
echo "This is muxsa-pngaac2mp4."
|
||||||
|
|
||||||
OUTFILE="out.mp4"
|
# first, we need to define 3 file names - check command line, then defaults:
|
||||||
if [ "$1" ] ; then
|
# SLIDES_IN - concat multiplexer control file with png slide names
|
||||||
OUTFILE="$1"
|
# AUDIO_IN - one .wav or .m4a sound file, or concat file with several wav/m4a
|
||||||
# make sure that file ends on .mp4
|
# VIDEO_OUT - mp4 output
|
||||||
OUTFILE="${OUTFILE%%.mp4}.mp4"
|
|
||||||
|
while getopts "a:s:o:" OPTION ; do
|
||||||
|
case "$OPTION" in
|
||||||
|
a)
|
||||||
|
if [ -r "$OPTARG" ] ; then
|
||||||
|
AUDIO_IN="$OPTARG"
|
||||||
|
else
|
||||||
|
echo "error: AUDIO_IN file $OPTARG does not exist. abort."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
if [ -r "$OPTARG" ] ; then
|
||||||
|
SLIDES_IN="$OPTARG"
|
||||||
|
else
|
||||||
|
echo "error: SLIDES_IN file $OPTARG does not exist. abort."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
o)
|
||||||
|
VIDEO_OUT="$OPTARG"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Incorrect options provided - ignored"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift "$((OPTIND-1))"
|
||||||
|
# backward compatibility: before getopts we only accepted OUT as parameter
|
||||||
|
if [ -z "$VIDEO_OUT" -a -n "$1" ] ; then
|
||||||
|
VIDEO_OUT="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f slides.concat ] ; then
|
if [ -z "$AUDIO_IN" -a -r "soundtrack.m4a" ] ; then
|
||||||
echo "error: file slides.concat missing. abort."
|
echo "Setting AUDIO_IN to default file name soundtrack.m4a"
|
||||||
echo "consider using muxsa-al2fc for creating one."
|
AUDIO_IN="soundtrack.m4a"
|
||||||
|
fi
|
||||||
|
if [ -z "$AUDIO_IN" -a -r "soundtrack.wav" ] ; then
|
||||||
|
echo "Setting AUDIO_IN to default file name soundtrack.wav"
|
||||||
|
AUDIO_IN="soundtrack.wav"
|
||||||
|
fi
|
||||||
|
if [ -z "$AUDIO_IN" -a -r "audio.concat" ] ; then
|
||||||
|
echo "Setting AUDIO_IN to default file name audio.concat"
|
||||||
|
AUDIO_IN="audio.concat"
|
||||||
|
fi
|
||||||
|
if [ -z "$AUDIO_IN" ] ; then
|
||||||
|
echo "No input audio file given and no default file name found. abort."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f soundtrack.m4a ] ; then
|
if [ -z "$SLIDES_IN" -a -r "slides.concat" ] ; then
|
||||||
AUDIOFILE="-i soundtrack.m4a"
|
echo "Setting SLIDES_IN to default file name slides.concat"
|
||||||
AUDIOOPTS="-c:a copy"
|
SLIDES_IN="slides.concat"
|
||||||
else
|
fi
|
||||||
if [ -f soundtrack.wav ] ; then
|
if [ -z "$SLIDES_IN" ] ; then
|
||||||
AUDIOFILE="-i soundtrack.wav"
|
echo "No input slides file given and no default file name found. abort."
|
||||||
AUDIOOPTS="-c:a aac -b:a 128k"
|
|
||||||
else
|
|
||||||
if [ -f audio.concat ] ; then
|
|
||||||
AUDIOFILE="-f concat -i audio.concat"
|
|
||||||
AUDIOOPTS="-c:a aac -b:a 128k"
|
|
||||||
else
|
|
||||||
echo "neither soundtrack.m4a, .wav, nor audio.concat found. abort."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ffmpeg -f concat -i slides.concat ${AUDIOFILE} \
|
# now we got all input and output file names
|
||||||
|
|
||||||
|
# depending on the type of the audio input, we need to give different options
|
||||||
|
case "${AUDIO_IN##*.}" in
|
||||||
|
m4a|M4A|aac|AAC)
|
||||||
|
AUDIO_SOURCE_OPTS="-i"
|
||||||
|
AUDIO_CODER_OPTS="-c:a copy"
|
||||||
|
;;
|
||||||
|
concat|CONCAT|sequence|SEQUENCE|seq|SEQ)
|
||||||
|
AUDIO_SOURCE_OPTS="-f concat -i"
|
||||||
|
AUDIO_CODER_OPTS="-c:a aac -b:a 128k"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AUDIO_SOURCE_OPTS="-i"
|
||||||
|
AUDIO_CODER_OPTS="-c:a aac -b:a 128k"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# time to start ffmpeg
|
||||||
|
# no "quotes" around the $..._OPTs on purpose
|
||||||
|
set -ex
|
||||||
|
ffmpeg -f concat -safe 0 -i "$SLIDES_IN" $AUDIO_SOURCE_OPTS "$AUDIO_IN" \
|
||||||
-vsync cfr -vf fps=25 \
|
-vsync cfr -vf fps=25 \
|
||||||
-c:v libx264 -preset slow -tune stillimage -crf 23 -pix_fmt yuv420p \
|
-c:v libx264 -preset slow -tune stillimage -crf 23 -pix_fmt yuv420p \
|
||||||
${AUDIOOPTS} \
|
$AUDIO_CODER_OPTS \
|
||||||
-movflags +faststart -brand mp42 "${OUTFILE}"
|
-movflags +faststart -brand mp42 "$VIDEO_OUT"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user