bigboss97
11th May 2011, 12:33
I'm writing a program which generates a slide show script from an image database. The program uses Avisynth API to display the slide show frame by frame. Everything is working. But it takes sometime to process the script (before the slide show).
Since the script is generated automatically I have to use some variables to make the codes repeatable.
global ScrWidth= 640
global ScrHeight= 480
FPS= 16
TransLen= 32 #---- Frames of a transition
ImgLen= 64/2 +32 #---- Frames for a single image
import("head.avs")
B= KillAudio( BlankClip( ImgLen, ScrWidth, ScrHeight, color=$000000, pixel_type="RGB24"))
Img00064=""
A= B
B= Image2Clip("folksKJ_1024.jpg", ImgLen, 1)
V00= Dissolve( A,B, TransLen)
Img00160="02/12/2007 13:53"
A= B
B= Image2Clip(".\..\..\..\Photos\20071202_HydePark\r0010778.jpg", ImgLen, 1)
V01= TransBubbles( A,B, TransLen)
*snip*
Img01888="30/03/2011 10:34"
A= B
B= Image2Clip(".\..\..\..\Photos\20110326_Mexico\0329_San_Cristobal\img_2191.jpg", ImgLen, 1)
V19= TransBubbles( A,B, TransLen)
V20= B.FadeOut( TransLen)
V00+ V01+ V02+ V03+ V04+ V05+ V06+ V07+ V08+ V09+ V10+ V11+ V12+ V13+ V14+ V15+ V16+ V17+ V18+ V19+ V20
Since the resolution of the screen is usually lower than the digital photos most of the time they got downsized. I don't know how Avisynth operations are executed. I guess if I downsize the image at the right place all following operations can save a lot of time.
Any suggestions for optimization?
LoadPlugin("TransAll.dll")
SetMemoryMax(64)
function Image2Clip( string FName, int ImgLen, int Ortn)
{
B= KillAudio( BlankClip( 1, ScrWidth, ScrHeight, color=$001144, pixel_type="RGB24"))
C= Ortn== 3 ? ImageSource( FName).Turn180(): \
Ortn== 6 ? ImageSource( FName).TurnRight(): \
Ortn== 8 ? ImageSource( FName).TurnLeft(): ImageSource( FName)
Width= C.Width
# Width= C.Width/1.333 # Fix distortion of 4:3 resolution on 16:9 screen
ImgIsWide = float(Width)/C.Height >= float(ScrWidth)/ScrHeight
Fact= ImgIsWide ? 1.0 *ScrWidth/Width : 1.0 *ScrHeight/C.Height
NewWidth= Round( Fact* Width)
NewHeight= Round( Fact* C.Height)
O= C.BilinearResize( NewWidth, NewHeight)
return B.Overlay( O, (ScrWidth-NewWidth)/2, (ScrHeight-NewHeight)/2).Loop( ImgLen)
}
Thanks
Phuoc
Since the script is generated automatically I have to use some variables to make the codes repeatable.
global ScrWidth= 640
global ScrHeight= 480
FPS= 16
TransLen= 32 #---- Frames of a transition
ImgLen= 64/2 +32 #---- Frames for a single image
import("head.avs")
B= KillAudio( BlankClip( ImgLen, ScrWidth, ScrHeight, color=$000000, pixel_type="RGB24"))
Img00064=""
A= B
B= Image2Clip("folksKJ_1024.jpg", ImgLen, 1)
V00= Dissolve( A,B, TransLen)
Img00160="02/12/2007 13:53"
A= B
B= Image2Clip(".\..\..\..\Photos\20071202_HydePark\r0010778.jpg", ImgLen, 1)
V01= TransBubbles( A,B, TransLen)
*snip*
Img01888="30/03/2011 10:34"
A= B
B= Image2Clip(".\..\..\..\Photos\20110326_Mexico\0329_San_Cristobal\img_2191.jpg", ImgLen, 1)
V19= TransBubbles( A,B, TransLen)
V20= B.FadeOut( TransLen)
V00+ V01+ V02+ V03+ V04+ V05+ V06+ V07+ V08+ V09+ V10+ V11+ V12+ V13+ V14+ V15+ V16+ V17+ V18+ V19+ V20
Since the resolution of the screen is usually lower than the digital photos most of the time they got downsized. I don't know how Avisynth operations are executed. I guess if I downsize the image at the right place all following operations can save a lot of time.
Any suggestions for optimization?
LoadPlugin("TransAll.dll")
SetMemoryMax(64)
function Image2Clip( string FName, int ImgLen, int Ortn)
{
B= KillAudio( BlankClip( 1, ScrWidth, ScrHeight, color=$001144, pixel_type="RGB24"))
C= Ortn== 3 ? ImageSource( FName).Turn180(): \
Ortn== 6 ? ImageSource( FName).TurnRight(): \
Ortn== 8 ? ImageSource( FName).TurnLeft(): ImageSource( FName)
Width= C.Width
# Width= C.Width/1.333 # Fix distortion of 4:3 resolution on 16:9 screen
ImgIsWide = float(Width)/C.Height >= float(ScrWidth)/ScrHeight
Fact= ImgIsWide ? 1.0 *ScrWidth/Width : 1.0 *ScrHeight/C.Height
NewWidth= Round( Fact* Width)
NewHeight= Round( Fact* C.Height)
O= C.BilinearResize( NewWidth, NewHeight)
return B.Overlay( O, (ScrWidth-NewWidth)/2, (ScrHeight-NewHeight)/2).Loop( ImgLen)
}
Thanks
Phuoc