Skip to content

Commit 2d3b884

Browse files
authored
Merge pull request #23 from nxtedition/ffmpeg_silence_warnings
ffmpeg: silence warnings
2 parents 9445ce1 + 71320b9 commit 2d3b884

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/modules/ffmpeg/producer/av_producer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,8 @@ struct AVProducer::Impl
844844
timer decode_timer;
845845

846846
int warning_debounce = 0;
847+
uint8_t warning_count = 0;
848+
const uint8_t max_warnings = 5;
847849

848850
while (!thread_.interruption_requested()) {
849851
{
@@ -904,14 +906,18 @@ struct AVProducer::Impl
904906

905907
if ((!video_filter_.frame && !video_filter_.eof) || (!audio_filter_.frame && !audio_filter_.eof)) {
906908
if (!progress) {
907-
if (warning_debounce++ % 500 == 100) {
909+
if (warning_debounce++ % 500 == 100 && warning_count < max_warnings) {
908910
if (!video_filter_.frame && !video_filter_.eof) {
909911
CASPAR_LOG(warning) << print() << " Waiting for video frame...";
910912
} else if (!audio_filter_.frame && !audio_filter_.eof) {
911913
CASPAR_LOG(warning) << print() << " Waiting for audio frame...";
912914
} else {
913915
CASPAR_LOG(warning) << print() << " Waiting for frame...";
914916
}
917+
warning_count++;
918+
if(warning_count == max_warnings) {
919+
CASPAR_LOG(warning) << print() << " Too many warnings. Silencing.";
920+
}
915921
}
916922

917923
// TODO (perf): Avoid live loop.
@@ -920,7 +926,7 @@ struct AVProducer::Impl
920926
continue;
921927
}
922928

923-
warning_debounce = 0;
929+
warning_debounce = warning_count = 0;
924930

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

0 commit comments

Comments
 (0)