Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Fedor  
#1 Posted : Friday, April 09, 2004 9:52:00 PM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,481

Thanks: 3 times
Was thanked: 40 time(s) in 39 post(s)
Here are some samples for using AVI Processor in ASP.NET. Each sample is implemented with early and late binding. If you will use early binding, then you will have to copy AviProcessor.Interop.dll to bin folder.

1. This sample code enumerates all installed compressors on computer using Next method and IsValid & Current properties:

Code:
<%@ Page aspcompat="true"%>
<%
Dim compressors, c 
compressors = Server.CreateObject("AviProcessor.AviCompressors")
Do
	c = compressors.Current
	If c.IsValid Then
		Response.Write(c.Name & ": " &  c.Handler & ": " & c.Description & "
")
	End If
Loop While compressors.Next() 
%>


Code:
<%@ Page aspcompat="true"%>
<%@ Import Namespace="Aurigma.AviProcessor"%>
<%
Dim compressors As New AviCompressors
Do
	Dim c As AviCompressor = compressors.Current
	If c.IsValid Then
		Response.Write(c.Name & ": " &  c.Handler & ": " & c.Description & "
")
	End If
Loop While compressors.Next() 
%>


2. This sample code creates new empty AVI, selects DivX Mpeg-4 as video compressor, adds all JPG files from some folder, and finally adds sound track from WAV file.

Code:
<%@ Page aspcompat="true"%>
<%
Dim writer
writer = Server.CreateObject("AviProcessor.AviWriter")
writer.CompressorHandler = 1482049860 'DivXPro5Compressor
writer.Quality = 8000
writer.CreateNew("c:\Images\MyVideo.avi", 300, 300)
writer.AddImages("c:\Images\*.jpg", True)
'writer.AddWav("c:\Images\Sounds.wav")
%>


Code:
<%@ Page aspcompat="true"%>
<%@ Import Namespace="Aurigma.AviProcessor"%>
<%
Dim writer As New AviWriter
writer.CompressorHandler = 1482049860 'DivXPro5Compressor
writer.Quality = 8000
writer.CreateNew("c:\Images\MyVideo.avi", 300, 300)
writer.AddImages("c:\Images\*.jpg", True)
'writer.AddWav("c:\Images\Sounds.wav")
%>


3. This sample code reads existing AVI and saves frame sequence to separated JPG files:

Code:
<%@ Page aspcompat="true"%>
<%
Dim reader 
reader = Server.CreateObject("AviProcessor.AviReader")
reader.Open("c:\windows\clock.avi")
reader.Frames.SaveSeq(0, 10, "C:\temp\clip_frame_", ".jpg")
%>


Code:
<%@ Page aspcompat="true"%>
<%@ Import Namespace="Aurigma.AviProcessor"%>
<%
Dim reader As New AviReader
reader.Open("c:\windows\clock.avi")
reader.Frames.SaveSeq(0, 10, "C:\temp\clip_frame_", ".jpg")
%>


4. This sample code extracts frames from existing AVI by one to separated JPG files

Code:
<%@ Page aspcompat="true"%>
<%
Dim reader 
reader = Server.CreateObject("AviProcessor.AviReader")
reader.Open("c:\windows\clock.avi")
Dim I As Integer
For i = 0 To reader.Frames.Count - 1
	reader.Frames(i).SaveFile("C:\temp\clip_frame_" & CStr(i) & ".jpg")
Next 
%>


Code:
<%@ Page aspcompat="true"%>
<%@ Import Namespace="Aurigma.AviProcessor"%>
<%
Dim reader As New AviReader
reader.Open("c:\windows\clock.avi")
Dim I As Integer
For i = 0 To reader.Frames.Count - 1
	reader.Frames(i).SaveFile("C:\temp\clip_frame_" & CStr(i) & ".jpg")
Next 
%>


5. This sample code opens existing AVI and creates new AVI with almost the same content but with additional watermark image and timer:

Code:
<%@ Page aspcompat="true"%>
<%
Dim writer
writer = Server.CreateObject("AviProcessor.AviWriter")
Dim reader
reader = Server.CreateObject("AviProcessor.AviReader")
' Making new AVI file with the same sizes and compressor
reader.Open("c:\windows\clock.avi")
writer.CompressorHandler = 1129730893 'reader.CompressorHandler
writer.CreateNew("c:\images\NewVideo.avi", reader.Width, reader.Height)
' Prepare watermark content
writer.Watermark.AddImage("c:\Images\Watermark.gif", 5, 5)
writer.Watermark.AddTimer(5, reader.Height-20, , , , , , &h0000FF)
reader.Close
' Closes reader for releasing source AVI file
' Copying all frames from old AVI to new one
writer.AddAvi("c:\windows\clock.avi")
writer.Close
%>


Code:
<%@ Page aspcompat="true"%>
<%@ Import Namespace="Aurigma.AviProcessor"%>
<%
Dim writer As New AviWriter
Dim reader As New AviReader
' Making new AVI file with the same sizes and compressor
reader.Open("c:\windows\clock.avi")
writer.CompressorHandler = 1129730893 'reader.CompressorHandler
writer.CreateNew("c:\images\NewVideo.avi", reader.Width, reader.Height)
' Prepare watermark content
writer.Watermark.AddImage("c:\Images\Watermark.gif", 5, 5)
writer.Watermark.AddTimer(10, _
	reader.Height-20, _
	TimerStyleConstants.TimerStyleTime, _
	0, _
	"Arial", _
	FontStyleConstants.FontStyleRegular, _
	12, _ 
	Convert.ToUInt32(&h0000FF), _
	Convert.ToUInt32(&h0000FF), _
	0, _
	Convert.ToUInt32(&h0000FF), _
	0, _
	70)

reader.Close
' Closes reader for releasing source AVI file
' Copying all frames from old AVI to new one
writer.AddAvi("c:\windows\clock.avi")
writer.Close
%>

Edited by user Monday, December 24, 2007 6:02:57 PM(UTC)  | Reason: Not specified

Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.