+ // If ten seconds is gone without anything happening, we assume that
+ // we are in a network stream that died and FFmpeg just didn't
+ // pick it up (or perhaps it just hung, keeping the connection open).
+ // Called back approximately every 100 ms if something is hanging,
+ // so we get more than enough accuracy for our purposes.
+ if (!should_interrupt && frame_timeout_valid &&
+ duration<double>(steady_clock::now() - frame_timeout_started).count() >= 10.0) {
+ string filename_copy;
+ {
+ lock_guard<mutex> lock(filename_mu);
+ filename_copy = filename;
+ }
+ fprintf(stderr, "%s: No frame for more than 10 seconds, restarting stream.\n", filename.c_str());
+ should_interrupt = true;
+ }