2012-01-31 427 views
2

在delphi.i中使用Iam初学者创建一个示例应用程序我需要一个help.how在Delphi中使用FFMPEG?如何在Delphi中使用FFMPEG

+4

我看不出这个问题有什么问题 – Simon 2012-02-02 03:41:55

+0

同样适合我,完全有效,因为我在寻找相同的信息 – ruhalde 2013-07-22 17:47:35

回答

4

FFMPEG是一个命令行应用程序,让您可以轻松地使用ShellExecute(),一些例子here调用它。

首先,您需要决定使用哪些命令行开关。

如果您需要进一步的帮助,我可以在明天发布代码。

编辑:

这里是运行一个命令行应用程序的更先进的方法,包括:它的输出重定向到一个备忘录用于观看:

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; 

可以称为像这样:

cmd := 'ffmpeg.exe -i "'+InFile+'" -vcodec copy -acodec copy "'+OutFile+'"'; 
GetDosOutput(cmd,FFMPEGDirectory,MemoLog); 
+0

嗨西蒙,你能给我举个例子 – periyasamy 2012-02-01 10:38:10