Skip to content

Instantly share code, notes, and snippets.

@allsey87
Created April 20, 2016 09:08
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 allsey87/c28d2d9db53c0feebc1f7bc881bbf1fc to your computer and use it in GitHub Desktop.
Save allsey87/c28d2d9db53c0feebc1f7bc881bbf1fc to your computer and use it in GitHub Desktop.
Convert images with timestamps in filename to h264 video
#!/bin/bash
WORKING_DIR=temp
OUTPUT=output
#create working directory
if [[ -d $WORKING_DIR ]]
then
echo "Directory '$WORKING_DIR' already exists"
exit
else
mkdir $WORKING_DIR
fi
# create symbolic links
TIME=0
for IMAGE in $(ls *.png | sort -n)
do
IMAGE_TIMESTAMP=$(echo $IMAGE | cut -c 4-9)
while [ $TIME -lt $IMAGE_TIMESTAMP ]
do
ln -s ../$IMAGE $WORKING_DIR/$(echo $TIME | awk -F, '{ printf "%05d\n", $1 }').png
TIME=$(bc <<< $TIME+1)
done
done
# create the sequence
avconv -r 100 -f image2 -i $WORKING_DIR/%05d.png -c:v h264 -tune stillimage -crf 0 $OUTPUT.mp4
# remove working directory
rm -r temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment