将ffmpeg管道重定向到子进程
Redirect ffmpeg pipe to child process
如何将ffmpeg管道从进程重定向到子进程stdin?
我想在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
不能正常打印到控制台?
您可以尝试创建一个管道:
-
调用CreatePipe()创建一个读句柄和一个写句柄
-
调用SetStdHandle()使管道的写句柄成为新的stdout
-
将管道的读取句柄指定为CreateProcess()的hStdInput
更新:
如果您的应用程序使用printf()打印到STD输出控制台,您可能需要破解stdout结构并替换那里的句柄。在任何情况下,尝试进入一个没有正确重定向的printf()调用,看看它最终使用了哪个句柄。
相关文章:
- 使用重定向标准处理子进程中的 kbhit
- 是否可以将子进程的 stdout 重定向到父进程中的另一个文件?
- 当使用带有stdin和stdout重定向的双进程管道时,如何避免stdin上的重复输入
- 如何将传入的流量重定向到模块中,以在Omnet 中的简单子模块中
- 无法使用创建进程重定向标准输出
- 重定向子进程的输出
- 我可以重定向两个子进程的标准输出吗?
- 创建进程和重定向输出
- 进程重定向可以在bash中同步吗
- 使用管道从子进程进行I/O重定向-winapi
- 重定向父进程的管道,而不影响子进程
- 重定向子进程的输入和输出不起作用
- 将ffmpeg管道重定向到子进程
- 子进程的异步双向IO重定向
- Python将输入重定向到子进程
- 仅重定向子进程stdin,并从stdout和stderr中删除数据
- 重定向子进程的文件流
- 重定向子进程输出
- 重定向子进程输出到缓冲区
- 重定向子进程输出到FIFO不工作