Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/imbuf/intern/util.c')
-rw-r--r--source/blender/imbuf/intern/util.c51
1 files changed, 36 insertions, 15 deletions
diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 2b0597d64a5..9ec22f0798e 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -43,6 +43,8 @@
#include "BLI_path_util.h"
#include "BLI_fileops.h"
+#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "DNA_userdef_types.h"
#include "BKE_global.h"
@@ -220,6 +222,8 @@ static int isqtime(const char *name)
#ifdef WITH_FFMPEG
+static char ffmpeg_last_error[1024];
+
void silence_log_ffmpeg(int quiet)
{
if (quiet) {
@@ -230,21 +234,40 @@ void silence_log_ffmpeg(int quiet)
}
}
-extern void do_init_ffmpeg(void);
-void do_init_ffmpeg(void)
+void ffmpeg_log_callback(void *ptr, int level, const char *format, va_list arg)
{
- static int ffmpeg_init = 0;
- if (!ffmpeg_init) {
- ffmpeg_init = 1;
- av_register_all();
- avdevice_register_all();
- if ((G.debug & G_DEBUG_FFMPEG) == 0) {
- silence_log_ffmpeg(1);
- }
- else {
- silence_log_ffmpeg(0);
- }
+ if (ELEM(level, AV_LOG_FATAL, AV_LOG_ERROR)) {
+ size_t n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, arg);
+
+ /* strip trailing \n */
+ ffmpeg_last_error[n - 1] = '\0';
}
+
+ /* call default logger to print all message to console */
+ av_log_default_callback(ptr, level, format, arg);
+}
+
+void IMB_ffmpeg_init(void)
+{
+ av_register_all();
+ avdevice_register_all();
+
+ if ((G.debug & G_DEBUG_FFMPEG) == 0) {
+ silence_log_ffmpeg(1);
+ }
+ else {
+ silence_log_ffmpeg(0);
+ }
+
+ ffmpeg_last_error[0] = '\0';
+
+ /* set own callback which could store last error to report to UI */
+ av_log_set_callback(ffmpeg_log_callback);
+}
+
+const char *IMB_ffmpeg_last_error(void)
+{
+ return ffmpeg_last_error;
}
static int isffmpeg(const char *filename)
@@ -255,8 +278,6 @@ static int isffmpeg(const char *filename)
AVCodec *pCodec;
AVCodecContext *pCodecCtx;
- do_init_ffmpeg();
-
if (BLI_testextensie(filename, ".swf") ||
BLI_testextensie(filename, ".jpg") ||
BLI_testextensie(filename, ".png") ||