Skip to content

Instantly share code, notes, and snippets.

@errkk
Last active December 21, 2015 08:38
Show Gist options
  • Save errkk/6279024 to your computer and use it in GitHub Desktop.
Save errkk/6279024 to your computer and use it in GitHub Desktop.
Composite a PNG over an input video frame by frame
avconv -i input.mp4 -f image2 frames/f_%00d.jpg
for F in $(ls frames/)
do
composite -compose atop -gravity SouthWest overlay_frame.png frames/$F out/$F
done
avconv -f image2 -i out/f_%00d.jpg out.mpeg -b 2400kb
ffmpeg -i input.mp4 -i yorkshire_seq/f_%03d.png -filter_complex overlay=0:0 -q:v 1 -f mpeg tmp.mpeg &&
ffmpeg -i tmp.mpeg -loop 1 -i frame.png -filter_complex overlay=0:0 -shortest -acodec aac -strict -2 out.mpeg &&
rm tmp.mpeg
echo 'Numbering frames from 181'
COUNTER=181
for F in $(ls yorkshire_seq/)
do
echo $F
mv yorkshire_seq/$F yorkshire_seq/f_$(printf "%03g" $COUNTER).png
COUNTER=$((COUNTER+1))
done
echo 'Filling preceding frames with copy of the first one'
COUNTER=0
while [ $COUNTER -lt 181 ]
do
cp yorkshire_seq/f_181.png yorkshire_seq/f_$(printf "%03g" $COUNTER).png
COUNTER=$((COUNTER+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment