Files
libstb-hal/tools/pic2m2v.sh
Stefan Seyfried d76cf27929 pic2m2v: implement as a script
The C code was only calling ffmpeg binary anyway...
Additionally create a md5 sum of the input file to avoid
unnecessary conversions.
2013-12-21 23:56:11 +01:00

41 lines
891 B
Bash

#!/bin/sh
#
# creates still-mpegs from pictures, to be able to display them
# using a hardware video decoder. Does about the same as pic2m2v.c
# (C) 2013 Stefan Seyfried
# License: GPLv2+
#
if grep -q TRIPLEDRAGON /proc/cpuinfo; then
RES=704x576
else
RES=1280x720
fi
while true; do
IN=$1
test -z "$IN" && break
shift
OUT="/var/cache/`echo ${IN#/}|sed 's@/@.@g'`"
MD5=${OUT}.md5
M2V=${OUT}.m2v
# $MD5 not existing => return code != 0
if [ -s $M2V ] && md5sum -c -s $MD5 > /dev/null 2>&1; then
echo "$IN is unchanged"
touch -r $IN $M2V
continue
fi
if ! [ -e $IN ]; then
echo "$IN does not exist!"
continue
fi
echo "converting $IN -> $M2V"
ffmpeg -v 31 -y -f mjpeg -i $IN -s $RES $M2V < /dev/null
if ! [ -s $M2V ]; then
echo "$M2V does not exist - conversion error?"
continue
fi
# set the time identical to input file
touch -r $IN $M2V
md5sum $IN > $MD5
done