如何在Delphi中使用FFMPEG [英] How to Use FFMPEG in inside the Delphi

查看:1159
本文介绍了如何在Delphi中使用FFMPEG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是delphi.i的初学者,我需要一个帮助。如何在delphi中使用FFMPEG?

Iam beginner in delphi.i create the one sample application i need one help.how to use FFMPEG in inside the delphi?

推荐答案

FFMPEG是一个命令行应用程序,因此您可以使用 ShellExecute()轻松调用它,并提供一些示例此处

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.

编辑:

这是运行命令行应用程序的更高级的方法:它将输出重定向到备忘录以供查看:

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;

可以这样称呼:

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

这篇关于如何在Delphi中使用FFMPEG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