As it turns out, Piwigo and AVI files don’t play nicely together. So, I shamelessly ripped off this thread, and wrote a script to automatically convert my camcorder’s AVI files into MP4 videos and put them into my gallery:

#!/bin/bash

echo "Converting videos..."
cd /home/alaskalinuxuser/Videos/
for i in *.avi; do ffmpeg -i "$i" -c:a aac -strict -2 -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done
for i in *.AVI; do ffmpeg -i "$i" -c:a aac -strict -2 -b:a 128k -c:v libx264 -crf 20 "${i%.avi}.mp4"; done

echo "Moving videos..."
mv /home/alaskalinuxuser/Videos/*.mp4 /var/www/html/galleries/camcorder/
cd /home/alaskalinuxuser/Videos/
rm -rf *

chown -R apache:apache /var/www/html/galleries/
echo "Changed owndership"

.....EDITED OTHER FUNCTIONS THAT ARE SPECIFIC TO MY PIWIGO SERVER IMPLEMENTATION.....

exit

Note the double quotes, I learned that this is important because single quotes will not properly handle some characters and spaces in file names. As it turns out, the camcorder we have does not allow you to change the naming convention, nor to use anything other than AVI as the video format.

Linux – keep it simple.

Leave a Reply

Your email address will not be published.