Skip to content

Instantly share code, notes, and snippets.

@skulumani
Created February 2, 2021 14:50
Show Gist options
  • Save skulumani/9ffd788062644abc539cf934e9b538c3 to your computer and use it in GitHub Desktop.
Save skulumani/9ffd788062644abc539cf934e9b538c3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Take a bunch of images and draw an overlay, then form a video
#
# Some useful links:
# https://superuser.com/questions/717103/burn-filenames-of-single-images-into-ffmpeg-output-videou
# https://stackoverflow.com/questions/24961127/how-to-create-a-video-from-images-with-ffmpeg
# https://video.stackexchange.com/questions/21905/how-to-set-pts-time-format-when-using-ffmpeg-filter-to-add-timestamp
# https://video.stackexchange.com/questions/12105/add-an-image-overlay-in-front-of-video-using-ffmpeg
# https://itimagination.com/ffmpeg-image-sequence-video-date-overlay-based-timestamps/
# form some directories
if [ ! -d ./corrected ]; then
mkdir -p ./corrected;
fi
if [ ! -d ./uncorrected ]; then
mkdir -p ./uncorrected;
fi
# Example command for overlay
# ffmpeg -i video.mkv -filter_complex "drawtext=fontfile=/Library/Fonts/Arial.ttf:
# text='timestamp: %{pts \: hms}': x=5: y=5: fontsize=24:
# [email protected]: box=1: [email protected]" -c:a copy -c:v libx264 -map 0 output.mkv
# corrected images
for infile in *_ms.jpg; do
overlay=$(echo ${infile} | cut -d . -f 1)
outfile="./corrected/mod_${overlay}.jpg"
echo "Input File: $infile Output File: $outfile"
ffmpeg -i ${infile} -vf "drawtext=text=${infile}: x=5: y=5: fontsize=24: [email protected]" ${outfile}
done
ffmpeg -framerate 24 -pattern_type glob -i './corrected/*.jpg' -c:v libx264 -r 30 -pix_fmt yuv420p corrected.mp4
# uncorrected
for infile in *_ms_uncorrected.jpg; do
overlay=$(echo ${infile} | cut -d . -f 1)
outfile="./uncorrected/mod_${overlay}.jpg"
echo "Input File: $infile Output File: $outfile"
ffmpeg -i ${infile} -vf "drawtext=text=${infile}: x=5: y=5: fontsize=24: [email protected]" ${outfile}
done
ffmpeg -framerate 24 -pattern_type glob -i './uncorrected/*.jpg' -c:v libx264 -r 30 -pix_fmt yuv420p uncorrected.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment