AVTool

An interactive Animate(Crop) editor for AVISynth.

David W. Poole, Jr.

Last updated 2005-04-23 02:24:54 Saturday

What is it?

It is a utility to make it easier to build script files for AVISynth to perform Crop functions with varying arguments pass to it via the Animate function. Huh? It provides an interactive way to perform pan-and-scan functions on your videos. This is handy if you would like to interactively crop certain parts of a video so that you can build, for example, a 320x320 video for your PDA, and would prefer to fill as much of the screen as possible, much as in the way filmed movies are cropped during some conversions. This cropping is called pan-and-scan.

This program allows the user to play through a video, moving a rectangle around on the video, and recording where the user leaves the cropping box. When complete, the program writes a script file that can be used with AVISynth containing the appropriate cropping commands.

Why is it?

I have a video where the subject only takes about a half the screen at any given time, and the remainder of the screen's content is, in my opinion, worthless. I wanted to produce a pan-and-scan video where the subject would have fill a small 320x320 pixel screen, and the video source is 704x480 pixels.

I found AVISynth to be a wonderful tool, but the act of typing cropping commands into a text file and loading them into a video player to see if the cropping parameters were correct was just a tad too much effort. No tools I found provided the interactivity I needed, and none performed the desired interpolation. As I could definitely use some experience with the Video For Windows interface, and some more experience with the Graphic Device Interface, I decided to write my own.

How does it work?

Basically, you decide how large you need the cropping rectangle to be. This will be the the size of the output video. Launch AVTool from a command line, with the name of the Video For Windows compatible video file you wish to crop. Video For Windows means AVI files and whatever other file types you have Video For Windows codecs for installed on your system.

After loading the file, you will be presented with a video edit window and a control dialog. There are two scroll bars on the control dialog. One positions the video by frame, the other by user defined keyframe. At each keyframe you define, you position a cropping rectangle in the Edit Video window, and AVTool displays the cropped video frame in the Preview Video window. For all frames between keyframes, the position of the cropping rectangle is interpolated from the positions of the cropping rectangles for the two surrounding key frames. This interpolation is written to an AVISynth script file utilizing a series of Trim(Animate(Crop())) functions.

Additionally, two adjacent keyframes indicate the end of one clip and the beginning of the next. As of this writing, the only significance of clips for AVTool is that it causes the series of Trim(Animate(Crop())) functions for each clip to be written on a seperate line in the generated script file. The reason it works this way is because I really can't see a need for two consecutive keyframes at any time other than at a scene transition in a video; this makes it a little easier to remove certain segments if so desired. However, if clips are used, the resulting AVISynth script will generate an error when you try to render it, unless you make the appropriate edits to the script file. The type of edits required depend on the goal you are attempting to achieve. If you don't need to remove any clips, you can merely perform a splice with each of the clips.