Recording thumbnails - resolved! :-D (2 Viewers)

Wo0zy

Retired Team Member
  • Premium Supporter
  • April 30, 2008
    394
    134
    Home Country
    United Kingdom United Kingdom
    Thanks for doing this pilehave.

    My recordings thumbnails (or lack there of) has been a bit frustrating. :)

    Are you still using the code you quoted earlier or have you tweaked it for the tests?

    All the best,

    Mick
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    I tweaked the code a bit more. This is what I have so far, a cleanup is needed ;)

    Code:
    Index: VideoThumbCreator.cs
    ===================================================================
    --- VideoThumbCreator.cs	(revision 28214)
    +++ VideoThumbCreator.cs	(working copy)
    @@ -33,7 +33,7 @@
     {
       public class VideoThumbCreator
       {
    -    private static string ExtractApp = "mtn.exe";
    +    private static string ExtractApp = "ffmpeg.exe";
         private static string ExtractorPath = Config.GetFile(Config.Dir.Base, "MovieThumbnailer", ExtractApp);
         private static int PreviewColumns = 2;
         private static int PreviewRows = 2;
    @@ -112,7 +112,7 @@
           // Params for mplayer (outputs 00000001.jpg in video resolution into working dir) -vf scale=600:-3
           //string ExtractorArgs = string.Format(" -noconsolecontrols -nosound -vo jpeg:quality=90 -vf scale -frames 1 -ss {0} \"{1}\"", "501", aVideoPath);
     
    -      // Params for mtm (http://moviethumbnail.sourceforge.net/usage.en.html)
    +      // Params for mtn (http://moviethumbnail.sourceforge.net/usage.en.html)
           //   -D 8         : edge detection; 0:off >0:on; higher detects more; try -D4 -D6 or -D8
           //   -B 420/E 600 : omit this seconds from the beginning / ending TODO: use pre- / postrecording values
           //   -c 2 / r 2   : # of column / # of rows
    @@ -136,13 +136,7 @@
             postGapSec = 600;
           }
           bool Success = false;
    -      string ExtractorArgs = string.Format(" -D 6 -B {0} -E {1} -c {2} -r {3} -b {4} -t -i -w {5} -n -P \"{6}\"",
    -                                           preGapSec, postGapSec, PreviewColumns, PreviewRows, blank, 0, aVideoPath);
    -      string ExtractorFallbackArgs = string.Format(
    -        " -D 8 -B {0} -E {1} -c {2} -r {3} -b {4} -t -i -w {5} -n -P \"{6}\"", 0, 0, PreviewColumns, PreviewRows, blank,
    -        0, aVideoPath);
    -      // Honour we are using a unix app
    -      ExtractorArgs = ExtractorArgs.Replace('\\', '/');
    +
           try
           {
             // Use this for the working dir to be on the safe side
    @@ -150,16 +144,19 @@
             string OutputThumb = string.Format("{0}_s{1}", Path.ChangeExtension(aVideoPath, null), ".jpg");
             string ShareThumb = OutputThumb.Replace("_s.jpg", ".jpg");
     
    +        string ExtractorArgs = string.Format(" -ss {0} -itsoffset -5 -i \"{1}\" -vframes 1 \"{2}\"", preGapSec, aVideoPath, OutputThumb);
    +        string ExtractorFallbackArgs = string.Format(" -ss 60 -itsoffset -5 -i \"{1}\" -vframes 1 \"{2}\"", preGapSec, aVideoPath, OutputThumb);
    +
             if ((LeaveShareThumb && !Util.Utils.FileExistsInCache(ShareThumb))
                 // No thumb in share although it should be there
                 || (!LeaveShareThumb && !Util.Utils.FileExistsInCache(aThumbPath)))
               // No thumb cached and no chance to find it in share
             {
    -          //Log.Debug("VideoThumbCreator: No thumb in share {0} - trying to create one with arguments: {1}", ShareThumb, ExtractorArgs);
    +          Log.Debug("VideoThumbCreator: No thumb in share {0} - trying to create one with arguments: {1}", ShareThumb, ExtractorArgs);
               Success = Utils.StartProcess(ExtractorPath, ExtractorArgs, TempPath, 15000, true, GetMtnConditions());
               if (!Success)
               {
    -            // Maybe the pre-gap was too large or not enough sharp & light scenes could be caught
    +            // Maybe it takes more than 15 seconds to create the thumbnail, try fallback arguments
                 Thread.Sleep(100);
                 Success = Utils.StartProcess(ExtractorPath, ExtractorFallbackArgs, TempPath, 30000, true, GetMtnConditions());
                 if (!Success)
    @@ -172,7 +169,7 @@
               Utils.KillProcess(Path.ChangeExtension(ExtractApp, null));
               try
               {
    -            // remove the _s which mdn appends to its files
    +            // remove the _s which mtn appends to its files
                 File.Move(OutputThumb, ShareThumb);
               }
               catch (FileNotFoundException)
     

    powermarcel10

    Retired Team Member
  • Premium Supporter
  • November 30, 2010
    2,839
    898
    35
    Groningen
    Home Country
    Netherlands Netherlands
    Hello,

    the solution doesn't work for me anymore, because the tweaked TV.dll file is not compatible with MP 1.2.1. Can you compile it maybe? Because this solution works like a charm for me!
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    If any of you would like to try the solution I had on my problems, you are more than welcome.

    It uses ffmpeg to create the thumbnails. It doesn't have the blur-detection of the old thumbnailer, but I haven't found that to be an issue yet. It has created thumbnails of all of my +500 recordings.

    You need two files:

    - replacement Utils.dll
    - ffmpeg.exe

    Put Utils.dll in C:\Program Files (x86)\Team MediaPortal\MediaPortal (remember to make a backup of your existing Utils.dll first!)
    Put ffmpeg.exe in C:\Program Files (x86)\Team MediaPortal\MediaPortal\MovieThumbnailer

    This should be enough. MediaPortal keeps track in the database what files failed to generate a thumbnail, so new files won't be re-created automatically. If you want this you need to edit the MySQL/ MS SQL database (let me know, and I'll explain).

    Both files are attached. The ffmpeg.exe is for 64-bit only! Get a 32-bit version from http://ffmpeg.zeranoe.com/builds/

    I'm not sure if you also need a replacement Core.dll, but I don't think so!
     

    Attachments

    • Utils.zip
      43.4 KB
    • ffmpeg.zip
      6.5 MB

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Thanks pilehave,

    I assume this solution is only good if you use MP TVServer, I'm using FTR.

    John.

    I would think so, I believe FTR creates its own TV-thumbnails. The Util I posted is used by MP to create thumbnails not only for TV, but for videos as well.
     

    01-0077

    Portal Member
    March 14, 2009
    5
    0
    Perth
    Home Country
    Yes FTR generates its own thumbnails using mtn. I believe FTR uses either a different version of mtn or different mtn switches to TVServer. I have found FTR is more successful at producing recorded tv thumbs for our HD channels than TVServer but its still not 100%. Is it possible to run ffmpeg on a recording from a command line?
     

    pilehave

    Community Skin Designer
  • Premium Supporter
  • April 2, 2008
    2,566
    521
    Hornslet
    Home Country
    Denmark Denmark
    Yes FTR generates its own thumbnails using mtn. I believe FTR uses either a different version of mtn or different mtn switches to TVServer. I have found FTR is more successful at producing recorded tv thumbs for our HD channels than TVServer but its still not 100%. Is it possible to run ffmpeg on a recording from a command line?

    Yes it is.

    It uses these args:

    string ExtractorArgs = string.Format(" -ss {0} -itsoffset -5 -i \"{1}\" -vframes 1 \"{2}\"", preGapSec, aVideoPath, OutputThumb);

    which translates into something like

    ffmpeg.exe -ss 720 -itsoffet -5 -i "path/to/videofile" -vframes 1 "path/to/thumbnailname.jpg"

    All of this is trivially explained in ffmpeg Documentation :)
     

    01-0077

    Portal Member
    March 14, 2009
    5
    0
    Perth
    Home Country
    Thanks pilehave, the reason I asked was because I couldn't get the version you posted to run from a command prompt. Is it 64 bit, I'm on x86? I downloaded a 32 bit version and it works a treat.

    I found the ffmpeg documentation in one of your earlier posts. Quickly found out that for a performance boost to make sure the -ss argument is before the -i, this way ffmpeg jumps straight to that position without decoding first.

    A while back I had a play with a filewatcher app which monitors a folder and when a file is created will call another program to run on the file. I used this with mtn with limited success (due to mtn), but I might have a go with ffmpeg and see how it goes. This runs as a service and I can just disable thumb generation in FTR.
     

    Users who are viewing this thread

    Top Bottom