Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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:
# fontcolor=yellow@0.9: box=1: boxcolor=blue@0.6" -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: fontcolor=yellow@0.9" ${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: fontcolor=yellow@0.9" ${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