mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-27 07:23:11 +02:00
spark: fix TODO in cVideo::ShowPicture()
rebuild the MPEG stillpicture if the source jpeg has changed additionally check for zero sized m2v from broken ffmpeg versions
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <utime.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
@@ -333,10 +334,14 @@ void cVideo::ShowPicture(const char * fname)
|
|||||||
char destname[512];
|
char destname[512];
|
||||||
char cmd[512];
|
char cmd[512];
|
||||||
char *p;
|
char *p;
|
||||||
unsigned char *data;
|
|
||||||
int mfd;
|
int mfd;
|
||||||
struct stat st;
|
struct stat st, st2;
|
||||||
strcpy(destname, "/var/cache");
|
strcpy(destname, "/var/cache");
|
||||||
|
if (stat(fname, &st2))
|
||||||
|
{
|
||||||
|
lt_info("%s: could not stat %s (%m)\n", __func__, fname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
mkdir(destname, 0755);
|
mkdir(destname, 0755);
|
||||||
/* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg):
|
/* the cache filename is (example for /share/tuxbox/neutrino/icons/radiomode.jpg):
|
||||||
/var/cache/share.tuxbox.neutrino.icons.radiomode.jpg.m2v
|
/var/cache/share.tuxbox.neutrino.icons.radiomode.jpg.m2v
|
||||||
@@ -347,14 +352,17 @@ void cVideo::ShowPicture(const char * fname)
|
|||||||
while ((p = strchr(p, '/')) != NULL)
|
while ((p = strchr(p, '/')) != NULL)
|
||||||
*p = '.';
|
*p = '.';
|
||||||
strcat(destname, ".m2v");
|
strcat(destname, ".m2v");
|
||||||
/* ...then check if it exists already...
|
/* ...then check if it exists already... */
|
||||||
TODO: check if the cache file is older than the jpeg file... */
|
if (stat(destname, &st) || (st.st_mtime != st2.st_mtime) || (st.st_size == 0))
|
||||||
if (access(destname, R_OK))
|
|
||||||
{
|
{
|
||||||
/* it does not exist, so call ffmpeg to create it... */
|
struct utimbuf u;
|
||||||
|
u.actime = time(NULL);
|
||||||
|
u.modtime = st2.st_mtime;
|
||||||
|
/* it does not exist or has a different date, so call ffmpeg... */
|
||||||
sprintf(cmd, "ffmpeg -y -f mjpeg -i '%s' -s 1280x720 '%s' </dev/null",
|
sprintf(cmd, "ffmpeg -y -f mjpeg -i '%s' -s 1280x720 '%s' </dev/null",
|
||||||
fname, destname);
|
fname, destname);
|
||||||
system(cmd); /* TODO: use libavcodec to directly convert it */
|
system(cmd); /* TODO: use libavcodec to directly convert it */
|
||||||
|
utime(destname, &u);
|
||||||
}
|
}
|
||||||
mfd = open(destname, O_RDONLY);
|
mfd = open(destname, O_RDONLY);
|
||||||
if (mfd < 0)
|
if (mfd < 0)
|
||||||
|
Reference in New Issue
Block a user