Creating Thumbnails

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Creating Thumbnails

Post by spectrum »

I am bulding a database holding records of video events. I am trying to make thumnails from each videofile to accompany each record, either as embeded images or links to thumnails.

I downloaded an excellent free program called Easy Thumnails which when manually run produces user specified picture sizes. I am trying to find something similar that I could conduct the operations using VBA within the database. Has anyone seen such an application, prefereably free as non commercial end use. Thanks

User avatar
HansV
Administrator
Posts: 78481
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Creating Thumbnails

Post by HansV »

I assume that you mean Easy Thumbnails from Fookes Software.

I haven't been able to find a way to create thumbnails of videos programmatically. (I found one link to a Technet article that no longer exists... :sad:)
Best wishes,
Hans

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Thanks Hans, yes it's from Fookes Software. Seems to work very well, quick, just would have liked to control it internally. I have sent an email to them, and if anything comes back I will let you know, and maybe others might like the info. Best regards

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Creating Thumbnails

Post by JohnH »

I am not sure whether this question is about controlling Easy Thumbs via VBA, or using it for videos.

You can use Easy Thumbs from within Access using VBA, but I have no experience of using it with videos.

Easy Thumbs accepts a range of Command Line switches, which you can then execute with a Shell Command.

Here is a bit of code from a place I use it. (All the variables are defined elsewher.)

strEZThumbscommandLine = strEZThumbsLocation & strDataPath & strPhotoRelPath & StrPhotofilename & " ,/D=" & strDataPath & strPhotoRelPath & ", P= 'tn_', /W=" & intThumbWidth & " /H=" & intThumbHeight & " /Z=ShrinktoFit"

Retval = Shell(strEZThumbscommandLine, vbHide)
Regards

John

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Thankyou John. I had a reply from Fookes Software and they say controlling Easy Thumnails within Access cannot be done. So your news is welcome.

I have a directory where short videoclips are put after I make backups from the main recordings done overnight. Each recording gets a formatted filename eg 20120129_650152_camera3.mpg (individual camera) or 20120129_650152_Quad.mpg (group of 4 cameras)

What I am trying to do within Access is goto the directory C:/camera , loop through all the video titles making Thumnails of them that can be then used as an example against each recording/record in a database. I can manually do this from opening Easy Thumnails but would like to automate it with vba. Regards

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Creating Thumbnails

Post by JohnH »

Here is some aircode that will create a thumbnail for each file in a nominated directory. The thumbs a put into a subfolder.

Code: Select all

Dim Retval As Variant
Dim strEZThumbsCommandLine as string
Dim strEZThumbsLocation as string
strEZThumbsLocation = "C:\Program Files\Easy Thumbnails\EzThumbs.exe "
Dim strDirectory as string
strDirectory ="c:\Camera\"
Dim strDestinationDirectory as string
strDestinationDirectory ="c:\Camera\thumbs\"
Dim inThumbWidth as integer
intThumbWidth =100
Dim intThumbHeight as integer
intThumbHeight =100
Dim strFName as string
strFName = Dir(strDirectory)

Do While strFName <> ""
strEZThumbsCommandLine =strstrEZThumbsLocation & strDirectory & strFname & " ,/D=" & strDestinationDirectory & ", P= 'tn_', /W=" & intThumbWidth & " /H=" & intThumbHeight & " /Z=ShrinktoFit"
 Retval = Shell(strEZThumbscommandLine, vbHide)
'move to the next file in the list
strFName = Dir()

Loop
Regards

John

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Thankyou for taking the time on this, however I am getting a Runtime Error 5, Invalid call or argument on the line:

Retval = Shell(strEZThumbscommandLine, vbHide).

I created the subfolder thumbs under C:\Camera, remains empty

Thanks again

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Creating Thumbnails

Post by JohnH »

I don't know what the problem is.

Maybe strDestinationDirectory ="c:\Camera\thumbs\" does not need the final "\"?

I would add another line

Debug.Print strEZThumbscommandLine

