• The forum software that supports hummy.tv has been upgraded to XenForo 2.3!

    Please bear with us as we continue to tweak things, and feel free to post any questions, issues or suggestions in the upgrade thread.

Thumbnails - any configuration?

Jxp's method seems to be more like what I'm after. I don't necessarily want to choose a thumbnail manually but would prefer that the thumbnail was actually a frame from the program :rolleyes:

Any chance of a package that runs in the background and shifts thumbnails to a minute in?

Sent from my GT-N7100 using Tapatalk 2
 
This appears to make no sense...

The indenting is just wrong there. It should look more like;

Code:
        if [ -f "$fileRoot.thm" ]
        then
            checkByte=`hexdump -n1 -s3 -e'"" 1/1 "%02x"' "$fileRoot.thm"`
                fileSize=$(stat -c '%s' "$fileRoot.thm")
 
            if [ $checkByte == "ff" ] && [ $fileSize == "43680" ]
            then
                process="1"
            fi
        else
            process="1"
        fi
 
The indenting is just wrong there. It should look more like;

Code:
        if [ -f "$fileRoot.thm" ]
        then
            checkByte=`hexdump -n1 -s3 -e'"" 1/1 "%02x"' "$fileRoot.thm"`
                fileSize=$(stat -c '%s' "$fileRoot.thm")
 
            if [ $checkByte == "ff" ] && [ $fileSize == "43680" ]
            then
                process="1"
            fi
        else
            process="1"
        fi

