Skip to content

Instantly share code, notes, and snippets.

@considine
Last active November 10, 2022 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save considine/6a59219af068f123fc17d22eb812978a to your computer and use it in GitHub Desktop.
Save considine/6a59219af068f123fc17d22eb812978a to your computer and use it in GitHub Desktop.
#! /bin/bash
MY_DIR=$PWD
if [[ $# -lt 2 ]]; then
echo 'Please provide two timestamps of the format hh:mm:ss. The first is where you want a "Before" frame, and the second is where you want an "After" frame'
exit 0
fi
if [[ $# -lt 3 ]]; then
echo 'please provide the path to an mp4 file'
exit 0
fi
cd /tmp
DATE_PATH="$(date +'%m-%d-%y-%H-%M-%S')"
mkdir $DATE_PATH
cd $DATE_PATH
# bring in before nand after
curl -L https://www.dropbox.com/s/cl53unjslxtqq7b/before.mp4\?dl\=0 >before.mp4
curl -L https://www.dropbox.com/s/on18roo0l2jzoqi/after.mp4?dl=0 >after.mp4
if [ ! -f $3 ]; then
echo "File not found!"
exit 1
fi
echo $1
echo $2
echo $3
# # create three videos. Start and
ffmpeg -hide_banner -loglevel error -ss 00:00:00 -i $3 -c copy -to $1 frame-1.mp4
ffmpeg -hide_banner -loglevel error -ss $1 -i $3 -c copy -to $2 frame-2.mp4
ffmpeg -hide_banner -loglevel error -ss $2 -i $3 -c copy -to 99:00:00 frame-3.mp4
# ls -l
# Concatenate these three
echo file "frame-1.mp4" >concat.txt
echo file "before.mp4" >>concat.txt
echo file "frame-2.mp4" >>concat.txt
echo file "after.mp4" >>concat.txt
echo file "frame-3.mp4" >>concat.txt
ffmpeg -hide_banner -loglevel error -f concat -safe 0 -i concat.txt -c copy output.mp4 >>/dev/null
mv output.mp4 $MY_DIR
echo $MY_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment