source: projects/specs/trunk/nonfree/self-build-minidlna/minidlna_video_thumbnail_v121.patch @ 11754

Revision 11754, 12.3 KB checked in by iwaim, 6 years ago (diff)

self-build-minidlna: add files

  • Makefile.am

    old new  
    5353        @LIBEXIF_LIBS@ \ 
    5454        @LIBINTL@ \ 
    5555        @LIBICONV@ \ 
    56         -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) 
     56        -lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) @LIBFFMPEGTHUMBNAILER_LIBS@ 
    5757 
    5858minidlnad_LDFLAGS = @STATIC_LDFLAGS@ 
    5959 
  • albumart.c

    old new  
    3232 
    3333#include <jpeglib.h> 
    3434 
     35#ifdef THUMBNAIL_CREATION 
     36#include <libffmpegthumbnailer/videothumbnailerc.h> 
     37#endif 
     38 
    3539#include "upnpglobalvars.h" 
    3640#include "albumart.h" 
    3741#include "sql.h" 
     
    348352        return NULL; 
    349353} 
    350354 
     355#ifdef THUMBNAIL_CREATION 
     356char * 
     357generate_thumbnail(const char * path) 
     358{ 
     359       char *tfile = NULL; 
     360       video_thumbnailer *vt = NULL; 
     361       char cache_dir[MAXPATHLEN]; 
     362 
     363       if( art_cache_exists(path, &tfile) ) 
     364               return tfile; 
     365 
     366       if ( is_video(path) ) 
     367       { 
     368 
     369               vt = video_thumbnailer_create(); 
     370               if ( !vt ) 
     371               { 
     372                       free(tfile); 
     373                       return 0; 
     374               } 
     375               vt->thumbnail_image_type = Jpeg; 
     376               vt->thumbnail_image_quality = runtime_vars.thumb_quality; 
     377               vt->thumbnail_size = runtime_vars.thumb_width; 
     378               vt->seek_percentage = 20; 
     379               vt->overlay_film_strip = (GETFLAG(THUMB_FILMSTRIP))?1:0; 
     380 
     381               DPRINTF(E_DEBUG, L_METADATA, "generating thumbnail: %s\n", path); 
     382 
     383               strncpyt(cache_dir, tfile, sizeof(cache_dir)); 
     384               if ( !make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) && 
     385                       !video_thumbnailer_generate_thumbnail_to_file(vt, path, tfile) ) 
     386               { 
     387                       video_thumbnailer_destroy(vt); 
     388                       return tfile; 
     389               } 
     390 
     391               video_thumbnailer_destroy(vt); 
     392       } 
     393       free(tfile); 
     394 
     395       return 0; 
     396} 
     397#endif 
     398 
    351399int64_t 
    352400find_album_art(const char *path, uint8_t *image_data, int image_size) 
    353401{ 
    354402        char *album_art = NULL; 
    355403        int64_t ret = 0; 
    356404 
    357         if( (image_size && (album_art = check_embedded_art(path, image_data, image_size))) || 
    358             (album_art = check_for_album_file(path)) ) 
     405        if(image_size) 
     406               album_art = check_embedded_art(path, image_data, image_size); 
     407 
     408        if(!album_art) 
     409               album_art = check_for_album_file(path); 
     410 
     411#ifdef THUMBNAIL_CREATION 
     412        if(!album_art && GETFLAG(THUMB_MASK)) 
     413               album_art = generate_thumbnail(path); 
     414#endif 
     415 
     416        if(album_art) 
    359417        { 
    360418                ret = sql_get_int_field(db, "SELECT ID from ALBUM_ART where PATH = '%q'", album_art); 
    361419                if( !ret ) 
  • configure.ac

    old new  
    617617        ] 
    618618) 
    619619 
     620AC_ARG_ENABLE(thumbnail, 
     621       [  --enable-thumbnail      enable video thumbnail generation using libffmpegthumbnailer],[ 
     622       if test "$enableval" = "yes"; then 
     623               AC_DEFINE([THUMBNAIL_CREATION],[1],[Define to 1 if you want to enable video thumbnail generation]) 
     624               PKG_CHECK_MODULES([LIBFFMPEGTHUMBNAILER], libffmpegthumbnailer, , 
     625                       AC_MSG_ERROR([Unable to find libffmpegthumbnailer])) 
     626               AC_SUBST([LIBFFMPEGTHUMBNAILER_CFLAGS]) 
     627               AC_SUBST([LIBFFMPEGTHUMBNAILER_LIBS]) 
     628       else 
     629               AC_MSG_RESULT([no]) 
     630       fi 
     631       ],[ 
     632               AC_MSG_RESULT([no]) 
     633       ] 
     634) 
    620635 
    621636case "$target_os" in 
    622637        darwin*) 
  • minidlna.c

    old new  
    539539        runtime_vars.root_container = NULL; 
    540540        runtime_vars.ifaces[0] = NULL; 
    541541 
     542#ifdef THUMBNAIL_CREATION 
     543       runtime_vars.thumb_width = 160; 
     544       runtime_vars.thumb_quality = 8; 
     545#endif 
     546 
    542547        /* read options file first since 
    543548         * command line arguments have final say */ 
    544549        if (readoptionsfile(optionsfile) < 0) 
     
    752757                        if (strcasecmp(ary_options[i].value, "beacon") == 0) 
    753758                                CLEARFLAG(TIVO_BONJOUR_MASK); 
    754759                        break; 
     760#ifdef THUMBNAIL_CREATION 
     761               case ENABLE_THUMB: 
     762                       if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) 
     763                               SETFLAG(THUMB_MASK); 
     764                       break; 
     765               case THUMB_WIDTH: 
     766                       runtime_vars.thumb_width = atoi(ary_options[i].value); 
     767                       if (runtime_vars.thumb_width < 120) 
     768                               runtime_vars.thumb_width = 120; 
     769                       if (runtime_vars.thumb_width > 480) 
     770                               runtime_vars.thumb_width = 480; 
     771                       break; 
     772               case THUMB_QUALITY: 
     773                       runtime_vars.thumb_quality = atoi(ary_options[i].value); 
     774                       if (runtime_vars.thumb_quality < 5) 
     775                               runtime_vars.thumb_quality = 5; 
     776                       if (runtime_vars.thumb_quality > 30) 
     777                               runtime_vars.thumb_quality = 30; 
     778                       break; 
     779               case ENABLE_THUMB_FILMSTRIP: 
     780                       if( (strcmp(ary_options[i].value, "yes") == 0) || atoi(ary_options[i].value) ) 
     781                               SETFLAG(THUMB_FILMSTRIP); 
     782                       break; 
     783#endif 
    755784                default: 
    756785                        DPRINTF(E_ERROR, L_GENERAL, "Unknown option in file %s\n", 
    757786                                optionsfile); 
  • minidlna.conf

    old new  
    8888 
    8989# set this to yes to allow symlinks that point outside user-defined media_dirs. 
    9090#wide_links=no 
     91 
     92# Suport to Movie Thumbnail generation. To use this option, thumbnail generation must be enable at compile time. 
     93#enable_thumbnail=no 
     94 
     95# The width of the thumbnail image. Large images takes more time to generate.  To use this option, thumbnail generation must be enable at compile time. 
     96#thumbnail_width=160 
     97 
     98# Thumbnail Image quality. To use this option, thumbnail generation must be enable at compile time. 
     99#thumbnail_quality=8 
     100 
     101# Should the thumbnail have a film strip? To use this option, thumbnail generation must be enable at compile time. 
     102#enable_thumbnail_filmstrip=no 
  • options.c

    old new  
    6464        { USER_ACCOUNT, "user" }, 
    6565        { FORCE_SORT_CRITERIA, "force_sort_criteria" }, 
    6666        { MAX_CONNECTIONS, "max_connections" }, 
     67#ifndef THUMBNAIL_CREATION 
    6768        { MERGE_MEDIA_DIRS, "merge_media_dirs" }, 
     69#else 
     70       { MERGE_MEDIA_DIRS, "merge_media_dirs" }, 
     71       { ENABLE_THUMB, "enable_thumbnail" }, 
     72       { THUMB_WIDTH, "thumbnail_width" }, 
     73       { THUMB_QUALITY, "thumbnail_quality" }, 
     74       { ENABLE_THUMB_FILMSTRIP, "enable_thumbnail_filmstrip" }, 
     75#endif 
    6876        { WIDE_LINKS, "wide_links" }, 
    6977        { TIVO_DISCOVERY, "tivo_discovery" }, 
    7078}; 
  • options.h

    old new  
    5757        USER_ACCOUNT,                   /* user account to run as */ 
    5858        FORCE_SORT_CRITERIA,            /* force sorting by a given sort criteria */ 
    5959        MAX_CONNECTIONS,                /* maximum number of simultaneous connections */ 
     60#ifndef THUMBNAIL_CREATION 
    6061        MERGE_MEDIA_DIRS,               /* don't add an extra directory level when there are multiple media dirs */ 
     62#else 
     63        MERGE_MEDIA_DIRS,               /* don't add an extra directory level when there are multiple media dirs */ 
     64        ENABLE_THUMB,                   /* enable thumbnail generation */ 
     65        THUMB_WIDTH,                    /* thunbnail image with */ 
     66        THUMB_QUALITY,                  /* thumnail image quality */ 
     67        ENABLE_THUMB_FILMSTRIP,         /* film strip overlay */ 
     68#endif 
    6169        WIDE_LINKS,                     /* allow following symlinks outside the defined media_dirs */ 
    6270        TIVO_DISCOVERY,                 /* TiVo discovery protocol: bonjour or beacon. Defaults to bonjour if supported */ 
    6371}; 
  • upnpglobalvars.h

    old new  
    196196#define SCANNING_MASK         0x0100 
    197197#define RESCAN_MASK           0x0200 
    198198 
     199#ifdef THUMBNAIL_CREATION 
     200#define THUMB_MASK            0x0100 
     201#define THUMB_FILMSTRIP       0x0200 
     202#endif 
     203 
    199204#define SETFLAG(mask)   runtime_flags |= mask 
    200205#define GETFLAG(mask)   (runtime_flags & mask) 
    201206#define CLEARFLAG(mask) runtime_flags &= ~mask 
  • utils.h

    old new  
    101101int make_dir(char * path, mode_t mode); 
    102102unsigned int DJBHash(uint8_t *data, int len); 
    103103 
     104#ifdef THUMBNAIL_CREATION 
     105int rename_artcache_dir(const char * oldpath, const char * newpath); 
     106#endif 
     107 
    104108#endif 
  • minidlnatypes.h

    old new  
    5151        int max_connections;    /* max number of simultaneous conenctions */ 
    5252        const char *root_container;     /* root ObjectID (instead of "0") */ 
    5353        const char *ifaces[MAX_LAN_ADDR];       /* list of configured network interfaces */ 
     54#ifdef THUMBNAIL_CREATION 
     55       int thumb_width; 
     56       int thumb_quality; 
     57#endif 
    5458}; 
    5559 
    5660struct string_s { 
  • monitor.c

    old new  
    322322                sql_exec(db, "DELETE from OBJECTS where DETAIL_ID = %lld", detailID); 
    323323        } 
    324324        snprintf(art_cache, sizeof(art_cache), "%s/art_cache%s", db_path, path); 
     325 
     326#ifdef THUMBNAIL_CREATION 
     327       /* Remove video thumbnails */ 
     328       if ( is_video(path) ) 
     329       { 
     330               char *vthumb = art_cache; 
     331               strcpy(strchr(vthumb, '\0')-4, ".jpg"); 
     332       } 
     333#endif 
     334 
    325335        remove(art_cache); 
    326336 
    327337        return 0; 
     
    616626        sigdelset(&set, SIGCHLD); 
    617627        pthread_sigmask(SIG_BLOCK, &set, NULL); 
    618628 
     629#ifdef THUMBNAIL_CREATION 
     630       char renpath_buf[PATH_MAX]; 
     631       int cookie = 0; 
     632#endif 
     633 
    619634        pollfds[0].fd = inotify_init(); 
    620635        pollfds[0].events = POLLIN; 
    621636 
     
    685700                                { 
    686701                                        DPRINTF(E_DEBUG, L_INOTIFY,  "The directory %s was %s.\n", 
    687702                                                path_buf, (event->mask & IN_MOVED_TO ? "moved here" : "created")); 
     703 
     704#ifdef THUMBNAIL_CREATION 
     705                                       /* We do not want to regenerate the thumbnails if e rename a directory. 
     706                                          We should keep at least four cookies/olddir since IN_MOVED_FROM/IN_MOVED_TO may 
     707                                          not arrive in sequence, but one should cover most cases */ 
     708                                       if (event->cookie == cookie && event->mask & IN_MOVED_TO) 
     709                                       { 
     710                                               DPRINTF(E_DEBUG, L_INOTIFY, "Directory rename: %s -> %s \n", renpath_buf, path_buf); 
     711                                               rename_artcache_dir(renpath_buf, path_buf); 
     712                                       } 
     713#endif 
     714 
    688715                                        monitor_insert_directory(pollfds[0].fd, esc_name, path_buf); 
    689716                                } 
    690717                                else if ( (event->mask & (IN_CLOSE_WRITE|IN_MOVED_TO|IN_CREATE)) && 
     
    717744                                                (event->mask & IN_ISDIR ? "directory" : "file"), 
    718745                                                path_buf, (event->mask & IN_MOVED_FROM ? "moved away" : "deleted")); 
    719746                                        if ( event->mask & IN_ISDIR ) 
     747 
     748#ifdef THUMBNAIL_CREATION 
     749                                        { 
     750                                               if ( event->mask & IN_MOVED_FROM ) 
     751                                               { 
     752                                                       strncpy(renpath_buf, path_buf, sizeof(renpath_buf)); 
     753                                                       cookie = event->cookie; 
     754                                               } 
     755#endif 
     756 
    720757                                                monitor_remove_directory(pollfds[0].fd, path_buf); 
     758 
     759#ifdef THUMBNAIL_CREATION 
     760                                        } 
     761#endif 
     762 
    721763                                        else 
    722764                                                monitor_remove_file(path_buf); 
    723765                                } 
  • utils.c

    old new  
    531531 
    532532        return ALL_MEDIA; 
    533533} 
     534 
     535#ifdef THUMBNAIL_CREATION 
     536int 
     537rename_artcache_dir(const char * oldpath, const char * newpath) 
     538{ 
     539       char old_artcache[PATH_MAX]; 
     540       char new_artcache[PATH_MAX]; 
     541 
     542       snprintf(old_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, oldpath); 
     543       snprintf(new_artcache, sizeof(old_artcache), "%s/art_cache%s", db_path, newpath); 
     544 
     545       return rename(old_artcache, new_artcache); 
     546} 
     547#endif 
Note: See TracBrowser for help on using the repository browser.