Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f65b098
Initial work on OpenFX module support
Sep 28, 2024
4681405
Making yml files explicit in openfx module CMakeLists
Aug 8, 2025
bf155f1
clang-format openfx module source files
Aug 8, 2025
b22535b
OpenFX module: adding TODO to incompleted code
Aug 20, 2025
3709874
reordering functions in src/modules/openfx/mlt_openfx.c|h
Aug 25, 2025
bc8798a
openfx module: avoid reading directories that contain .ofx.bundle but…
Aug 25, 2025
bdbbdc5
openfx module: using typedefs for shared object symbols
Aug 25, 2025
dea2a02
openfx module: replace strtok with strtok_r to parse openfx plugin pa…
Aug 26, 2025
41c144c
closedir after parsing openfx plugins
Aug 30, 2025
ebd0a1c
openfx module support more parameters types
Sep 5, 2025
02ccdbc
openfx module fix plugin parameter not passed correctly form the host
Sep 5, 2025
e25a6c9
openfx module adding support for color parameters
Sep 8, 2025
15f3ac4
openfx module: add support for double 2d point
Sep 22, 2025
912501e
filter_openfx.c set default value for parameter with type 'double' an…
Sep 22, 2025
a02a87b
openfx module: progress on kOfxImageEffectActionGetRegionOfDefinition…
Sep 23, 2025
ea99a03
openfx module: avoid adding unsupported plugins as filters
Dec 15, 2025
dbfccf2
Fix openfx module build issue with mingw/msys2
Dec 17, 2025
4b352b4
Addressing @ddennedy review comments
Dec 31, 2025
336a8e0
Make sure that OpenFX module have the imported target glib in CMakeLi…
Dec 31, 2025
7ef1edc
Turn off openfx module on msvc CI/CD build
Jan 2, 2026
06b8a33
openfx module: when plugin support RGBA64 or RGBA color format conver…
Jan 6, 2026
5fa2d86
clang-format src/modules/openfx/filter_openfx.c
Jan 6, 2026
9da20ce
openfx module extract plugin description into mlt filter metadata
Jan 18, 2026
8e8957c
clang-format src/modules/openfx/filter_openfx.c
Jan 18, 2026
70246fc
OpenFX module: setting some standard Source/Output properties after d…
Jan 31, 2026
fcedd95
openfx module: Quiet warnings from plugins that use OCIO patch by @bm…
Jan 31, 2026
9a83112
openfx module: applying @bmatherly suggested changes in plugin detect…
Feb 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ option(MOD_SDL2 "Enable SDL2 module" ON)
option(MOD_SOX "Enable SoX module" ON)
option(MOD_SPATIALAUDIO "Enable SpatialAudio module" OFF)
option(MOD_VIDSTAB "Enable vid.stab module (GPL)" ON)
option(MOD_OPENFX "Enable OpenFX module (GPL)" ON)
option(MOD_VORBIS "Enable Vorbis module" ON)
option(MOD_XINE "Enable XINE module (GPL)" ON)
option(MOD_XML "Enable XML module" ON)
Expand Down Expand Up @@ -185,6 +186,7 @@ if(NOT GPL)
set(MOD_RESAMPLE OFF)
set(MOD_RUBBERBAND OFF)
set(MOD_VIDSTAB OFF)
set(MOD_OPENFX OFF)
set(MOD_XINE OFF)
endif()

Expand Down Expand Up @@ -263,6 +265,10 @@ if(MOD_JACKRACK)
list(APPEND MLT_SUPPORTED_COMPONENTS jackrack)
endif()

if(MOD_OPENFX)
pkg_check_modules(glib IMPORTED_TARGET glib-2.0)
endif()