before the Shell line, then comment out the Shell line (put a ' at the start of the line.)

When you run the procedure the command line will be written to the immediate window. Press Ctrl + G to see that.

Copy a line from the immediate window to a Run dialog and see what happens. Find a version that works from a Run dialog, then go back and modify the code.
Regards

John

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Thanks again. My debug.print looks like this:
c:\Camera\20111201_052317_Camera03.mpg ,/D=c:\Camera\thumbs\, P= 'tn_', /W=100 /H=100 /Z=ShrinktoFit

I also tried removing the extra \ after thumbs, no different

Does it make any sense to you?

JohnH
3StarLounger
Posts: 287
Joined: 09 Mar 2010, 23:16
Location: Canberra Australia

Re: Creating Thumbnails

Post by JohnH »

To understand what that line is doing you need to have read about command line switches in help. Help button is on the About Page.

Here is some slightly different code that I have tested and works for me.

Code: Select all

Dim Retval As Variant
Dim strEZThumbsCommandLine As String
Dim strEZThumbsLocation As String
strEZThumbsLocation = "C:\Program Files\Easy Thumbnails\EzThumbs.exe "
Dim strDirectory As String
strDirectory = "c:\Camera\"
Dim strDestinationDirectory As String
strDestinationDirectory = "c:\Camera\thumbs"
Dim intThumbWidth As Integer
intThumbWidth = 100
Dim intThumbHeight As Integer
intThumbHeight = 100
strEZThumbsCommandLine = strEZThumbsLocation & strDirectory & "*.jpg" & " /D=" & strDestinationDirectory & " P= 'tn_' /W=" & intThumbWidth & " /H=" & intThumbHeight & " /Z=ShrinktoFit"

Retval = Shell(strEZThumbsCommandLine, vbHide)
* I have realised there is no need to write a loop. Easy Thumbs handles that with a wildcard.
* I have also corrected a couple of typos, and removed some commas.

But this does not work for me when I replace *.jpg with *.mpg. In my copy (which may be a bit old) I cannot find anything to say that it works with videos.
Are you sure you are using the same program?
Regards

John

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

John, I feel like like I should dig a big hole and hide. I did not think at the time, but my camera folder contained .mpg's and snapshop pictures. When I used Easy Thumbs manually, it created thumbnails and I thought it had converted everything, but was wrong.

Your code update now works well, no errors. So now I have to find something else to get thumnails from .mpg files. Took it for granted all this time when looking at files with Windows Explorer.

However thanks very much for your bit, valuable part of the link.

Best regards

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

I have realised this is all not a problem. When I am reviewing overnight security video, it takes a second to get a snapshop either of one specific shot, or as a snapshot preceding video footage. So my problems hve gone, and everything is working well with Easy Thumnails now. Just need to do a bypass of mpg extensions and I can carry on with my db creation. Many thanks again for your help.

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Dare I stick my head over the wall again? I have come accross another application that produces thumbnails, this time from mpg files. Therfore if I can get this to work in front of my Easy Thumnails work done by John then it's going to be slicker.

The application is called ffmpg. The only information I found was a description to run it from an MSDOS prompt, and wonder if it could be put in a shell statement. I have tried myself but either make Access freeze or nothing happening. The info I read was:

The instructions I found to run are:

1. FFmpeg.exe to be installed in windows\system32 directory
2. Open a command-prompt window & navigate to the folder where the videos are located.
3. Then type the following:

for %i in (*.mpg) do ffmpeg -i "%i" -f mjpeg -t 0.001 -ss 3 -y "%~ni.tbn"

4. Click "enter".

Thanks again

User avatar
HansV
Administrator
Posts: 78481
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Creating Thumbnails

Post by HansV »

Create a new text file.
Enter the following lines in it:

Code: Select all

@echo off
cd "C:\SomeFolder\Video"
for %%i in (*.mpg) do ffmpeg -i "%%i" -f mjpeg -t 0.001 -ss 3 -y "%%~ni.tbn"
where C:\SomeFolder\Video is the folder containing the videos.

Save and close the text file.
Change its name to CreateThumbs.bat
Windows will warn you that changing the extension may cause problems. Confirm that you want to continue.

Try running this batch file by double-clicking it from Windows Explorer.

If it works OK, try running the batch file from your code as follows:

Code: Select all

Shell "C:\Test\CreateThumbs.bat"
where C:\Test\CreateThumbs.bat is the full path to the batch file.
Best wishes,
Hans

spectrum
StarLounger
Posts: 56
Joined: 24 Jan 2012, 21:48

Re: Creating Thumbnails

Post by spectrum »

Excellent isn't the word Hans, thankyou very much. Yes it all worked, although at first I could not see pictures, it produced TBN files. I changed the part to jpg, and there were my thumbnails. So now with this, and the earlier part helped on by John so I can trim thumnail sizes, I now have all my bits to happily go off and do my database. All the best