]> git.sesse.net Git - casparcg/commitdiff
Instead of disabling ffmpeg logging just truncate log level to debug so trace and...
authorHelge Norberg <helge.norberg@svt.se>
Tue, 17 Nov 2015 15:19:58 +0000 (16:19 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Tue, 17 Nov 2015 15:19:58 +0000 (16:19 +0100)
modules/ffmpeg/audio_channel_remapper.cpp
modules/ffmpeg/ffmpeg.cpp
modules/ffmpeg/ffmpeg.h
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/filter/audio_filter.cpp
modules/ffmpeg/producer/filter/filter.cpp
modules/ffmpeg/producer/input/input.cpp
modules/ffmpeg/producer/muxer/frame_muxer.cpp

index f003a7ada1c5ddf320dd84d937a98baa8d429917..4290f481bb244df669825c5b981436e55ec49074 100644 (file)
@@ -147,7 +147,7 @@ struct audio_channel_remapper::impl
                        auto pan_filter = u8(generate_pan_filter_str(input_layout_, output_layout_, mix_config));
 
                        CASPAR_LOG(debug) << "[audio_channel_remapper] Using audio filter: " << pan_filter;
-                       auto logging_disabled = ffmpeg::temporary_disable_logging_for_thread(true);
+                       auto quiet_logging = ffmpeg::temporary_enable_quiet_logging_for_thread(true);
                        filter_.reset(new ffmpeg::audio_filter(
                                        boost::rational<int>(1, 1),
                                        48000,
index 6a6946f1faa4084749a97dfab56ea3fe15f640af..455e95b1a0ee3f0d9a00d0d3697a4cc801fe6ed3 100644 (file)
@@ -237,49 +237,46 @@ std::wstring swscale_version()
 {
        return make_version(::swscale_version());
 }
-bool& get_disable_logging_for_thread()
+bool& get_quiet_logging_for_thread()
 {
-       static boost::thread_specific_ptr<bool> disable_logging_for_thread;
+       static boost::thread_specific_ptr<bool> quiet_logging_for_thread;
 
-       auto local = disable_logging_for_thread.get();
+       auto local = quiet_logging_for_thread.get();
 
        if (!local)
        {
                local = new bool(false);
-               disable_logging_for_thread.reset(local);
+               quiet_logging_for_thread.reset(local);
        }
 
        return *local;
 }
 
-void disable_logging_for_thread()
+bool is_logging_quiet_for_thread()
 {
-       get_disable_logging_for_thread() = true;
+       return get_quiet_logging_for_thread();
 }
 
-bool is_logging_disabled_for_thread()
+std::shared_ptr<void> temporary_enable_quiet_logging_for_thread(bool enable)
 {
-       return get_disable_logging_for_thread();
-}
-
-std::shared_ptr<void> temporary_disable_logging_for_thread(bool disable)
-{
-       if (!disable || is_logging_disabled_for_thread())
+       if (!enable || is_logging_quiet_for_thread())
                return std::shared_ptr<void>();
 
-       disable_logging_for_thread();
+       get_quiet_logging_for_thread() = true;
 
        return std::shared_ptr<void>(nullptr, [](void*)
        {
-               get_disable_logging_for_thread() = false; // Only works correctly if destructed in same thread as original caller.
+               get_quiet_logging_for_thread() = false; // Only works correctly if destructed in same thread as original caller.
        });
 }
 
 void log_for_thread(void* ptr, int level, const char* fmt, va_list vl)
 {
        ensure_gpf_handler_installed_for_thread("ffmpeg-thread");
-       if (!get_disable_logging_for_thread()) // It does not matter what the value of the bool is
-               log_callback(ptr, level, fmt, vl);
+
+       int min_level = is_logging_quiet_for_thread() ? AV_LOG_DEBUG : AV_LOG_FATAL;
+
+       log_callback(ptr, std::max(level, min_level), fmt, vl);
 }
 
 void init(core::module_dependencies dependencies)
@@ -302,8 +299,7 @@ void init(core::module_dependencies dependencies)
        dependencies.media_info_repo->register_extractor(
                        [](const std::wstring& file, const std::wstring& extension, core::media_info& info) -> bool
                        {
-                               // TODO: merge thumbnail generation from 2.0
-                               //auto disable_logging = temporary_disable_logging_for_thread(true);
+                               auto quiet_logging = temporary_enable_quiet_logging_for_thread(true);
                                if (extension == L".WAV" || extension == L".MP3")
                                {
                                        info.clip_type = L"AUDIO";
index a20a882470acee4a2191930571a75422c993f0d9..08a098da45bdc8f2f0271e968379c90e42c7e5cd 100644 (file)
@@ -28,8 +28,7 @@ namespace caspar { namespace ffmpeg {
 
 void init(core::module_dependencies dependencies);
 void uninit();
-void disable_logging_for_thread();
-std::shared_ptr<void> temporary_disable_logging_for_thread(bool disable);
-bool is_logging_disabled_for_thread();
+std::shared_ptr<void> temporary_enable_quiet_logging_for_thread(bool enable);
+bool is_logging_quiet_for_thread();
 
 }}
index 8dcf6fbd888b7f6806f45f2291d66e0b4e8c3d18..558e839f1f2ef884b684a51c9f536aef304b9493 100644 (file)
@@ -145,12 +145,14 @@ public:
                        constraints_.width.set(video_decoder_->width());
                        constraints_.height.set(video_decoder_->height());
                        
-                       if (!is_logging_disabled_for_thread())
+                       if (is_logging_quiet_for_thread())
+                               CASPAR_LOG(debug) << print() << L" " << video_decoder_->print();
+                       else
                                CASPAR_LOG(info) << print() << L" " << video_decoder_->print();
                }
                catch(averror_stream_not_found&)
                {
-                       //CASPAR_LOG(warning) << print() << " No video-stream found. Running without video.";   
+                       CASPAR_LOG(debug) << print() << " No video-stream found. Running without video.";       
                }
                catch(...)
                {
@@ -186,7 +188,9 @@ public:
                
                decode_next_frame();
 
-               if (!is_logging_disabled_for_thread())
+               if (is_logging_quiet_for_thread())
+                       CASPAR_LOG(debug) << print() << L" Initialized";
+               else
                        CASPAR_LOG(info) << print() << L" Initialized";
        }
 
index de5b8fd34f079b9ad74fcb295602b374b9fcca41..c592023b3b6966bec916897eb0d4d6473f611b88 100644 (file)
@@ -156,12 +156,18 @@ struct audio_filter::implementation
                audio_graph_in_  = filt_asrc;
                audio_graph_out_ = filt_asink;
                
-               if (!is_logging_disabled_for_thread())
-                       CASPAR_LOG(info)
+               if (is_logging_quiet_for_thread())
+                       CASPAR_LOG(trace)
                                <<      u16(std::string("\n") 
                                        + avfilter_graph_dump(
                                                        audio_graph_.get(), 
                                                        nullptr));
+               else
+                       CASPAR_LOG(debug)
+                               << u16(std::string("\n")
+                                       + avfilter_graph_dump(
+                                               audio_graph_.get(),
+                                               nullptr));
        }
        
        void configure_filtergraph(
index ac16815e4bb7411a626bae91caa514b8a4ed0669..ab4e259e5520d1a1440f77295721fb16d3163035 100644 (file)
@@ -151,12 +151,18 @@ struct filter::implementation
                video_graph_in_  = filt_vsrc;
                video_graph_out_ = filt_vsink;
                
-               if (!is_logging_disabled_for_thread())
-                       CASPAR_LOG(info)
+               if (is_logging_quiet_for_thread())
+                       CASPAR_LOG(trace)
                                <<      u16(std::string("\n") 
                                        + avfilter_graph_dump(
                                                        video_graph_.get(), 
                                                        nullptr));
+               else
+                       CASPAR_LOG(debug)
+                               << u16(std::string("\n")
+                                       + avfilter_graph_dump(
+                                                       video_graph_.get(),
+                                                       nullptr));
        }
        
        void configure_filtergraph(
index 86ce1c994c23ddc5a64ea7ce77b1ba04b114d12f..6b982f84d57b96cc9d526da49778f19956c2c58e 100644 (file)
@@ -219,7 +219,9 @@ private:
                eof_ = false;
                graph_->set_tag(diagnostics::tag_severity::INFO, "seek");
 
-               if (!is_logging_disabled_for_thread())
+               if (is_logging_quiet_for_thread())
+                       CASPAR_LOG(trace) << print() << " Seeking: " << target;
+               else
                        CASPAR_LOG(debug) << print() << " Seeking: " << target;
 
                int flags = AVSEEK_FLAG_FRAME;
index 4189326c0533df073603eb8fbc95a75bf216edf1..3b286bd827871a1f08368cdcb2923548679ac9ca 100644 (file)
@@ -124,8 +124,11 @@ struct frame_muxer::impl : boost::noncopyable
                if (previous_frame_ && video->data[0] && is_frame_format_changed(*previous_frame_, *video))
                {
                        // Fixes bug where avfilter crashes server on some DV files (starts in YUV420p but changes to YUV411p after the first frame).
-                       if (!ffmpeg::is_logging_disabled_for_thread())
+                       if (ffmpeg::is_logging_quiet_for_thread())
+                               CASPAR_LOG(debug) << L"[frame_muxer] Frame format has changed. Resetting display mode.";
+                       else
                                CASPAR_LOG(info) << L"[frame_muxer] Frame format has changed. Resetting display mode.";
+
                        display_mode_ = display_mode::invalid;
                }
 
@@ -330,8 +333,11 @@ struct frame_muxer::impl : boost::noncopyable
 
                if(display_mode_ == display_mode::invalid)
                {
-                       if (!ffmpeg::is_logging_disabled_for_thread())
+                       if (ffmpeg::is_logging_quiet_for_thread())
+                               CASPAR_LOG(debug) << L"[frame_muxer] Auto-transcode: Failed to detect display-mode.";
+                       else
                                CASPAR_LOG(warning) << L"[frame_muxer] Auto-transcode: Failed to detect display-mode.";
+
                        display_mode_ = display_mode::simple;
                }
 
@@ -351,7 +357,9 @@ struct frame_muxer::impl : boost::noncopyable
                        std::vector<AVPixelFormat>(),
                        u8(filter_str)));
 
-               if (!ffmpeg::is_logging_disabled_for_thread())
+               if (ffmpeg::is_logging_quiet_for_thread())
+                       CASPAR_LOG(debug) << L"[frame_muxer] " << display_mode_ << L" " << print_mode(frame->width, frame->height, in_fps_, frame->interlaced_frame > 0);
+               else
                        CASPAR_LOG(info) << L"[frame_muxer] " << display_mode_ << L" " << print_mode(frame->width, frame->height, in_fps_, frame->interlaced_frame > 0);
        }