How can I get ffmpeg command running status in real time?
If you run ffmpeg with the -progress - -nostats
options, it'll print its progress in a parsable format to the output:
frame=2675
fps=0.00
stream_0_0_q=-0.0
bitrate=N/A
total_size=N/A
out_time_us=107000000
out_time_ms=107000000
out_time=00:01:47.000000
dup_frames=0
drop_frames=0
speed= 214x
progress=continue
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, yield
ing its progress in terms of out_time
, here.
Related videos on Youtube
![Paul Lee](https://lh4.googleusercontent.com/--QOt--jd20c/AAAAAAAAAAI/AAAAAAAAAOI/unHqJ-BLvh4/photo.jpg?sz=256)
Paul Lee
Updated on September 18, 2022Comments
-
Paul Lee almost 2 years
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.
-
slhck almost 5 yearsIf 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.
-
Paul Lee almost 5 yearsIn 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 almost 5 yearssorry correct link is superuser.com/questions/84631/…
-
-
slhck almost 5 yearsDid 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.
-
Paul Lee almost 5 yearsEven though the frame count is not increasing, ffmpeg does not return, still running.
-
Alex Collette over 2 yearsI also found it helpful to add
-loglevel error
. This will remove all other output that generally shows up at the beginning.