tacman1123
29th June 2008, 18:44
I'm pleased to announce the alpha release of AVSPP, an Avisynth Preprocessor, available on sourceforge at
https://sourceforge.net/project/showfiles.php?group_id=232121
One of the more difficult tasks I've had an an Avisynth newcomer is getting sample scripts to work. Often a sample on the forum is dependent on something being installed, or runs on the author's machine and files but is difficult to replicate.
Another issue is easily processing a batch of files, such as all the jpegs in a directory. Finally, Avisynth control blocks are very cumbersome for the newcomer to use, and difficult to debug.
The Avisynth Preprocessor aims to make some of these issues easier. While it lacks documentation right now, I'll present two simple scripts the introduce some of the benefits of avspp.
# slideshow1.avp: very simple display of a directory of jpg's, resizing them to fit
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
dissolve_time = 15
slide_time = 75
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Basic Slideshow")
<? foreach ('c:\photos\*.jpg') as $fn) { ?>
a = ImageSource("<?=$fn?>").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
<? } ?>
return video
The initial setup is probably familiar to most people. The PHP scripting is handled inside of <? ... ?> tags. In this simple example, each jpg in the c:\photos directory is processed. The avisynth script it produces is
# slideshow1.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
dissolve_time = 15
slide_time = 75
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Basic Slideshow")
a = ImageSource("C:\photos\2179140185_d7fd61f19a_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
a = ImageSource("C:\photos\2179141497_af5c7dc947_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
return video
(Note: for simplcity, I've shortened the result to just 2 slides, obviously the power comes in not having to type in all the names of a much longer list of files.)
Of course, the problem with this simple script is that portrait files are stretched and look ugly. As part of Mike's KBE routines is a function called ZoomBox. The normal procedure to incorporate this would be to find the thread, cut out the code into your script or an avsi file, and make your code work. AVSPP automates this by extracting code from doom9 threads into a temporary file.
Here's a second example, with ZoomBox.
# slideshow2.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Slideshow with no resizing")
# the zoombox function requires Avisynth 2.58, which has max() as a native function.
# define it here for 2.57 users
function max(x,y) { return x > y ? x : y }
<?
/*
import_code() is a function that goes to the zoom9 forums and grabs the first block,
and puts that block of code into the avspp download directory (default is a directory named 'downloads'
in the directory where avspp.exe. The second parameter is the local name of the file.
Once the code has been downloaded to a local file, it can be called by Avisynth with import.
In this case, we want the code for the ZoomBox routine, which will preserve the aspect ratio
when resizing the photo, so that the pictures are not distorted.
*/
import_code('http://forum.doom9.org/showthread.php?p=1111789#post1111789', "zoom.avsi");
# this
foreach (glob(dirname(__FILE__) . '\loc_photos\*.jpg') as $fn)
{
?>
a = ImageSource("<?=$fn?>").ConvertToRGB32().AssumeFPS(F).Trim(0, 90).ZoomBox(W, H)
video = Dissolve(video, a, 20)
<?
}
?>
video
The relevant line here is import_code, which automatically extracts the code, creates the .avsi file, and includes it, so running
avspp examples\slideshow2.avp
will create examples\slideshow2.avs, which looks like
# slideshow2.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Slideshow with no resizing")
# the zoombox function requires Avisynth 2.58, which has max() as a native function.
# define it here for 2.57 users
function max(x,y) { return x > y ? x : y }
#Getting http://forum.doom9.org/showthread.php?p=1111789#post1111789
# from S:\vt\avspp\downloads\zoom.avsi
import("S:\vt\avspp\downloads/zoom.avsi")
a = ImageSource("S:\vt\avspp\examples\loc_photos\2179140185_d7fd61f19a_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, 90).ZoomBox(W, H)
video = Dissolve(video, a, 20)
video
I have some other examples I'm working on, including an easy way to use the KenBurnsEffect that Mike's been working on. I'd also like to use the Avisynth Library, which looks really cool but lacks examples.
Avspp can also download images from the internet, which will make presenting examples much, much easier (I'll post that example shortly), and in the future will be able to get dll's.
Anyway, I'm quite jazzed about this script, I want to thank the doom9 community for all their support, and hope that this tool will grow into something useful for Avisynth fans.
I look forward to comments and feedback!
Tac
https://sourceforge.net/project/showfiles.php?group_id=232121
One of the more difficult tasks I've had an an Avisynth newcomer is getting sample scripts to work. Often a sample on the forum is dependent on something being installed, or runs on the author's machine and files but is difficult to replicate.
Another issue is easily processing a batch of files, such as all the jpegs in a directory. Finally, Avisynth control blocks are very cumbersome for the newcomer to use, and difficult to debug.
The Avisynth Preprocessor aims to make some of these issues easier. While it lacks documentation right now, I'll present two simple scripts the introduce some of the benefits of avspp.
# slideshow1.avp: very simple display of a directory of jpg's, resizing them to fit
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
dissolve_time = 15
slide_time = 75
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Basic Slideshow")
<? foreach ('c:\photos\*.jpg') as $fn) { ?>
a = ImageSource("<?=$fn?>").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
<? } ?>
return video
The initial setup is probably familiar to most people. The PHP scripting is handled inside of <? ... ?> tags. In this simple example, each jpg in the c:\photos directory is processed. The avisynth script it produces is
# slideshow1.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
dissolve_time = 15
slide_time = 75
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Basic Slideshow")
a = ImageSource("C:\photos\2179140185_d7fd61f19a_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
a = ImageSource("C:\photos\2179141497_af5c7dc947_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, slide_time).BilinearResize(W, H)
video = Dissolve(video, a, dissolve_time)
return video
(Note: for simplcity, I've shortened the result to just 2 slides, obviously the power comes in not having to type in all the names of a much longer list of files.)
Of course, the problem with this simple script is that portrait files are stretched and look ugly. As part of Mike's KBE routines is a function called ZoomBox. The normal procedure to incorporate this would be to find the thread, cut out the code into your script or an avsi file, and make your code work. AVSPP automates this by extracting code from doom9 threads into a temporary file.
Here's a second example, with ZoomBox.
# slideshow2.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Slideshow with no resizing")
# the zoombox function requires Avisynth 2.58, which has max() as a native function.
# define it here for 2.57 users
function max(x,y) { return x > y ? x : y }
<?
/*
import_code() is a function that goes to the zoom9 forums and grabs the first block,
and puts that block of code into the avspp download directory (default is a directory named 'downloads'
in the directory where avspp.exe. The second parameter is the local name of the file.
Once the code has been downloaded to a local file, it can be called by Avisynth with import.
In this case, we want the code for the ZoomBox routine, which will preserve the aspect ratio
when resizing the photo, so that the pictures are not distorted.
*/
import_code('http://forum.doom9.org/showthread.php?p=1111789#post1111789', "zoom.avsi");
# this
foreach (glob(dirname(__FILE__) . '\loc_photos\*.jpg') as $fn)
{
?>
a = ImageSource("<?=$fn?>").ConvertToRGB32().AssumeFPS(F).Trim(0, 90).ZoomBox(W, H)
video = Dissolve(video, a, 20)
<?
}
?>
video
The relevant line here is import_code, which automatically extracts the code, creates the .avsi file, and includes it, so running
avspp examples\slideshow2.avp
will create examples\slideshow2.avs, which looks like
# slideshow2.avp: goes through a directory of photos
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
video = BlankClip(1, W, H, "RGB32", F, stereo=false).Trim(0, 1).KillAudio().Subtitle("Slideshow with no resizing")
# the zoombox function requires Avisynth 2.58, which has max() as a native function.
# define it here for 2.57 users
function max(x,y) { return x > y ? x : y }
#Getting http://forum.doom9.org/showthread.php?p=1111789#post1111789
# from S:\vt\avspp\downloads\zoom.avsi
import("S:\vt\avspp\downloads/zoom.avsi")
a = ImageSource("S:\vt\avspp\examples\loc_photos\2179140185_d7fd61f19a_o.jpg").ConvertToRGB32().AssumeFPS(F).Trim(0, 90).ZoomBox(W, H)
video = Dissolve(video, a, 20)
video
I have some other examples I'm working on, including an easy way to use the KenBurnsEffect that Mike's been working on. I'd also like to use the Avisynth Library, which looks really cool but lacks examples.
Avspp can also download images from the internet, which will make presenting examples much, much easier (I'll post that example shortly), and in the future will be able to get dll's.
Anyway, I'm quite jazzed about this script, I want to thank the doom9 community for all their support, and hope that this tool will grow into something useful for Avisynth fans.
I look forward to comments and feedback!
Tac