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:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-08-26 15:01:14 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-08-26 15:01:14 +0400
commit1b487e994850c0acb647aaa9a36464d613f89f51 (patch)
treebf3a591c736690b113b897caf8a986a5bda44b02 /source/blender/imbuf
parentaa17fc367bbd8a5a5834c07f3b225547dae11ee5 (diff)
Some FFmpeg changes
- Make FFmpeg initialization called from creator, not from functions which requires FFmpeg. Makes it easier to follow when initialization should happen. - Enable DNxHD codec. It was commented a while ago due to some strange behavior on some platforms. Re-tested it on Linux and Windows and it seemd to be working quite nice. Would let it be tested further, if it wouldn't be stable enough, easy to comment it again. - Make non-error messages from writeffmpeg.c printed only if ffmpeg debug argument was passed to blender. Reduces console pollution with messages which are not useful for general troubleshooting. Error messages would still be printed to the console. - Show FFmpeg error message when video stream failed to allocate. makes it easier to understand what exactly is wrong from Blender interface, no need to restart blender with FFmpeg debug flag and check for console messages. Used custom log callback for this which stores last error message in static variable. This is not thread safe, but with current design FFmpeg routines could not be called form several threads anyway, so think it's fine solution/
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_imbuf.h4
-rw-r--r--source/blender/imbuf/intern/anim_movie.c4
-rw-r--r--source/blender/imbuf/intern/util.c51
3 files changed, 40 insertions, 19 deletions
diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h
index 738e61dbe6e..a04affd4891 100644
--- a/source/blender/imbuf/IMB_imbuf.h
+++ b/source/blender/imbuf/IMB_imbuf.h
@@ -506,5 +506,9 @@ void IMB_processor_apply_threaded(int buffer_lines, int handle_size, void *init_
void *customdata),
void *(do_thread) (void *));
+/* ffmpeg */
+void IMB_ffmpeg_init(void);
+const char *IMB_ffmpeg_last_error(void);
+
#endif
diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index f07a18cb89c..9092d59c351 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -439,8 +439,6 @@ static ImBuf *avi_fetchibuf(struct anim *anim, int position)
#ifdef WITH_FFMPEG
-extern void do_init_ffmpeg(void);
-
static int startffmpeg(struct anim *anim)
{
int i, videoStream;
@@ -463,8 +461,6 @@ static int startffmpeg(struct anim *anim)
streamcount = anim->streamindex;
- do_init_ffmpeg();
-
if (avformat_open_input(&pFormatCtx, anim->name, NULL, NULL) != 0) {
return -1;
}
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") ||