Ok, here is my test case.
The attached scripts implement the test case; the initial "builtin.avs" attached by gamez is also needed to run the normal chain (see below).
At the end are the results that IMHO point to a leak in the implementation of the Overlay() filter.
By the way the scripts are also a nice example of using arrays:
- to make your life better (and the code listings much shorter) in general,
- to create a for...next loop in Avisynth.
What the script-set does in brief is to code all of the images and intermediate bitmaps as array data and them to execute a for...next loop to combine them to the final result.
The breakdown to pieces of 25 images per step (8 steps in total) is hard-coded inside the mv.avs script's body. The global variable chain_part informs the script about what part of the chain to execute. It has to be set for each step from the command line (see section 1.2 below).
1. Prerequisites
1.1. Required software:- Avisynth, version 2.5.6
- AVSLib, version 1.0.0.
- The 1.0.1 patch version of AVSlib (from the above location). The patch must be installed after the installation of AVSLib 1.0.0. The patch offers (for Avisynth 2.5.6 and later only) arrays of practically unlimited length; it is also needed for the scripts to execute.
- Configuration of your system so that at least 2.2 GB of total (ram+swap) memory are available (the "Limit" field at Task Manager's dialog box should report > 2200000)
- VirtualDub, version 1.5.10 or later
- XviD 1.0.3 Codec
The later two are needed for exactly reproducing my setup and comparing the results; I assume any selected video compression method will work for encoding the results.
1.2. Script edits / creation of environment
- The path on the first line of the mv.avs (main) script must change to the location where you have installed the AVSLib loader (avslib-h.avsi).
- From a command prompt you must cd to the scripts' directory and issue the following two commands:
Code:
echo return 0 > mv_chain.ini
echo return 0 > mv_built.ini
This will setup the main script for normal operation at step 0 of the script chain.
- For later steps (1,2,...,7) you must issue a
Code:
echo return X > mv_chain.ini
command (X = 1,2,...,7) before invoking the main script again.
- For each successive step you must save the output video as: mvout0.avi, mvout1.avi, mvout2.avi, ... and so on up to the last step.
- If you are gamez:
i. Edit the line (no #6 inside mv.avs):
Code:
global __debug__ = true
to
Code:
global __debug__ = false
ii. Check the "bmps" and "bmp_ids" arrays in mvinc.avsi; they may need some adjustment because I think I have missed three items during copying and pasting from your sources. This is the only thing that may make the output to deviate from the intensions of your initial script.
- If you are not gamez:
i. Create a folder and put inside:
a. 402 JPEG photos with dimensions at least those reported at the top message of this forum thread, named {anything}001.jpg, ..., {anything}402.jpg
b. one JPEG photo with same dimensions and name "z.jpg" (for the transition effect).
- Edit lines #19 and #75 in mvinc.avsi to point at the above folder (don't forget to include {anything} in a1., above, at the end of the path).
- Edit the "chain_last" function in mv.avs (lines #48 - 58) to insert an audio of your choice (this will only be called at step 7 of the script chain).
2. Execution
i. As said above, before each step, issue this command (at the command prompt, with active dir the script's dir):
echo return X > mv_chain.ini
Substitute 0,1,2,3,4,5,6,7 for X. Save the output video as mvoutX.avi.
ii. Executing the normal (with effects and the call to Overlay()) chain is the default, if all steps above have been made. If after playing with debug chains you want to revert to normal execution, issue this command (at the command prompt):
echo return 0 > mv_built.ini
iii.To execute a debug chain, issue one of the three commands below:
echo return 1 > mv_built.ini (uses Layer instead of Overlay)
echo return 2 > mv_built.ini (in addition to the case above, does not use Animate)
echo return 3 > mv_built.ini (in addition to the cases above, does not use the transition mask effect)
iii.For inspecting memory consumption, record the total memory before and after opening and encoding (saving as AVI) the script in VirtualDub.
3. Results
With my setup:
1. images of ~2.2 MB each
2. VirtualDub 1.5.10 as renderer
3. XviD 1.0.3 Codec for video compression, with settings:
a. profile / level: AS @ L5
b. target quantizer: 1.00
c. quantization type: MPEG
d. quarter pixel: true
e. global motion compensation: true
f. Motion search precision: 6
g. Use chroma motion: true
h. Trellis quantization: true
4. PC: Pentium-M 1.7GHz / 1GB RAM / ATI Mob. Radeon 9600 AGP, 350MHz, 64MB / XP-Pro, SP2 / avisynth.dll 2.5.6.0
The following results are obtained:
1. Executing the normal chain, required ~ 1.34 GB memory to fully encode the first part (step 0).
2. Executing the first debug chain (Overlay replaced by Layer in the transition function), required ~ 0.52 GB to fully encode the first part (step 0)
3. Executing the other debug chains (without Overlay + Animate / without Overlay + Animate + Transition) required similar amount of memory with the first debug chain.
4. This means ~ 0.82 extra GB are due to Overlay() alone (for about 4000 frames, ie ~ 200 KB per frame).
5. The memory consumption between opening the script and the appearance of the first frame at VirtualDub's input window was about the same for all cases (approx. 0.3 GB). The build-up of the great difference in consumption between the normal and the debug chains is performed during the serving of frames to the encoder.
6. The extra memory required to encode the normal chain is 160% of the debug chains; this is too much and thus it is probably a sign of a memory leak somewhere inside the Overlay() code.