Author: Senn Marco
How can I extract an audio stream of an *.avi file?
Answer:
Note, you must use VfW.pas. You may find this file somewhere in the internet or
simply write me an email. In addition, I was not able to test this code under
Delphi 5.x or lower. Only Delphi 6.x. Please send me a piece of information, if you
can test this for me. Thanks
1 uses VfW;
2 3 function CallBack(i: int): BOOL; pascal;
4 begin5 Label1.Caption := IntToStr(i) + '%';
6 Application.ProcessMessages;
7 Result := False;
8 end;
9 10 procedure TForm1.Button1Click(Sender: TObject);
11 var12 PFile: IAviFile;
13 PAvi: IAviStream;
14 plpOptions: PAviCompressOptions;
15 begin16 AviFileInit;
17 if AviFileOpen(PFile, 'C:\test.avi', 0, nil) <> 0 then18 begin19 ShowMessage('Couldn'' t open * .avi!');
20 Exit;
21 end;
22 if AviFileGetStream(PFile, PAvi, StreamTypeAudio, 0) <> 0 then23 begin24 ShowMessage('Couldn' t load audio stream!');
25 AviFileExit;
26 Exit;
27 end;
28 if AviSaveV('il, @CallBack, 1, PAvi, plpOptions) <> 0 then29 begin30 ShowMessage('Couldn'' t save * .wav - file!');
31 AviStreamRelease(PAvi);
32 AviFileExit;
33 Exit;
34 end;
35 AviStreamRelease(PAvi);
36 AviFileExit;
37 end;