Skip to content

Instantly share code, notes, and snippets.

@Envek
Last active December 19, 2015 05:49
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 Envek/5906850 to your computer and use it in GitHub Desktop.
Save Envek/5906850 to your computer and use it in GitHub Desktop.
Script for creating videos from printed html page. Each printed page — separate videofile.
#!/bin/bash
# Beautiful script, that creates videos from printed html.
# Authors: Andrey Novikov, Olga Kosolapova, Timofey Karev
# Distributed AS IS under terms of MIT License
#
# Required packages:
# wkhtmltopdf : ~> 0.11.rc1
# imagemagick :
# libav || ffmpeg : (with mpeg2video codec)
# openssh-client :
VIDEOBITRATE=5120 # kilobits per second
VIDEOLENGTH=20 # seconds
RESOLUTION=720x576 # ${COLUMNS}x${ROWS}
SOURCE_URL=http://priem.amursu.ru/status
DESTINATION=user@host:/path/to/videos/
# Create PDF (note the wkhtmltopdf binary is in current directory)
echo "Printing HTML to PDF"
./wkhtmltopdf -O Landscape -s A4 --print-media-type -n -L 15mm -R 15mm -q ${SOURCE_URL} status.pdf
echo "Decomposing PDF into separate pages"
convert -density 150 -quality 100 -background white -colorspace CMYK "status.pdf" "faculty.jpg"
rm faculty-10.jpg
echo "Creating video for each page"
for image in faculty-*.jpg; do
bname=$(basename "$image") # filename without path
fname="${bname%.*}" # filename without extension
echo " - ${bname} -> ${fname}.mpg..."
convert -colorspace RGB "$image" "$image"
avconv -y -v quiet -loop 1 -f image2 -i "$image" -c:v mpeg2video -b:v 25000k -t $VIDEOLENGTH "${fname}.mp4"
avconv -y -v quiet -i "${fname}.mp4" -c:v mpeg2video -b:v ${VIDEOBITRATE}k -s:v ${RESOLUTION} -f mpegts "${fname}.mpg"
done
echo "Uploading to the videoserver"
scp faculty-*.mpg ${DESTINATION}
echo "Cleaning up"
rm faculty-*
rm status.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment