independet of where the videos are located

This commit is contained in:
soulgalore 2017-04-27 08:28:44 +02:00
parent 3c23e975d8
commit 5ca3d4cf96
1 changed files with 19 additions and 14 deletions

View File

@ -1,8 +1,6 @@
#! /bin/bash
# Combine two videos and slow down the result
# make sure the files are in the same dir as this script since we
# mount the current dir in Docker
if [[ -z $1 || -z $2 ]]; then
echo "Missing input parameters"
@ -10,31 +8,38 @@ if [[ -z $1 || -z $2 ]]; then
exit 1
fi
FILE1="$1"
FILE2="$2"
if [ ! -f "$1" ] || [ ! -f "$2" ] ; then
echo "File $1 or $2 not found!"
exit 1
fi
TMP_VIDEO_DIR=tmp-video
FILE1=$(basename $1)
FILE2=$(basename $2)
OUTPUT_FILE=${3:-output_slow.mp4}
SLOWDOWN=5.0
if [ ! -f "$FILE1" ] || [ ! -f "$FILE2" ] ; then
echo "File $FILE1 or $FILE2 not found!"
exit 1
fi
# Move the videos to a tmp dir so it is easy to mount them in Docker
mkdir $TMP_VIDEO_DIR
cp $1 $TMP_VIDEO_DIR
cp $2 $TMP_VIDEO_DIR
echo "Combining $FILE1 with $FILE2"
docker run -v "$(pwd)":/video sitespeedio/visualmetrics-deps ffmpeg \
-i "/video/$FILE1" \
-i "/video/$FILE2" \
-i "/video/$TMP_VIDEO_DIR/$FILE1" \
-i "/video/$TMP_VIDEO_DIR/$FILE2" \
-filter_complex '[0:v]pad=iw*2:ih[int];[int][1:v]overlay=W/2:0[vid]' \
-map [vid] \
-c:v libx264 \
-crf 23 \
-preset veryfast \
/video/output.mp4 > /dev/null 2>&1
/video/$TMP_VIDEO_DIR/output.mp4 > /dev/null 2>&1
echo "Slow down the video"
docker run -v "$(pwd)":/video sitespeedio/visualmetrics-deps ffmpeg -i /video/output.mp4 -filter:v "setpts=$SLOWDOWN*PTS" /video/${OUTPUT_FILE} > /dev/null 2>&1
rm output.mp4
docker run -v "$(pwd)":/video sitespeedio/visualmetrics-deps ffmpeg -i /video/$TMP_VIDEO_DIR/output.mp4 -filter:v "setpts=$SLOWDOWN*PTS" /video/${OUTPUT_FILE} > /dev/null 2>&1
# Cleanup
rm -fR $TMP_VIDEO_DIR
echo "Combined and slowed down video $OUTPUT_FILE"
echo "Combined and slowed down video: $OUTPUT_FILE"