[FFmpeg-devel] [PATCH] set FONTCONFIG_PATH relative to ffmpeg binary, if it is a static build
Helmut K. C. Tessarek
tessarek at evermeet.cx
Mon Feb 17 11:05:57 CET 2014
For static builds FONTCONFIG might not be installed on the system, so ffmpeg will throw an error.
Also, if people bundled the binary, a relative fontconfig path would be an advantage.
---
ffmpeg.c | 31 +++++++++++++++++++++++++++++++
ffmpeg.h | 1 +
2 files changed, 32 insertions(+)
diff --git a/ffmpeg.c b/ffmpeg.c
index 6a51810..d8f9443 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3541,11 +3541,42 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
{
}
+void set_relative_fontconfig_path(void)
+{
+#if !HAVE_WINDOWS_H
+ char subdir[] = "/fonts";
+#else
+ char subdir[] = "\\fonts";
+#endif
+
+ char *curdir = (char *) av_malloc (PATH_MAX);
+ char *fontdir = (char *) av_malloc (PATH_MAX);
+
+ getcwd (curdir, PATH_MAX);
+
+ strncpy( fontdir, curdir, PATH_MAX );
+ fontdir[PATH_MAX-1] = '\0';
+
+ if( strlen(curdir) < (PATH_MAX - 7) )
+ {
+ strncat( fontdir, subdir, 7 );
+ }
+
+ setenv( "FONTCONFIG_PATH", fontdir, 0 );
+
+ av_free( fontdir );
+ av_free( curdir );
+}
+
int main(int argc, char **argv)
{
int ret;
int64_t ti;
+#if CONFIG_STATIC && CONFIG_FONTCONFIG
+ set_relative_fontconfig_path();
+#endif
+
register_exit(ffmpeg_cleanup);
setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
diff --git a/ffmpeg.h b/ffmpeg.h
index 00f7a2a..48c6451 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -489,6 +489,7 @@ int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOu
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost);
+void set_relative_fontconfig_path(void);
int ffmpeg_parse_options(int argc, char **argv);
int vdpau_init(AVCodecContext *s);
--
1.8.5.4
More information about the ffmpeg-devel
mailing list