[FFmpeg-user] Terminate on no frames/input buffer overflow

Adam Nielsen a.nielsen at shikadi.net
Fri Oct 1 20:08:14 EEST 2021

Hi all,

I'm streaming a video with ffplay on a Raspberry Pi using the hardware
decoder (v4l2_m2m) and the video stream keeps randomly freezing, I am
guessing due to a bug in the hardware decoder implementation.

When this happens, I must run "killall ffplay".  I have configured
systemd to restart ffplay automatically so the streams resume a few
seconds later, until they freeze again anywhere from a few minutes to a
few hours later.

Rather than having to manually SSH in and terminate ffplay, I am
wondering whether there is a way that ffplay can be told to exit when
the decoder freezes, so that I might have a chance of recovering from
this situation automatically?

It looks like when the freeze happens, ffplay's memory usage increases
as if it's buffering the incoming stream, so perhaps being able to get
ffplay to quit in this situation might work.

I have tried to use systemd's configuration to limit ffplay's memory
usage, however it doesn't seem to terminate ffplay when this situation
arises so I am not entirely sure what's going on.

As a side note, the reason I am assuming this is a hardware bug is
because I am streaming two videos, and when one freezes, so does the
other one.  Occasionally I also get corrupted bits of one stream
appearing in the other ffplay window as well, and dmesg reports errors
about the graphics decoder timing out.  If I only restart one video
stream I just get the old frozen frame showing up again.  I have to
restart both ffplay instances before playback returns to normal.

Any ideas how to tell ffplay to exit when it no longer receives frames
from the streaming source?

Many thanks,

More information about the ffmpeg-user mailing list