I am trying to follow the instruction from the official website, but since I am a beginner programmer, I am always failed to do the compile with SWIG for python binding on windows.
I struggled years ago, failed, now I tried again, still failed. too much out of my league.
If anyone successfully made such python binding for mltframework(melt) , can you help to share here, much appreciate for you generous. Thank you.
If there is a dependency you cannot find or do not care about disable the module with a cmake -D MOD_GDK=OFF for example. Read mlt/CMakeLists.txt to see which modules are available to turn off.
Add -D SWIG_PYTHON=ON to the cmake command line to add that. I do not know which python packages it requires.
Use the -G Ninja to build with ninja instead of make.
With your answer I finally collect all the courage and try it for all day, finally make it going.
Here is something I found out which may help someone in the future:
install all dependencies as den said.
use this command to get around all the missing part: cmake -D MOD_GDK=OFF -D MOD_MOVIT=OFF -D MOD_PLUS=OFF -D MOD_QT=OFF -D MOD_SDL1=OFF -D MOD_RTAUDIO=OFF -D MOD_JACKRACK=OFF -D SWIG_PYTHON=ON -G Ninja
simplly using ninja to compile. //take me sometime to know why build file generated, but no dll can be found.
not sure if this step is needed or not, I get error when using: ImportError: DLL load failed while importing _mlt7 so I tried to add this two line:
LINK_DIRECTORIES(“D:\Program Files\Python38\libs”)
LINK_LIBRARIES(“D:\Program Files\Python38\python38.dll”)
according this answer:c - MinGW / SWIG built python extension failing to load in Anaconda command terminal - Stack Overflow
// also be forced to learn a bit about gcc commandline and cmake
after the above steps, I still get error when using: ImportError: DLL load failed while importing _mlt7 so I tried to add this two line:
take me a lot of hours to trouble shouting, using depencies tool serveral times, all the dependecies resolved good, and try to debug it using x64dbg, seems all fine, but finally I found some library is using the dll under git install path. I’ve got git in my path, so some library such as libgcc_s_seh-1,libiconv-2 from git maybe not compatible. I replace it with those coming from shotcut folder.
Suddenly it works. But still I there is something wrong
One thing you are going to have a problem with is MLT locating its data files such as profiles. The Windows build is a relocatable such that it locates run-time data files relative to the executable. This works fine for things such as melt.exe, shotcut.exe, and kdenlive.exe but not python.exe if that is not in the same location as the MLT framework DLLs. I doubt that is why prod is None. More than likely the libmltavformat.dll is not loading. It expects its dependent DLLs to be in the executable’s directory if they are not in the %PATH%. You can set environment variables (either MLT_DATA or MLT_PROFILES_PATH) to help it locate profiles when you get to that point. But first you need to get melt.exe working to verify your MLT build before jumping into code.
yes, you are right, it’s the environment issue.
In windows, without pass a module handle to function GetModuleFileName, it will return python’s path if we suing python bindings, which is the main EXE file directory instead of DLL directory
But I changed the environment, so all solved, thank you again for your help.