[These pages contain ready ASP scripts. You can use them in your own applications]

ASP SCRIPT: Creating preview of AVI, MPEG, QuickTime movies

Note: all scripts examples included in these Web pages are absolutely free. You can copy, use, and modify these scripts anyway you want. The scripts are published without warranty of any kind.

What is this

This ASP script builds the thumbnail (preview) image of movie files: AVI, MPEG, or QuickTime. The script uses first movie frame as a preview image. The image size is reducing twice.
If the first frame can not be drawn, the script produces 10x10 black image.

Requirements

Important!
Internet Explorer 4.0 or higher should be installed on your server. The movie files should not be corrupted. Before running this script, try to logon to your NT server interactively and play that kind of movies there. Make sure there are no any error messages.
Your Internet NT account should have permissions to read the movie file and create objects (you can use the dcomcnfg utility to grant those permissions if it will be necessary).
The movie file should have .avi, .mpg, .mpeg, .qt or .mov extension.
Some registry settings must be present on your NT4.0 server to make movie files available through this mechanism. Windows 2000 machine already has all necessary settings installed, so you have not to apply this settings on Windows 2000:

File viewmovie.asp
<%
Response.Contenttype="image/jpeg"
Set g=CreateObject("shotgraph.image")
' The FULL PATH to movie file
movie_file="d:\movies\car1.mpg"

Main()

Sub Main()
g.CheckObject movie_file,xsize,ysize
if xsize>0 then
' The movie file can be drawn. Calculating the new size
	xsize=xsize\2
	ysize=ysize\2
	g.CreateImage xsize,ysize,8
' Drawing the first frame of the movie
	g.DrawObject movie_file,"CONTENT",0,0,xsize,ysize
else
' The movie file can not be drawn
' Creating the empty image 10x10
	xsize=10
	ysize=10
	g.CreateImage xsize,ysize,8
end if
' Outputting image to client
Response.BinaryWrite g.JpegImage(75,0,"")
End Sub
%>

This is the content of the file with registry settings for server:
File movies.reg
REGEDIT4

[HKEY_CLASSES_ROOT\AVIFile]
@="Video Clip"

[HKEY_CLASSES_ROOT\AVIFile\CLSID]
@="{00022602-0000-0000-C000-000000000046}"

[HKEY_CLASSES_ROOT\MOVFile]
@="Video Clip"

[HKEY_CLASSES_ROOT\MOVFile\CLSID]
@="{00022601-0000-0000-C000-000000000046}"

[HKEY_CLASSES_ROOT\mpegfile]
@="Movie Clip"

[HKEY_CLASSES_ROOT\mpegfile\CLSID]
@="{00022601-0000-0000-C000-000000000046}"

[HKEY_CLASSES_ROOT\.mpg]
@="mpegfile"

[HKEY_CLASSES_ROOT\.mpeg]
@="mpegfile"

[HKEY_CLASSES_ROOT\.mov]
@="movfile"

[HKEY_CLASSES_ROOT\.qt]
@="movfile"

[HKEY_CLASSES_ROOT\.avi]
@="avifile"


Back to examples