如何将ffmpeg管道从进程重定向到子进程stdin?将ffmpeg管道重定向到子进程
我想达到同样的事情,管道在CMD:
ffmpeg -i test.mov pipe:1 | vlc -
我想:
avio_open("pipe:1"); // ffmpeg open pipe to STD_OUTPUT_HANDLE.
// lots of code
STARTUPINFO si;
PROCESS_INFORMATION pi;
SECURITY_ATTRIBUTES saAttr = {0};
saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
saAttr.bInheritHandle = TRUE;
saAttr.lpSecurityDescriptor = NULL;
CreatePipe(&hReadPipe, &hWritePipe, &saAttr, 0);
SetStdHandle(STD_OUTPUT_HANDLE, hWritePipe);
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = hReadPipe;
CreateProcess(NULL, // No module name (use command line)
L"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc -vv --demux ffmpeg -", // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
TRUE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
// start ffmpeg write to file.
但我真的不知道我在做什么。
是否有任何GetStdHandle
通常不会打印到控制台?
如果您在使用GetStdHandle捕获父级的输出句柄之后分支子元素,那么您可能会有什么工作。但是,代码的res如何工作? – 2012-04-01 18:06:10
John Zwinck:添加了更多代码,您需要知道的任何特定内容? – ronag 2012-04-01 18:12:24
现在你已经隐藏了变量'si'的类型(在编辑之前显示)!我不知道我是否能够解决您的问题本身,但我认为您可以更好地提出您的问题,这将有助于其他人帮助您。 – 2012-04-01 18:18:54