我正在使用C扫描包含由ffmpeg提取的帧的目录。现在,如果在扫描过程中到达最后一个文件,我需要检查两个条件:
- 这是视频持续时间结束后的最后一个文件。
- 这是最后一个文件,因为 ffmpeg 突然终止并且无法再填充目录
我的C程序工作流程如下:
while(<there exists files in the directory>)
{
// iterate over them and do something with each frame
}
// coming out of the loop means no more files available...so I need a if condition
if(<check if ffmpeg is stopped>) // <-- need to know what to put inside the condition
{
// start it again
}
else
{
// video is over, nothing more left to do
}
我想我可以使用 ffmpeg 的进程 ID
来做到这一点,但是我如何获取该信息?还有其他方法可以检查 ffpmeg 是否已停止吗?
一些元数据
操作系统:Windows 7
IDE:Dev C++
使用的语言:C
最佳答案
您绝对可以等待 FFmpeg
进程完成。您通常会获取 ffmpeg.exe
进程句柄,然后使用 wait functions 等待它。 ,检查其 GetExitCodeProcess
或两者。
如果您没有句柄,但有进程标识符,OpenProcess
将为您获取句柄。
当然,如果您使用 native Windows API,直接处理帧,而不是通过文件和外部进程,那么您就不必陷入这个麻烦。
关于c - 检测 FFmpeg 是否正在运行或已停止运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14998096/