Created
April 24, 2020 11:19
-
-
Save henrydatei/bb2da87a8d41cdf5d346ed8a9c9c0ec7 to your computer and use it in GitHub Desktop.
Make a video from an ppsx file
This file contains 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 | |
#passende Ordner erstellen | |
read -p "Nummer der Vorlesung " nummer | |
mkdir -p Einzelseiten | |
mkdir -p Einzelseiten/VL$nummer | |
mkdir -p Einzelseiten/VL$nummer/audio | |
mkdir -p Einzelseiten/VL$nummer/jpg | |
mkdir -p Einzelseiten/VL$nummer/pdf | |
mkdir -p Einzelseiten/VL$nummer/png | |
mkdir -p Einzelseiten/VL$nummer/video | |
mkdir -p decrypt | |
# check if file is decrypted | |
if msoffcrypto-tool "$1" --test; then | |
#decrypt ppsx (https://github.com/nolze/msoffcrypto-tool) | |
read -p "Password: " pass | |
msoffcrypto-tool "$1" decrypted.ppsx -p $pass | |
else | |
# just rename | |
cp "$1" decrypted.ppsx | |
fi | |
# pdf erstellen -> decrypted.pdf | |
libreoffice --headless --convert-to pdf decrypted.ppsx | |
# pdf split pages | |
pdftk decrypted.pdf burst output Einzelseiten/VL$nummer/pdf/slide%d.pdf | |
# convert to png | |
ls ./Einzelseiten/VL$nummer/pdf/*.pdf | xargs -L1 -I {} inkscape {} -z --export-dpi=300 --export-area-drawing --export-png={}.png | |
mv ./Einzelseiten/VL$nummer/pdf/*.png ./Einzelseiten/VL$nummer/png | |
# convert to jpg | |
ls ./Einzelseiten/VL$nummer/png/*.png | xargs -L1 -I {} convert {} -quality 100 -density 300 {}.jpg | |
mv ./Einzelseiten/VL$nummer/png/*.jpg ./Einzelseiten/VL$nummer/jpg | |
# copy audio files to /audio | |
cp decrypted.ppsx decrypted.zip | |
unzip decrypted.zip -d decrypt | |
mv ./decrypt/ppt/media/media*.m4a ./Einzelseiten/VL$nummer/audio | |
# rename audio files matching slides | |
cd decrypt/ppt/slides/_rels | |
for f in $(ls); do | |
if grep -q "m4a" "$f"; then | |
slideNummer=$(echo "$f" | cut -d"." -f1 | cut -c 6-) | |
mediaFile=$(grep -o -E "media[[:digit:]]*.m4a" "$f" | head -n 1 | cut -d "." -f1 | cut -c 6-) | |
echo "Found Media (Audio-File $mediaFile) in $f (Slide $slideNummer)" | |
mv ../../../../Einzelseiten/VL$nummer/audio/media$mediaFile.m4a ../../../../Einzelseiten/VL$nummer/audio/audio$slideNummer.m4a | |
fi | |
done | |
cd ../../../.. | |
# Einzelfolien mit Audio kreieren | |
cd Einzelseiten/VL$nummer/audio/ | |
for f in $(ls); do | |
slideNummer=$(echo "$f" | cut -d"." -f1 | cut -c 6-) | |
ffmpeg -i ../jpg/slide$slideNummer.pdf.png.jpg -i audio$slideNummer.m4a -c:v mjpeg -c:a copy -pix_fmt yuv420p ../video/$slideNummer.mp4 | |
#echo "file './Einzelseiten/VL$nummer/video/$slideNummer.mp4'" >> ../../../list.txt | |
done | |
cd ../../.. | |
# Liste erstellen | |
cd Einzelseiten/VL$nummer/video/ | |
for f in $(ls); do | |
slideNummer=$(echo "$f" | cut -d"." -f1) | |
echo "$slideNummer" >> numbers.txt | |
done | |
sort -n numbers.txt >> numbers_sorted.txt | |
while read line; do | |
echo "file './Einzelseiten/VL$nummer/video/$line.mp4'" >> ../../../list.txt | |
done < numbers_sorted.txt | |
cd ../../.. | |
# Merge Einzelvideos | |
ffmpeg -f concat -safe 0 -i list.txt -c copy VL$nummer.mp4 | |
# cleanup | |
rm -rf decrypt | |
rm decrypted.pdf | |
rm decrypted.ppsx | |
rm decrypted.zip | |
rm list.txt |
MP4 isn't super slow to generate as I'm using -c copy
to copy the whole stream and not reencoding it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, interesting! I've made something similar recently, but using python. I've made it available online: https://becausecurious.me/ppsx_to_video/. Also I found mp4 to be super slow to generate, so I switched to flv. This decreased time to generate a video 50x.