Iam beginner in delphi.i create the one sample application i need one help.how to use FFMPEG in inside the delphi?
Asked
Active
Viewed 8,966 times
3
-
4I can't see whats wrong with this question – Simon Feb 02 '12 at 03:41
-
same for me, perfectly valid as I'm searching for same information – ruhalde Jul 22 '13 at 17:47
2 Answers
5
FFMPEG is a command line app, so you can easily call it using ShellExecute()
, with some examples here.
First, however, you need to decide what command line switches to use.
I can post code tomorrow if you need further help.
EDIT:
Here is a more advanced method to run a command line application: It redirects the output to a memo for viewing:
procedure GetDosOutput(CommandLine, WorkDir: string;aMemo : TMemo);
var
SA: TSecurityAttributes;
SI: TStartupInfo;
PI: TProcessInformation;
StdOutPipeRead, StdOutPipeWrite: THandle;
WasOK: Boolean;
Buffer: array[0..255] of AnsiChar;
BytesRead: Cardinal;
Handle: Boolean;
begin
AMemo.Lines.Add('Commencing processing...');
with SA do begin
nLength := SizeOf(SA);
bInheritHandle := True;
lpSecurityDescriptor := nil;
end;
CreatePipe(StdOutPipeRead, StdOutPipeWrite, @SA, 0);
try
with SI do
begin
FillChar(SI, SizeOf(SI), 0);
cb := SizeOf(SI);
dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
wShowWindow := SW_HIDE;
hStdInput := GetStdHandle(STD_INPUT_HANDLE); // don't redirect stdin
hStdOutput := StdOutPipeWrite;
hStdError := StdOutPipeWrite;
end;
Handle := CreateProcess(nil, PChar('cmd.exe /C ' + CommandLine),
nil, nil, True, 0, nil,
PChar(WorkDir), SI, PI);
CloseHandle(StdOutPipeWrite);
if Handle then
try
repeat
WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);
if BytesRead > 0 then
begin
Buffer[BytesRead] := #0;
AMemo.Text := AMemo.Text + Buffer;
end;
until not WasOK or (BytesRead = 0);
WaitForSingleObject(PI.hProcess, INFINITE);
finally
CloseHandle(PI.hThread);
CloseHandle(PI.hProcess);
end;
finally
CloseHandle(StdOutPipeRead);
AMemo.Lines.Add('Processing completed successfully.');
AMemo.Lines.Add('**********************************');
AMemo.Lines.Add('');
end;
end;
It can be called like so:
cmd := 'ffmpeg.exe -i "'+InFile+'" -vcodec copy -acodec copy "'+OutFile+'"';
GetDosOutput(cmd,FFMPEGDirectory,MemoLog);

Simon
- 9,197
- 13
- 72
- 115
0
Here is the encapsulated library of FFmpeg for Delphi.
You may read the documents and try to build the examples.

ciphor
- 8,018
- 11
- 53
- 70