summaryrefslogtreecommitdiff
path: root/src/lib/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-02-23 23:35:40 +0100
committerCarl Hetherington <cth@carlh.net>2023-03-03 01:17:41 +0100
commit69957d093fd1cb798449271e6212cd86321d5528 (patch)
tree02fa032c1a9d95b28cdcd127f4f9d8a66bca1c34 /src/lib/util.cc
parent0a4c399e8ed2ebb8b7dadf2684595effd1ca9f3e (diff)
Setup ffmpeg log callback in dcpomatic_setup() instead of in FFmpeg.
Diffstat (limited to 'src/lib/util.cc')
-rw-r--r--src/lib/util.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc
index bab74583c..6ed66c40f 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -388,6 +388,31 @@ capture_asdcp_logs ()
}
+static
+void
+ffmpeg_log_callback(void* ptr, int level, const char* fmt, va_list vl)
+{
+ if (level > AV_LOG_WARNING) {
+ return;
+ }
+
+ char line[1024];
+ static int prefix = 0;
+ av_log_format_line(ptr, level, fmt, vl, line, sizeof (line), &prefix);
+ string str(line);
+ boost::algorithm::trim(str);
+ dcpomatic_log->log(String::compose("FFmpeg: %1", str), LogEntry::TYPE_GENERAL);
+}
+
+
+static
+void
+capture_ffmpeg_logs()
+{
+ av_log_set_callback(ffmpeg_log_callback);
+}
+
+
/** Call the required functions to set up DCP-o-matic's static arrays, etc.
* Must be called from the UI thread, if there is one.
*/
@@ -455,6 +480,7 @@ LIBDCP_ENABLE_WARNINGS
ui_thread = boost::this_thread::get_id ();
capture_asdcp_logs ();
+ capture_ffmpeg_logs();
}
#ifdef DCPOMATIC_WINDOWS