I am using ffmpeg on linux for real time video recording to Youtube. When I put the ffmpeg command, ffmpeg is running well. But, audio device becomes fail, frame count is not increase at all from time of audio device failure. Video record on Youtube is stopped. but ffmpeg command is still running with not increasing frame count as follow image.


My question is that how can I get the status of ffmpeg running at outside of ffmpeg command?

My first solution is that I read frame counter field, if counter is not changed, then something fail on ffmpeg.

  • If ffmpeg fails, it will exit with a corresponding non-zero exit code and the process will be stopped. If it is running, it is running. Or are you specifically looking at the frame count not increasing? Please clarify your question.
    – slhck
    Jul 15 '19 at 8:28
  • In my case, ffmpeg is not stopped, remain on running state, wirh same frame counter value. I did as follow link, stackoverflow.com/questions/2017843/… but I can not get frame count value at real time, there are some delay.
    – Paul Lee
    Jul 16 '19 at 5:12
  • sorry correct link is superuser.com/questions/84631/…
    – Paul Lee
    Jul 16 '19 at 5:17

If you run ffmpeg with the -progress - -nostats options, it'll print its progress in a parsable format to the output:

speed= 214x

Query that output repeatedly from whatever script or shell you are calling ffmpeg from, and watch for lines starting with frame=. If the number does not change, the encoding process is hanging.

You can see an example of a Python function querying the output of an ffmpeg command repeatedly, yielding its progress in terms of out_time, here.


We use this type of code to convert and detect the completion of the FFmpeg command in PHP. I hope it can help you in some way.

$status=shell_exec('ffmpeg  -loglevel 16 -i inputfile.gsm -acodec libmp3lame test.mp3 2>&1; echo $?');
if ($status==0) {
                # code...
                echo "The file converted successfully.";
            echo "The file cant converted.";         
  • Did the OP say anything about using PHP? Also, it seems he wants to check if the frame count is not increasing, not whether the program has stopped altogether.
    – slhck
    Jul 15 '19 at 8:29
  • Even though the frame count is not increasing, ffmpeg does not return, still running.
    – Paul Lee
    Jul 15 '19 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.