我需要从Windows服务执行ffmpeg进程并捕获其标准输出。在使用硬件加速之前,它工作正常。由于从Windows服务访问DirectX受限制,因此子进程也无法访问它。
当我从控制台应用程序执行相同的代码时,一切正常,但是从Windows服务执行的相同代码无法使用硬件加速。
string ffmpegArgs = /*-hwaccel dxva2 */"-threads 0 -probesize 100512 -i c:/Temp/test.mp4 -vf yadif -vcodec libx264 -preset ultrafast -tune zerolatency -profile baseline -x264-params keyint=20:min-keyint=20:scenecut=-1 -acodec aac -b:a 48k -flags +cgop -f mp4 -movflags empty_moov+default_base_moof+frag_keyframe c:/temp/output.avi";
var psi = new ProcessStartInfo
{
FileName = "c:/Temp/ffmpeg4/ffmpeg.exe",
Arguments = ffmpegArgs,
WorkingDirectory = "c:/Temp/ffmpeg4",
CreateNoWindow = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardInput = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false
};
var processVideo = new Process { StartInfo = psi }.Start();
我需要以某种方式打破继承的限制,以便能够以硬件加速(访问DirectX API)执行ffmpeg。有什么建议吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
您可以指示FFMPEG处理使用DirectX 11 Hardware Video acceleration。 在这种情况下,FFMPEG将需要通过调用DirectX 11 device函数来创建D3D11CreateDevice,该函数不需要提供任何窗口句柄。
为了使FFMPEG充分利用DirectX 11硬件视频加速,您需要改为指定以下hwaccel参数:
-hwaccel d3d11va