Skip to content

Commit

Permalink
ffmpeg: silence repeated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaspandersson committed Dec 1, 2024
1 parent 9445ce1 commit 71320b9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/modules/ffmpeg/producer/av_producer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,8 @@ struct AVProducer::Impl
timer decode_timer;

int warning_debounce = 0;
uint8_t warning_count = 0;
const uint8_t max_warnings = 5;

while (!thread_.interruption_requested()) {
{
Expand Down Expand Up @@ -904,14 +906,18 @@ struct AVProducer::Impl

if ((!video_filter_.frame && !video_filter_.eof) || (!audio_filter_.frame && !audio_filter_.eof)) {
if (!progress) {
if (warning_debounce++ % 500 == 100) {
if (warning_debounce++ % 500 == 100 && warning_count < max_warnings) {
if (!video_filter_.frame && !video_filter_.eof) {
CASPAR_LOG(warning) << print() << " Waiting for video frame...";
} else if (!audio_filter_.frame && !audio_filter_.eof) {
CASPAR_LOG(warning) << print() << " Waiting for audio frame...";
} else {
CASPAR_LOG(warning) << print() << " Waiting for frame...";
}
warning_count++;
if(warning_count == max_warnings) {
CASPAR_LOG(warning) << print() << " Too many warnings. Silencing.";
}
}

// TODO (perf): Avoid live loop.
Expand All @@ -920,7 +926,7 @@ struct AVProducer::Impl
continue;
}

warning_debounce = 0;
warning_debounce = warning_count = 0;

// TODO (fix)
// if (start_ != AV_NOPTS_VALUE && frame.pts < start_) {
Expand Down

0 comments on commit 71320b9

Please sign in to comment.