Replacement MTN (Thumbnailer) for H264 content (2 Viewers)

Jay_UK

Test Group
  • Team MediaPortal
  • October 6, 2009
    1,781
    283
    Derby
    Home Country
    United Kingdom United Kingdom
    All,

    Please find attached a "replacement" for the MTN.exe thumbnailer used by Mediaportal.

    Due to MTN being a dead project with no updates in over a year, no response from the author and not being able to thumbnail all types of media, I decided to have a look at a "fix".

    Ideally MediaPortal should be updated to stop using MTN and switch to something else (internal Windows thumbnailing, FFmpeg, etc - Pilehive did post some code previously), but my coding abilities are limited, so I wrote a new MTN.exe which is simply a wrapper to FFMpeg.

    It takes the commandline options (most of them) that MTN was sent and runs them through FFMpeg.

    To install simply copy the two files from the ZIP file (MTN.EXE and FFMpeg.exe) and place them into the Mediaportal/MovieThumbNailer directory (overwriting the MTN that is there) - thats it :D

    If you want a more feature rich replacement for MTN (which will grab images from the internet, supports client/server, etc) then may I suggest you try Kiwijunglist's great version here:

    https://forum.team-mediaportal.com/...tom-rec-tv-thumbs-better-h264-support.113415/

    The updated "Source" zip contains the four modules used in this project (No project or solution file).

    Change log:
    -------------------------------------------------------------------------------------------------------------------------
    Version 77:
    Fixed a bug if no registry key values are set.
    Now supports "overridebegin" and "overrideend" registry keys. These override the commandline "begin" and "end" skip values (-B and -E). This will allow you to use different values to those hardcoded by Mediaportal (eg 720 and 500 I think - Cant remember the end value off the top of my head).
    To specify the begin skip period, create the following key "overridebegin" (REG_SZ) and set it to the required time in seconds.
    To specify the end skip period, create the following key "overrideend" (REG_SZ) and set it to the required time in seconds.
    -------------------------------------------------------------------------------------------------------------------------
    Version 76:
    Now supports "maxthumbnailwidth". This will prevent a thumbnail from exceeding this value. Handy if using "thumbwidth -1". If the thumbnail is wider than the maximum, it is rescaled to the maximum value (if the width is less than max, then nothing is done).
    To specify the maximum width, create the following key "maxthumbnailwidth" (REG_SZ) and set it to the required width.
    -------------------------------------------------------------------------------------------------------------------------
    Version 74:
    Incorrect reporting of thumbnail in the log file
    New option of "-1" for thumbnail size, will now make the thumbnail width to be the total width of the source videos * columns. This may may mean the thumbnail could be massive!
    -------------------------------------------------------------------------------------------------------------------------
    Version 73:
    Simplified maths/logic for calculating tile sizes
    -------------------------------------------------------------------------------------------------------------------------
    Version 72:
    Customisable borders
    Now supports customisable internal and external borders.
    Create a new registry key called "externalborder" and set it to the number of pixels
    Create a new registry key called "internalborder" and set it to the number of pixels
    -------------------------------------------------------------------------------------------------------------------------
    Version 71:
    Black Frame Detection
    Now supports black/blank frame detection. If a grabbed frame/tile is black, it will try and grab another one. It will try 3 times. If they are all black, it will give up and use the black grabbed frame. This option is on by default. To turn it off create the following registry key (REG_SZ): "disableblankframedetection" and set it to "1". Please let me know how you get on with detection rates and speed. This function does drastically slow the thumbnailing process down (it is not variable like the MTN version - might be something I look at going forward)

    Borders
    Now supports black borders between the tiles. This is off by default, to enable borders (and specify thickness in pixels), create the following registry key (REG_SZ): "border" and set it to the required thickness.
    Image Quality
    Change the default, such that image encoding is done by default (JPEG quality is 100%). This will now produce smaller thumbs at 100% quality. To disable the encoding, set the "thumbnailquality" regsitry key to "-1"
    -------------------------------------------------------------------------------------------------------------------------
    Version 70:
    Code is now C# (instead of VB.Net) - Great fun converting data types!!
    Fixed a logic/maths issue with tiling
    Now includes a "thumbnailquality" option - set via the registry (value is 1 to 100 - Where 100 does no adjustment))
    Now includes a "thumbnailwidth" option - set via the registry that sets the default size if one is
    not set via the commandline (instead of using video size)
    -------------------------------------------------------------------------------------------------------------------------
    Version 61:
    Exit level on failure is now -1 (instead of 1)
    Can now specify debug mode via commandline ("-debug")
    Now supports two modes of aspect ratio:
    Thumbnail Aspect Ratio (default option)
    In this mode, the final thumbnail aspect ratio will match the source/video aspect ratio. This will mean the individual tile images may be distorted to ensure the overal AR is maintained for the thumbnail. The final thumbnail size should be quite consistant as it will be based on video aspect ratios (16:9, 4:3, etc)

    Tile Aspect Ratio (custom option)
    In this mode the final thumbnail aspect ratio will not match the source/video aspect ratio. Instead the individual tile image(s) aspect ratios are maintained. This may mean the overall thumbnail AR (dimensions) will be way off. I'm not sure how well MePo will handle it. In this mode having a large differential between rows and columns will make the overall thumbnail size "interesting".

    To change from the default mode, to the TileAR mode, create a reg key call "keeptilear" and set it to "1" (or specify "-keeptilear") as a commandline option.
    -------------------------------------------------------------------------------------------------------------------------
    Version 60:
    Refactored the code a little
    Dropped the minimum video length to 30 seconds (instead of 60)
    Now supports process priority (use a reg key called "priority" and set it to: realtime, abovenormal, belownormal,high, normal,idle) - default is BELOWNORMAL
    Has a commandline help feature (mtn.exe --h or -h or -help)
    Temporary tile files are now saved into a MTN_Replacement sub directory in "Windows Temp"
    Exit level set to 1 on a failure (0 on success)
    -------------------------------------------------------------------------------------------------------------------------
    Version 59:
    Switched to using a more complex process based launching mechanism (instead of shell and external file)
    If FFmpeg fails to extract movie details, the program will assume some defaults (duration 300, width 1270)
    -------------------------------------------------------------------------------------------------------------------------
    Version 56:
    Fixed annoying issues with long filenames and spaces (which I thought I had fixed in v55)
    -------------------------------------------------------------------------------------------------------------------------
    Version 55:
    Fixed issues of paths with spaces/long names
    -------------------------------------------------------------------------------------------------------------------------
    Version 53:
    Reverted to FFMpeg for extracting movie details
    Fixed stupid timeout mistake (wanted miliseconds I gave it secsonds)
    -------------------------------------------------------------------------------------------------------------------------
    Version 52:
    Tried using MediaInfo to extract details but was taking 20 seconds to open/read a movie of the LAN
    -------------------------------------------------------------------------------------------------------------------------
    Version 51:
    A large rewrite to address issues and performance (wife is not happy about how much time I've spent on it!!)
    No longer uses FFmpeg to tile (internally done by code)
    Frame grabs are now equally spaced between start and end points
    Supports custom suffix
    Supports custom output directory
    Supports end skip value
    If no custom size is specified for thumbnail, the size of the source is used
    -------------------------------------------------------------------------------------------------------------------------
    Version 50:
    Major issue/bug - so not available anymore!!
    Program rewritten using VB.Net
    -------------------------------------------------------------------------------------------------------------------------
    Version 49:
    Fixed issue of rows and columns the wrong way around
    -------------------------------------------------------------------------------------------------------------------------
    Version 48:
    Tweaked the "debug" setting - You can either use a "mtn.debug" flag file (in the same directory as the mtn.exe file), or you can create the following reg key: HKLM\Software\MTN\debug (create as a string and set to 1).

    To make everyone's life easy, I have included two reg files within the Zip file - these will turn on/off debug (simply double click on either one).

    With debug enabled, MTN will create a "mtn_replacement.log" log file in the mtn.exe directory.
    ---------------------------------------------------------------------------------------------------------------------------

    Many thanks,

    J.
     

    Attachments

    • MTN_Replacement_V77_C#.zip
      7.6 MB
    Last edited:

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,934
    2,235
    Ba-Wü
    Home Country
    Germany Germany
    I will give this a try.
    Thanks!

    Will it still be configurable through MP Config -> Thumbnails?
     

    Jay_UK

    Test Group
  • Team MediaPortal
  • October 6, 2009
    1,781
    283
    Derby
    Home Country
    United Kingdom United Kingdom
    Hi there,

    Yep it should work just the same :)

    There is a debug/logging feature included with my new MTN replacement.

    Simply create/place a file called "mtn.debug" in the same directory as the "mtn.exe" and this will tell MTN to create its own logfile (also in the MTN directory). This will give more detailed info in addition to the MePo log.

    J.
     

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,934
    2,235
    Ba-Wü
    Home Country
    Germany Germany
    Hi there,

    Yep it should work just the same :)

    There is a debug/logging feature included with my new MTN replacement.

    Simply create/place a file called "mtn.debug" in the same directory as the "mtn.exe" and this will tell MTN to create its own logfile (also in the MTN directory). This will give more detailed info in addition to the MePo log.

    J.

    Hello!
    I still got an error. See attached screenshot:
    Z1.jpg
    How to create a file called "mtn.debug"? .bat file you mean?
    Thanks!
     
    Last edited:

    kiwijunglist

    Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    I will pipe in just to say that mtn has about a 66% failure rate on my setup with DVB-T h264 recordings in NZ. So I would definitely like to see mtn replaced with ffdshow or something else.

    On my PC if doing a montage of 4 screenshots it is way way faster to just run ffmpeg 4 times compared with using ffmpeg to capture 4 screenshots in one go.

    PS. Thanks for the plug Jay
    [DOUBLEPOST=1352128742][/DOUBLEPOST]
    How to create a file called "mtn.debug"? .bat file you mean?
    Thanks!

    Right click inside the mtn folder, New -> Text document. Then rename the file to mtn.debug
     
    Last edited:

    Jay_UK

    Test Group
  • Team MediaPortal
  • October 6, 2009
    1,781
    283
    Derby
    Home Country
    United Kingdom United Kingdom
    Hi there,

    If you could create a file called "mtn.debug" and rerun the process again - I would be curious to see the log file (mtn_replacement.log) that is created.

    Many thanks,

    J.
     

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,934
    2,235
    Ba-Wü
    Home Country
    Germany Germany
    Hi there,

    If you could create a file called "mtn.debug" and rerun the process again - I would be curious to see the log file (mtn_replacement.log) that is created.

    Many thanks,

    J.

    I will do recording this evening because I think if thumbnail making fails once then the file got blacklisted?
    I put "mtn.debug.txt" in the same folder where mtn.exe is.
     

    kiwijunglist

    Super Moderator
  • Team MediaPortal
  • June 10, 2008
    6,746
    1,751
    New Zealand
    Home Country
    New Zealand New Zealand
    from my reading, im fairly sure meant to be mtn.debug , not mtn.debug.txt press F2 to rename the file and get rid of the last 4 char.
     

    Holzi

    Super Moderator
  • Team MediaPortal
  • April 21, 2010
    7,934
    2,235
    Ba-Wü
    Home Country
    Germany Germany
    Yes.. it is named "mtn.debug". But it is a txt file. (I hope this is right)
     

    Jay_UK

    Test Group
  • Team MediaPortal
  • October 6, 2009
    1,781
    283
    Derby
    Home Country
    United Kingdom United Kingdom
    Hi there,

    Get rid of the ".txt" from the end - it should be just "mtn.debug"

    I need to look at the code for blacklisting... I thought it was more than just one failure, but I could be wrong.

    J.
     

    Users who are viewing this thread

    Top Bottom