From 824c35104fef735d5d45eab4c38e2dfd074e6a15 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 11 Nov 2012 16:53:18 +0100 Subject: [PATCH] add pic2m2v for bulk-creating the still-mpegs Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/1466524bc512b23f924983f9c9e58b3779a757b1 Author: Stefan Seyfried Date: 2012-11-11 (Sun, 11 Nov 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- tools/Makefile.am | 3 ++ tools/pic2m2v.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tools/pic2m2v.c diff --git a/tools/Makefile.am b/tools/Makefile.am index 3e83dba..5ee4d5b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -4,3 +4,6 @@ if BOXTYPE_SPARK bin_PROGRAMS += spark_fp spark_fp_SOURCES = spark_fp.c endif + +bin_PROGRAMS += pic2m2v +pic2m2v_SOURCES = pic2m2v.c diff --git a/tools/pic2m2v.c b/tools/pic2m2v.c new file mode 100644 index 0000000..d99ddc1 --- /dev/null +++ b/tools/pic2m2v.c @@ -0,0 +1,85 @@ +/* + * (C) 2012 Stefan Seyfried + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include + +#if HAVE_TRIPLEDRAGON +#define TARGETRES "704x576" +#else +#define TARGETRES "1280x720" +#endif + +int main(int argc, char **argv) +{ + char destname[512]; + char cmd[512]; + char *p; + char *fname; + struct stat st, st2; + + if (argc < 2) + { + fprintf(stderr, "usage: pic2m2v /path/pic1.jpg [/path/pic2.jpg...]\n\n"); + return 1; + } + strcpy(destname, "/var/cache"); + mkdir(destname, 0755); + argv++; + for (fname = *argv; fname != NULL; fname = *++argv) + { + if (stat(fname, &st2)) + { + fprintf(stderr, "pic2m2v: could not stat '%s' (%m)\n", fname); + continue; + } + strcpy(destname, "/var/cache"); + /* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg): + /var/cache/share.tuxbox.neutrino.icons.radiomode.jpg.m2v + build that filename first... + TODO: this could cause name clashes, use a hashing function instead... */ + strcat(destname, fname); + p = &destname[strlen("/var/cache/")]; + while ((p = strchr(p, '/')) != NULL) + *p = '.'; + strcat(destname, ".m2v"); + /* ...then check if it exists already... */ + if (stat(destname, &st) || (st.st_mtime != st2.st_mtime) || (st.st_size == 0)) + { + struct utimbuf u; + u.actime = time(NULL); + u.modtime = st2.st_mtime; + printf("converting %s -> %s\n", fname, destname); + /* it does not exist or has a different date, so call ffmpeg... */ + sprintf(cmd, "ffmpeg -v 31 -y -f mjpeg -i '%s' -s %s '%s'