Indentation is a mess throughout. It makes it virtually impossible to follow, even if you are familiar with the language (which I'm mostly not).
Other things:
  • It uses inuse and ffmpeg without testing they are present. It didn't fail gracefully on my system where inuse wasn't installed.
  • It processes folders starting with '[' which, by convention, should not be processed.
Apart from that I like it!
 
Indentation is a mess throughout. It makes it virtually impossible to follow, even if you are familiar with the language (which I'm mostly not).
IMO, any language that uses "fi" instead of "endif" is trying to be cool rather than readable.
 
I like C style braces with the '{' and '}' aligned in the same column (never ever with the '{' hanging on the end of a line) and with them omitted if only using a single statement (unless necessary to force the else to an outer if):
Code:
if (x)
    foo();
else
    bar();
 
if (x)
{
    foo();
    bar();
    if (y)
    {
        foo2();
        bar2();
    }
    else
        foo2();
}
else
{
    bar();
    foo();
}
 
Indentation is a mess throughout. It makes it virtually impossible to follow, even if you are familiar with the language (which I'm mostly not).
Other things:
  • It uses inuse and ffmpeg without testing they are present. It didn't fail gracefully on my system where inuse wasn't installed.
  • It processes folders starting with '[' which, by convention, should not be processed.
Apart from that I like it!

Sorry about the readability. It's not a language (or environment) I'm familiar with either. This is the only Linux shell script I've written.
It seems the editors I've used have left me with a mix of tabs and spaces which look fine to me but didn't copy and paste correctly.

I could look at checking for ffmpeg and inuse and for ignoring folders starting with [ (and fixing the indenting while I'm at it). I don't think it would be too much trouble.
 
I like the concept. It could be fairly easily converted to Jim using the existing web interface libraries, and then implemented as an automatic post-decryption hook.
 
I have made a few more changes to the script following prpr's feedback
  • Fixed the indenting (I think)
  • Check for required packages being installed
  • Don't process files in folders wrapped in square brackets
  • Reduce the priority to prevent affecting in-progress recordings
  • Added some comments
  • Only run auto tasks (e.g. decrypt) in "overnight" mode
Code:
targetTime="400"
fallbackTarget="200"
slowForSD="1"
logActionsOnly="1"
 
# Check for required packages
packagesFound="0"
if hash inuse 2>/dev/null;
then
    if hash ffmpeg 2>/dev/null;
    then
        if [ "$1" == "STANDBY" ]
        then
            if hash ir 2>/dev/null;
            then
                packagesFound="1"
            fi
        else
            packagesFound="1"
        fi
    fi
fi
 
# Exit if packages are missing
if [ $packagesFound == "0" ]
then
    if [ "$1" == "STANDBY" ]
    then
        echo "--- ERROR Thumbnails requires packages inuse, ffmpeg and ir for batch mode ---"
    else
        echo "--- ERROR Thumbnails requires packages inuse and ffmpeg ---"
    fi
    exit 1
fi
 
# Change the process priority to be a low value
renice 19 -p $$
 
# For overnight mode run any pending auto tasks first
if [ "$1" == "STANDBY" ]
then
    if [ $logActionsOnly == "0" ]
    then
        echo "  "`date +"%d-%m %H:%M"`" Running auto task"
    fi
    /mod/webif/lib/bin/auto
fi
 
cd /
cd "media/My Video"
 
# Loop through all *.ts files in the My Video folder
find . -type f -name "*.ts" | while read fileTS
do
    file=${fileTS#*/}
    fileRoot=${file%.ts}
    process="0"
 
    case "$file" in
   
    \[[^/]*\]/* )
        if [ $logActionsOnly == "0" ]
        then
            echo "  "`date +"%d-%m %H:%M"`" ignoring [folder] $file"
        fi
        ;;
    * )
 
        # Check if the current file is in use (still recording, being watched etc)
        inuse "$file"
       
        if [ $? == "0" ]
        then
            if [ $logActionsOnly == "0" ]
            then
                echo "xx "`date +"%d-%m %H:%M"`" In use $file"
            fi
        else
            if [ -f "$fileRoot.thm" ]
            then
                # Check if the fourth byte is altered
                checkByte=`hexdump -n1 -s3 -e'"" 1/1 "%02x"' "$fileRoot.thm"`
                fileSize=$(stat -c '%s' "$fileRoot.thm")
 
                # Is this a Humax generated file (original size, original 4th byte)
                if [ $checkByte == "ff" ] && [ $fileSize == "43680" ]
                then
                    process="1"
                fi
            else
                # No thumbnail exists
                process="1"
            fi
       
 
            if [ $process == "1" ] && [ -f "$fileRoot.hmt" ]
            then
                flags=`hmt "$fileRoot.hmt" | grep -o 'Flags: .*$'`
 
                markFile="1"
                if [ "${flags/*ODEncrypted*}" == "" ]
                then
                    if [ $logActionsOnly == "0" ]
                    then
                        echo "xx "`date +"%d-%m %H:%M"`" Encrypted $file"
                    fi
                    markFile="0"
                else
                    videoID=`hmt "$fileRoot.hmt" | grep -o 'Video PID:.*$'`
                    videoID=${videoID#Video PID}
                    audioID=`hmt "$fileRoot.hmt" | grep -o 'Audio PID:.*$'`
                    audioID=${audioID#Audio PID}
               
                    if [ $audioID == $videoID ]
                    then
                        if [ $logActionsOnly == "0" ]
                        then
                            echo "xx "`date +"%d-%m %H:%M"`" $file is audio only"
                        fi
                    else
                        # Run the ffmpeg command to generate a thumbnail
                        cat /dev/null | ffmpeg -loglevel quiet -ss "$targetTime" -i "$file" -frames 1 -pix_fmt bgra -vf vflip -s 140x78 TempThumb.bmp > /dev/null 2>&1
                       
                        attemptSlowCapture="0"
                       
                        # Was the thumbnail generated
                        if [ ! -f TempThumb.bmp ]
                        then
                            attemptSlowCapture="1"
                        else
                            # Is the thumbnail all grey
                            picStart=`hexdump -s 54 -n 32 -v -e'"" 1/1 "%02x"' TempThumb.bmp`
                            if [ $picStart == "818181ff818181ff818181ff818181ff818181ff818181ff818181ff818181ff" ]
                            then 
                                echo "xx "`date +"%d-%m %H:%M"`" $file thumb looks faulty"
                                attemptSlowCapture="1"
                            fi                       
                        fi
 
                        if [ $attemptSlowCapture == "1" ]
                        then
                            echo "xx "`date +"%d-%m %H:%M"`" $file requires fallback method"
                            if [ "${flags/*SD*}" == "" ] && [ $slowForSD == "1" ]
                            then
                                echo "-- "`date +"%d-%m %H:%M"`" Attempting slow capture $file"
                               
                                cat /dev/null | ffmpeg -loglevel quiet -i "$file" -r 25 -ss "$targetTime" -frames 1 -an -pix_fmt bgra -vf vflip -s 140x78 TempThumb.bmp > /dev/null 2>&1
                            else
                                echo "-- "`date +"%d-%m %H:%M"`" Attempting fallback thumbnail $file"
                                cat /dev/null | ffmpeg -loglevel quiet -ss "$fallbackTarget" -i "$file" -r 25 -frames 1 -an -pix_fmt bgra -vf vflip -s 140x78 TempThumb.bmp > /dev/null 2>&1
                            fi
                        else
                            echo "++ "`date +"%d-%m %H:%M"`" Thumbnail created $file"
                        fi
                    fi
               
                    if [ -f TempThumb.bmp ]
                    then
                        # Trim the bitmap header from the start of the file
                        dd bs=54 skip=1 if=TempThumb.bmp of="$fileRoot.thm" > /dev/null 2>&1
                        rm TempThumb.bmp
                    fi
       
                    if [ -f "$fileRoot.thm" ] && [ $markFile == "1" ]
                    then
                        # Alter the 4th byte of the thumbnail to show this script has generated it
                        echo -ne \\xFE | dd conv=notrunc bs=1 count=1 seek=3 of="$fileRoot.thm" > /dev/null 2>&1
                    fi
                fi
            else
                if [ $logActionsOnly == "0" ]
                then
                    if [ -f "$fileRoot.hmt" ]
                    then
                        echo "-- "`date +"%d-%m %H:%M"`" Already processed $file"
                    else
                        echo "-- "`date +"%d-%m %H:%M"`" No media information for $file"
                    fi
                fi
            fi
        fi
        ;; 
    esac
done
 
if [ "$1" == "STANDBY" ]
then
    if [ $logActionsOnly == "0" ]
    then
        echo "  "`date +"%d-%m %H:%M"`" Shutting down"
    fi
    ir STANDBY >> /dev/null
fi

to run frequently (example shown is at listed minutes of each hour) add the following line (or similar) to /mod/var/spool/cron/crontabs/root

16,26,36,46,56 * * * * path/to/script >> /mod/tmp/thumbnail.log 2>&1

to run overnight (example is at 1 minute past 6am)

1 6 * * * path/to/script STANDBY >> /mod/tmp/thumbnail.log 2>&1
 
Perhaps the auto-thumbnail process can have a "blank" option for people who prefer not to have a thumbnail at all

Yes - I was thinking of a new package (name to be decided) with options to:

Replace all system generated thumbnails with:
  • blank;
  • custom image

Hi, did these options ever get implemented? I really can't understand the point of thumbnails for recordings - i'm sure 99% people select a recording by it's name and not by image. Even so, users could simplify their recordings list easier (especially if they're not all in dedicated folders) if say: all children's recordings have a thumbnail of a teddy bear; all films have a picture of a directors clapperboard, etc etc. Of course it's up to the user what they select but it's important to have choice, so having a 'custom image' option is just as important as having a blank option.
 
Yes, sort of. Bring up the programme details in WebIF >> Browse Media Files. Click the OPT+ button and see the thumbnail options. This gives you the opportunity to select another still from the video (one that is relevant to the programme rather than wherever the recording happened to start.

Having a library of icons or the option to upload ones own graphic is not currently on the road map, but it's fairly easy to DIY.
 
Last edited:
Update: a self-contained process has been developed for decrypted recordings (see the rest of this topic), but actually there is a process which would achieve the desired effect (albeit long-winded):
  1. Set a bookmark at the desired thumbnail frame (it must be the first bookmark in the recording);
  2. Perform a WebIF crop operation (this removes everything in front of the bookmark, but saves the previous recording as backup);
  3. Play the cropped file (this causes the Humax to generate a thumbnail for the "new" recording);
  4. Use FTP or Telnet to copy the new thumbnail to the thumbnail of the backup set;
  5. Delete the cropped set;
  6. Move the backup set back to the main folder (optionally delete the "_original" folder).
I have not tested this, but observations indicate it should work. Note that is does not require the recording to have been decrypted.

Hi 'Black Hole' - could you clarify number:4 - i've ftp'd into my box but don't understand when you say copy thumbnail..... how do you do this exactly. Thanks.
 
The thumbnail image is contained in a file <recording-name>.thm. Just copy the file across.

You don't need to do that though, just use the WebIF tools I have already pointed you at.
 
The thumbnail image is contained in a file <recording-name>.thm. Just copy the file across

Ah, my mistake was to ftp into the box via the web browser (effectively accessing the Webif), when i should of ftp'd via 'File Explore' (windows 8.1) where i can access all the sub-files.... so it's just a case of replacing the old .thm with the .thm from the new version. I should of thought of that, sorry to ask a stupid question!
wink.png


You don't need to do that though, just use the WebIF tools I have already pointed you at.

...yeah i know but i wanted to test out what you said in an old conversation (post#9), just to see if it still worked. I can then use this method (your method) to select my very own thumbnail image - ie. not one that is relevant to the programme (as per my post #129), but from a completely different recording. Generally in my opinion, the default/programme relevant thumbnails are a complete waste of time.

I'll use your 'albeit long-winded' process to copy a thumbnail from a different recording (a movie) where the intro has about 2-3 seconds of black (before the title sequence) thus creating my own custom blank thumbnail that i can apply to all my recordings. I also wanted to clarify what you meant for other future readers incase they did what i did, D'oh!
redface.png


As you stated, "...having a library of icons or the option to upload ones own graphic is not currently on the road map, but it's fairly easy to DIY" - and now i've just demonstrated that, with another option to apply any thumbnail to any recording, not just one that's been cropped from the original source material.

Thanks again.
 
Hi, did these options ever get implemented? I really can't understand the point of thumbnails for recordings - i'm sure 99% people select a recording by it's name and not by image. Even so, users could simplify their recordings list easier (especially if they're not all in dedicated folders) if say: all children's recordings have a thumbnail of a teddy bear; all films have a picture of a directors clapperboard, etc etc. Of course it's up to the user what they select but it's important to have choice, so having a 'custom image' option is just as important as having a blank option.

If you use theTVDB option of the webif to retrieve series information from the web it will show, if available, an image for the episode on the program details page.
These images are not currently stored as thumbnails so are not available via the TV remote interface but are usually more relevant than the auto generated thumbnails.
 
Ah, my mistake was to ftp into the box via the web browser (effectively accessing the Webif), when i should of ftp'd via 'File Explore' (windows 8.1) where i can access all the sub-files.... so it's just a case of replacing the old .thm with the .thm from the new version. I should of thought of that, sorry to ask a stupid question!
wink.png
s/of/have/g
 
I don't understand that bit. FTP via the web browser? Do web browsers offer FTP access??

My understanding is that you can access a Humax via FTP in two ways (from a Windows machine):

(i) - to view the whole file structure (the raw files only), for the purpose of "Foxy'ing" the .hmt file (non-custom firmware). Or to copy/paste a new thumbnail post #131 (click) . I use Windows 'File Explorer' and enter: ftp://192.*****.*.* in the address bar. To logon type: humaxftp (with password): 0000

(ii) - to use the custom firmware graphical user interface (Webif). I open a web browser using Google Chrome (or it can be Internet Explorer), and type: http://192.***.*.*** in the Address/URL bar.

Having said all of that i suspect many reading this forum are using a Linux operating system so maybe things are different for you guys....?


If it's not too presumptuous, a moderator/member of staff can use this post to update the FTP section for clarification if need be?
Thanks


(edited to include: via FTP)
 
Last edited:
Back
Top