From d76cf27929e1d22ab79cd30ba546801724ea2a1b Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sat, 21 Dec 2013 23:56:11 +0100 Subject: [PATCH] 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. --- tools/Makefile.am | 8 +++++++- tools/pic2m2v.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tools/pic2m2v.sh diff --git a/tools/Makefile.am b/tools/Makefile.am index 5ee4d5b..b5be652 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -5,5 +5,11 @@ bin_PROGRAMS += spark_fp spark_fp_SOURCES = spark_fp.c endif -bin_PROGRAMS += pic2m2v +# no longer use the compiled code... +noinst_PROGRAMS = pic2m2v pic2m2v_SOURCES = pic2m2v.c + +# ...use the script instead. +# hack... +install-exec-hook: + install -D -m 0755 $(srcdir)/pic2m2v.sh $(DESTDIR)$(bindir)/pic2m2v diff --git a/tools/pic2m2v.sh b/tools/pic2m2v.sh new file mode 100644 index 0000000..a673caa --- /dev/null +++ b/tools/pic2m2v.sh @@ -0,0 +1,40 @@ +#!/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