Last active
December 19, 2015 05:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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