if(USE_LV2)
pkg_check_modules(lilv IMPORTED_TARGET lilv-0)
if(NOT lilv_FOUND)
Expand Down Expand Up @@ -575,6 +581,7 @@ add_feature_info("Module: SDL2" MOD_SDL2 "")
add_feature_info("Module: SoX" MOD_SOX "")
add_feature_info("Module: SpatialAudio" MOD_SPATIALAUDIO "")
add_feature_info("Module: vid.stab" MOD_VIDSTAB "")
add_feature_info("Module: OpenFX" MOD_OPENFX "")
add_feature_info("Module: Vorbis" MOD_VORBIS "")
add_feature_info("Module: XINE" MOD_XINE "")
add_feature_info("Module: XML" MOD_XML "")
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"MOD_VIDSTAB": "OFF",
"MOD_VORBIS": "ON",
"MOD_XINE": "OFF",
"MOD_XML": "ON"
"MOD_XML": "ON",
"MOD_OPENFX": "OFF"
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions src/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ if(MOD_VIDSTAB)
add_subdirectory(vid.stab)
endif()

if(MOD_OPENFX)
add_subdirectory(openfx)
endif()

if(MOD_VORBIS)
add_subdirectory(vorbis)
endif()
Expand Down
26 changes: 26 additions & 0 deletions src/modules/openfx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
add_library(mltopenfx MODULE
factory.c
mlt_openfx.c mlt_openfx.h
filter_openfx.c
)

add_custom_target(Other_openfx_Files SOURCES
filter_openfx.yml
)

