Declaration
procedure CloseAVIFile();
Description
Closes an AVI file that was opened with
OpenAVIFile or
CreateAVIFile.
| Demos\VideoCapture\DesktopToAvi\DesktopToAvi.dpr |
| Demos\VideoCapture\ImagesToAvi\ImagesToAvi.dpr |
Example 1
// Create an AVI file from images
ImageEnView.IO.CreateAVIFile( 'D:\output.avi', 20, 'DIB ' );
// Save frame 0
ImageEnView.IO.LoadFromFile('C:\frame0.jpg');
ImageEnView.IO.Params.BitsPerSample := 8;
ImageEnView.IO.Params.SamplesPerPixel := 1;
ImageEnView.IO.SaveToAVI();
// Save frame 1
ImageEnView.IO.LoadFromFile('C:\frame1.jpg');
ImageEnView.IO.Params.BitsPerSample := 8;
ImageEnView.IO.Params.SamplesPerPixel := 1;
ImageEnView.IO.SaveToAVI();
etc...
// Close the file
ImageEnView.IO.CloseAVIFile();
Example 2
// Create an AVI transitioning one image to another
const
Frames_Per_Second = 20;
Display_Seconds = 5;
var
proc: TImageEnProc;
io: TImageEnIO;
startBitmap, endBitmap : TIEBitmap;
i, frameCount: Integer;
transLevel: Single;
begin
startBitmap := TIEBitmap.Create;
endBitmap := TIEBitmap.Create;
proc := TImageEnProc.Create( nil );
io := TImageEnIO.Create( nil );
try
if io.CreateAVIFile('D:\Transition.avi', Frames_Per_Second, 'cvid' ) = ieaviNOCOMPRESSOR then
raise Exception.create( 'This compressor is unavailable!' );
startBitmap.LoadFromFile( 'D:\image1.jpg' );
endBitmap.LoadFromFile( 'D:\image2.jpg' );
// Call PrepareTransitionBitmaps once
proc.PrepareTransitionBitmaps(startBitmap, endBitmap, SelectedTransitionEffect);
frameCount := Display_Seconds * Frames_Per_Second;
for i := 0 to frameCount - 1 do
begin
// We want levels from 0% to 100% (show start and end)
transLevel := 100 / ( frameCount - 1 ) * i;
// Call CreateTransitionBitmap for each required frame
proc.CreateTransitionBitmap( transLevel, io.IEBitmap );
io.SaveToAVI();
Caption := IntToStr( Round( i / frameCount * 100 )) + '%';
end;
io.CloseAVIFile();
Caption := 'Done!';
finally
startBitmap.Free();
endBitmap.Free();
proc.Free();
io.Free();
end;
end;