Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 检测FFmpeg是否正在运行或已停止运行_C_Process_Ffmpeg - Fatal编程技术网

C 检测FFmpeg是否正在运行或已停止运行

C 检测FFmpeg是否正在运行或已停止运行,c,process,ffmpeg,C,Process,Ffmpeg,我正在使用C扫描一个包含ffmpeg提取的帧的目录。现在,如果在扫描期间到达最后一个文件,我需要检查两个条件: 这是视频持续时间结束时的最后一个文件 这是ffmpeg突然终止的最后一个文件,无法再填充目录 我的C程序工作流如下: while(<there exists files in the directory>) { // iterate over them and do something with each frame } // coming out of the l

我正在使用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
    }
    
    while()
    {
    //对它们进行迭代,并对每个帧执行某些操作
    }
    //退出循环意味着没有更多的文件可用…所以我需要一个if条件
    
    if()/不确定在您的情况下这是否是一种方法,但是。。。在unix世界中,在后台运行的程序通常会创建一个具有进程id的公共可读文件,然后在完成后将其删除


    您可以从批处理脚本创建此文件,然后在C程序中检查该文件中的pid是否正在运行。

    您完全可以等待
    FFmpeg
    过程完成。您通常会获取
    ffmpeg.exe
    进程句柄,然后使用、检查其
    getExitCode进程
    或两者兼而有之

    如果您没有句柄,但有进程标识符,
    OpenProcess
    将为您获取句柄


    当然,如果您使用本机Windows API直接处理帧,而不是通过文件和外部进程,那么您就不必遇到这种麻烦。

    如何从批处理文件启动ffmpeg?然后我启动这个C程序嗯……我不确定Windows是否也做同样的事情……我必须对此进行研究。