if(GPL AND TARGET PkgConfig::glib)
include(GenerateExportHeader)
generate_export_header(mltopenfx)
target_compile_options(mltopenfx PRIVATE ${MLT_COMPILE_OPTIONS})
target_include_directories(mltopenfx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries(mltopenfx PRIVATE mlt PkgConfig::glib ${CMAKE_DL_LIBS})
if(NOT MSVC)
target_link_libraries(mltopenfx PRIVATE m)
endif()
endif()

set_target_properties(mltopenfx PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${MLT_MODULE_OUTPUT_DIRECTORY}")

install(TARGETS mltopenfx LIBRARY DESTINATION ${MLT_INSTALL_MODULE_DIR})

install(FILES filter_openfx.yml DESTINATION ${MLT_INSTALL_DATA_DIR}/openfx)
312 changes: 312 additions & 0 deletions src/modules/openfx/factory.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,312 @@
/*
* factory.c -- the factory method interfaces
* Copyright (C) 2025 Meltytech, LLC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "mlt_openfx.h"
#include <glib.h>
#include <stdbool.h>
extern OfxHost MltOfxHost;
static OfxSetHostFn ofx_set_host;
static OfxGetPluginFn ofx_get_plugin;
static OfxGetNumberOfPluginsFn ofx_get_number_of_plugins;
static int NumberOfPlugins;
mlt_properties mltofx_context;
mlt_properties mltofx_dl;

#if defined(__linux__) || defined(__FreeBSD__)

#define OFX_DIRLIST_SEP_CHARS ":;"
#define OFX_DIRSEP "/"
#include <dirent.h>

static const char *getArchStr()
{
if (sizeof(void *) == 4) {
#if defined(__linux__)
return "Linux-x86";
#else
return "FreeBSD-x86";
#endif
} else {
#if defined(__linux__)
return "Linux-x86-64";
#else
return "FreeBSD-x86-64";
#endif
}
}

#define OFX_ARCHSTR getArchStr()

#elif defined(__APPLE__)

#define OFX_DIRLIST_SEP_CHARS ";:"
#if defined(__x86_64) || defined(__x86_64__)
#define OFX_ARCHSTR "MacOS-x86-64"
#else
#define OFX_ARCHSTR "MacOS"
#endif
#define OFX_DIRSEP "/"
#include <dirent.h>

#elif defined(WINDOWS) || defined(WIN32) || defined(_WIN32) || defined(__MINGW32__) \
|| defined(__MINGW64__)
#define OFX_DIRLIST_SEP_CHARS ";"
#if defined(_WIN64) || defined(__MINGW64__)
#define OFX_ARCHSTR "Win64"
#else
#define OFX_ARCHSTR "Win32"
#endif
#define OFX_DIRSEP "\\"

#if defined(__MINGW32__) || defined(__MINGW64__)
#include <dirent.h>
#endif

#include "shlobj.h"
#include "tchar.h"
#endif

extern mlt_filter filter_openfx_init(mlt_profile profile,
mlt_service_type type,
const char *id,
char *arg);

static void plugin_mgr_destroy(mlt_properties p)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run melt and use an openfx filter, melt always ends with a crash. Here is the gdb backtrace:

0x00007fffe6f3d385 in ?? () from /home/brian/Downloads/Natron-2.5.0-Linux-x86_64-no-installer/Plugins/OFX/Natron/Misc.ofx.bundle/Contents/Linux-x86-64/Misc.ofx
(gdb) 
#0  0x00007fffe6f3d385 in ??? () at /home/brian/Downloads/Natron-2.5.0-Linux-x86_64-no-installer/Plugins/OFX/Natron/Misc.ofx.bundle/Contents/Linux-x86-64/Misc.ofx
#1  0x00007fffe7809b89 in ??? () at /home/brian/Downloads/Natron-2.5.0-Linux-x86_64-no-installer/Plugins/OFX/Natron/Misc.ofx.bundle/Contents/Linux-x86-64/Misc.ofx
#2  0x00007ffff0967b70 in plugin_mgr_destroy (p=0x555555705150) at /home/brian/shotcut/src/mlt/src/modules/openfx/factory.c:108
#3  0x00007ffff7fa2abe in clear_property (self=0x55555586e450) at /home/brian/shotcut/src/mlt/src/framework/mlt_property.c:124
#4  0x00007ffff7fa433a in mlt_property_close (self=0x55555586e450) at /home/brian/shotcut/src/mlt/src/framework/mlt_property.c:920
#5  0x00007ffff7f9fe6c in mlt_properties_close (self=0x555555561360) at /home/brian/shotcut/src/mlt/src/framework/mlt_properties.c:1508
#6  0x00007ffff7f8ab3a in mlt_factory_close () at /home/brian/shotcut/src/mlt/src/framework/mlt_factory.c:520
#7  0x000055555555b5a5 in main (argc=21, argv=0x7fffffffd8d8) at /home/brian/shotcut/src/mlt/src/melt/melt.c:1155

Do you also experience this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes I face similar issues with the git version of melt and not only openfx branch but using kdenlive does not cause this issue. I need to do more testing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seem to be a handful of plugins that crash when we call

        pt->mainEntry(kOfxActionUnload, NULL, NULL, NULL);

From inspection, I notice that we load and then unload all plugins while we are discovering them. Then, we load them all again when we are generating metadata - and we leave them all loaded until the program closes and we call plugin_mgr_destroy. Do you know if it is good to leave them all loaded? Does that consume extra resources? Should we try to only keep open plugins that we are using?

{
int cN = mlt_properties_count(mltofx_context);

for (int j = 0; j < cN; ++j) {
char *id = mlt_properties_get_name(mltofx_context, j);
mlt_properties pb = (mlt_properties) mlt_properties_get_data(mltofx_context, id, NULL);

char *dli = mlt_properties_get(pb, "dli");
dli[0] = 'g';
int index = mlt_properties_get_int(pb, "index");

OfxGetPluginFn get_plugin = mlt_properties_get_data(mltofx_dl, dli, NULL);

if (get_plugin != NULL) {
OfxPlugin *pt = get_plugin(index);
if (pt == NULL)
continue;
pt->mainEntry(kOfxActionUnload, NULL, NULL, NULL);
}
}

int N = mlt_properties_get_int(p, "N");

for (int i = 0; i < N; ++i) {
char tstr[12] = {
'\0',
};
sprintf(tstr, "%d", i);
void *current_dlhandle = mlt_properties_get_data(mltofx_dl, tstr, NULL);
dlclose(current_dlhandle);
}
}

static mlt_properties metadata(mlt_service_type type, const char *id, void *data)
{
char file[PATH_MAX];
snprintf(file, PATH_MAX, "%s/openfx/%s", mlt_environment("MLT_DATA"), (char *) data);
mlt_properties result = mlt_properties_parse_yaml(file);

mlt_properties pb = (mlt_properties) mlt_properties_get_data(mltofx_context, id, NULL);

char *dli = mlt_properties_get(pb, "dli");
int index = mlt_properties_get_int(pb, "index");

OfxGetPluginFn get_plugin = mlt_properties_get_data(mltofx_dl, dli, NULL);
OfxPlugin *pt = get_plugin(index);

dli[0] = 's';
OfxSetHostFn set_host = mlt_properties_get_data(mltofx_dl, dli, NULL);
if (set_host != NULL)
set_host(&MltOfxHost);

mlt_properties_set(result, "identifier", id);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run this command:
melt -query filter=openfx.net.sf.openfx.Mirror
Here is the result:

[OpenColorIO Info]: Color management disabled. (Specify the $OCIO environment variable to enable.)
---
schema_version: 7.0
type: filter
identifier: openfx.net.sf.openfx.Mirror
title: openfx.net.sf.openfx.Mirror
version: 1
license: GPLv2
language: en
url: "https://openeffects.org/"
creator: mr.fantastic <mrfantastic@firemail.cc>
tags:
  - Video
description: Process videos using OpenFX 1.5 plugins.
parameters:
  Controls:
    animation: yes
  flip:
    type: boolean
    animation: yes
    title: Vertical (flip)
    identifier: flip
  flop:
    type: boolean
    animation: yes
    title: Horizontal (flop)
    identifier: flop
...
Bus error (core dumped)

Besides the noisy info message and crash, the metadata is ill-formed. It should be:

parameters:
  - identifier: flip
    type: boolean
    animation: yes
    title: Vertical (flip)

  - identifier: flop
    type: boolean
    animation: yes
    title: Horizontal (flop)

The "Controls" item should not be there at all. And the identifier should be first and have a hyphen. See the schema in the framework.

mlt_properties_set(result, "title", id);

/* parameters */
mlt_properties params = mlt_properties_new();
mlt_properties_set_data(result,
"parameters",
params,
0,
(mlt_destructor) mlt_properties_close,
NULL);

mltofx_fetch_params(pt, params, result);
return result;
}

MLT_REPOSITORY
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run melt, i always see a new information message:

[OpenColorIO Info]: Color management disabled. (Specify the $OCIO environment variable to enable.)

This message is printed even if I do not try to use any openfx filters. Is there a way to avoid the message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugins print their logs but I think this goes to the stderr so in bash we can forward it to 2> /dev/null this is what I know but maybe there is OpenFX host property that turns off logging if plugins is implemented according to the standard.

Copy link
Copy Markdown
Member

@bmatherly bmatherly Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to turn off logging. Here is a patch that quiets the OCIO message:

diff --git a/src/modules/openfx/factory.c b/src/modules/openfx/factory.c
index 3007ef68..ca006ef5 100644
--- a/src/modules/openfx/factory.c
+++ b/src/modules/openfx/factory.c
@@ -161,6 +161,13 @@ MLT_REPOSITORY
     MltOfxHost.host = (OfxPropertySetHandle) mlt_properties_new();
     mltofx_init_host_properties(MltOfxHost.host);
 
+    // Quiet warnings from plugins that use OCIO
+    char *ocio = getenv("OCIO");
+    if (!ocio || !strcmp(ocio, "")) {
+        // If the OCIO environment variable is not set, set it to a built-in default config
+        setenv("OCIO", "ocio://ocio://default", 1);
+    }
+
     char *dir,
         *openfx_path = getenv("OFX_PLUGIN_PATH"),
         *load_unsupported_plugins = getenv(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put a commit here which you are welcome to cherry-pick
4cc5e4f

{
MltOfxHost.host = (OfxPropertySetHandle) mlt_properties_new();
mltofx_init_host_properties(MltOfxHost.host);

// Quiet warnings from plugins that use OCIO
char *ocio = getenv("OCIO");
if (!ocio || !strcmp(ocio, "")) {
// If the OCIO environment variable is not set, set it to a built-in default config
setenv("OCIO", "ocio://ocio://default", 1);
}

char *dir;
char *openfx_path = getenv("OFX_PLUGIN_PATH");
size_t archstr_len = strlen(OFX_ARCHSTR);

mltofx_context = mlt_properties_new();
mltofx_dl = mlt_properties_new();

if (openfx_path) {
int dli = 0;
char *saveptr;

for (char *strptr = openfx_path;; strptr = NULL) {
dir = strtok_r(strptr, MLT_DIRLIST_DELIMITER, &saveptr);
if (dir == NULL)
break;
size_t dir_len = strlen(dir);

DIR *d = opendir(dir);
if (!d)
continue;

struct dirent *de = readdir(d);
while (de) {
char *name = de->d_name;

char *bni = NULL;
if ((bni = strstr(name, ".ofx.bundle")) != NULL && bni[11] == '\0') {
char *barename = g_strndup(name, (int) (bni - name) + 4);
size_t name_len = (size_t) (bni - name) + 4 + 7;
/* 12b sizeof `Contents` word, 1 sizeof null byte */
char *binpath = malloc(dir_len + name_len + 12 + (name_len - 7) + archstr_len
+ 1);
sprintf(binpath, "%s/%s/Contents/%s/%s", dir, name, OFX_ARCHSTR, barename);

void *dlhandle = dlopen(binpath, RTLD_LOCAL | RTLD_LAZY);

ofx_set_host = dlsym(dlhandle, "OfxSetHost");

ofx_get_plugin = dlsym(dlhandle, "OfxGetPlugin");
ofx_get_number_of_plugins = dlsym(dlhandle, "OfxGetNumberOfPlugins");
if (!ofx_get_plugin || !ofx_get_number_of_plugins)
goto parse_error;
NumberOfPlugins = ofx_get_number_of_plugins();

char dl_n[16] = {
'\0',
};
sprintf(dl_n, "%d", dli);

mlt_properties_set_data(mltofx_dl, dl_n, dlhandle, 0, NULL, NULL);
dl_n[0] = '\0';
sprintf(dl_n, "gn%d", dli);
mlt_properties_set_data(mltofx_dl,
dl_n,
ofx_get_number_of_plugins,
0,
(mlt_destructor) mlt_properties_close,
NULL);
dl_n[0] = '\0';
sprintf(dl_n, "s%d", dli);
mlt_properties_set_data(mltofx_dl,
dl_n,
ofx_set_host,
0,
(mlt_destructor) mlt_properties_close,
NULL);

dl_n[0] = '\0';
sprintf(dl_n, "g%d", dli);
mlt_properties_set_data(mltofx_dl,
dl_n,
ofx_get_plugin,
0,
(mlt_destructor) mlt_properties_close,
NULL);

dli++;

if (ofx_get_plugin == NULL)
goto parse_error;

for (int i = 0; i < NumberOfPlugins; ++i) {
OfxPlugin *plugin_ptr = ofx_get_plugin(i);
if (!plugin_ptr)
goto parse_error;

int detected = mltofx_detect_plugin(plugin_ptr);

if (!detected)
continue;

char *s = NULL;
size_t pluginIdentifier_len = strlen(plugin_ptr->pluginIdentifier);
s = malloc(pluginIdentifier_len + 8);
sprintf(s, "openfx.%s", plugin_ptr->pluginIdentifier);

// if colon `:` exists in plugin identifier
// change it to accent sign `^` because `:`
// can cause issues with mlt if put in filter
// name
char *str_ptr = strchr(s, ':');
while (str_ptr != NULL) {
*str_ptr++ = '^';
str_ptr = strchr(str_ptr, ':');
}

mlt_properties p;
p = mlt_properties_new();
mlt_properties_set_data(mltofx_context,
s,
p,
0,
(mlt_destructor) mlt_properties_close,
NULL);

mlt_properties_set(p, "dli", dl_n);
mlt_properties_set_int(p, "index", i);

MLT_REGISTER(mlt_service_filter_type, s, filter_openfx_init);
MLT_REGISTER_METADATA(mlt_service_filter_type,
s,
metadata,
"filter_openfx.yml");
free(s);
}

parse_error:

free(binpath);
free(barename);
}

de = readdir(d);
}

closedir(d);
}

mlt_properties_set_int(mltofx_dl, "N", dli);
mlt_factory_register_for_clean_up(mltofx_dl, (mlt_destructor) plugin_mgr_destroy);
}
}
Loading
Loading