如何將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