Warning, /multimedia/kdenlive/dev-docs/build.md is written in an unsupported language. File is not indexed.
0001 # Building Kdenlive 0002 0003 ## Supported platforms 0004 0005 Kdenlive is primarily developed on GNU/Linux, but it is also possible to [build Kdenlive on Microsoft Windows and macOS using Craft](#build-craft). For Windows also [other possibilities exist](https://community.kde.org/Kdenlive/Development/WindowsBuild). 0006 0007 Currently supported distributions are: 0008 0009 * Ubuntu 22.04 LTS Focal Fossa and derivatives 0010 * Arch Linux 0011 0012 But you should be able to build it on any platform that provides up-to-date versions of the following dependencies: Qt >= 5.15.2, KF5 >= 5.86, MLT >= 7.10.0. 0013 0014 ## Build on Linux 0015 0016 ### Base procedure 0017 0018 Kdenlive usually requires the latest version of MLT, in which go several API updates, bugfixes and optimizations. 0019 On Ubuntu, the easiest way is to add [Kdenlive's ppa](https://launchpad.net/~kdenlive/+archive/ubuntu/kdenlive-master) 0020 0021 ```bash 0022 sudo add-apt-repository ppa:kdenlive/kdenlive-master 0023 sudo apt update 0024 ``` 0025 0026 It is recommended to uninstall the official kdenlive packages to avoid potential conflicts. 0027 0028 ```bash 0029 sudo apt remove kdenlive kdenlive-data 0030 ``` 0031 0032 0033 #### Get the build dependencies 0034 0035 0036 First, make sure you have the required tooling installed: 0037 0038 ```bash 0039 sudo apt install build-essential git cmake extra-cmake-modules libsm-dev 0040 ``` 0041 0042 You can use your distribution packages information (if not too old) to easily get a complete build environment: 0043 0044 ```bash 0045 # Debian/Ubuntu -- Enable deb-src entries /etc/apt/sources beforehand 0046 sudo apt build-dep mlt kdenlive 0047 # Fedora/CentOS -- Install builddep beforehand 0048 dnf builddep mlt kdenlive 0049 # OpenSUSE 0050 zypper source-install --build-deps-only mlt kdenlive 0051 ``` 0052 Or install the dependencies explicitly: 0053 0054 ```bash 0055 # KDE Frameworks 5, based on Qt5 0056 sudo apt install libkf5archive-dev libkf5bookmarks-dev libkf5coreaddons-dev libkf5config-dev \ 0057 libkf5configwidgets-dev libkf5dbusaddons-dev libkf5kio-dev libkf5widgetsaddons-dev \ 0058 libkf5notifyconfig-dev libkf5newstuff-dev libkf5xmlgui-dev libkf5declarative-dev \ 0059 libkf5notifications-dev libkf5guiaddons-dev libkf5textwidgets-dev libkf5purpose-dev \ 0060 libkf5iconthemes-dev libkf5crash-dev libkf5filemetadata-dev libkf5codecs-dev kio \ 0061 kinit qtdeclarative5-dev libqt5svg5-dev qml-module-qtquick-controls libqt5networkauth5-dev \ 0062 qtmultimedia5-dev qtquickcontrols2-5-dev qttools5-dev breeze-icon-theme breeze 0063 0064 # Multimedia stack 0065 sudo apt install frei0r-plugins ffmpeg 0066 0067 # MLT, except if you want to build it manually 0068 sudo apt install libmlt++-dev libmlt-dev melt 0069 0070 # Dependencies for localization 0071 sudo apt install ruby subversion gnupg2 gettext 0072 0073 0074 ``` 0075 #### Clone the repositories 0076 0077 In your development directory, run: 0078 0079 ```bash 0080 git clone https://invent.kde.org/multimedia/kdenlive.git 0081 ``` 0082 0083 #### Building MLT (not usually necessary) 0084 It is recommended to use your distro packages unless you have a reason to use MLT's git. 0085 To build manually: 0086 0087 ```bash 0088 # Install MLT dependencies 0089 sudo apt install libxml++2.6-dev libavformat-dev libswscale-dev libavfilter-dev libavutil-dev libavdevice-dev libsdl1.2-dev librtaudio-dev libsox-dev libsamplerate0-dev librubberband-dev libebur128-dev 0090 0091 # Get MLT's source code 0092 git clone https://github.com/mltframework/mlt.git 0093 cd mlt 0094 mkdir build 0095 cd build 0096 # To build with Qt5, you may also enable other optional modules in this command (-GNinja is optional, to build with the faster Ninja command) 0097 cmake .. -GNinja -DMOD_QT=ON 0098 # To build with Qt6: 0099 cmake .. -GNinja -DMOD_QT=OFF -DMOD_QT6=ON 0100 #install (use make instead of ninja if ninja is not used) 0101 sudo ninja install 0102 0103 ``` 0104 0105 #### Build and install the projects 0106 0107 You should decide where you want to install your builds: 0108 0109 - by default it goes to `/usr/local` (good option if you are admin of the machine, normally programs there are automatically detected); 0110 - you may use `$HOME/.local` user-writable directory (good option if you don't want to play with admin rights, programs there are also usually found) 0111 - you may want to override the distribution files in `/usr` (then you have to remove MLT & Kdenlive binary & data packages first) 0112 - you can pick any destination you like (eg in `/opt` or anywhere in `$HOME`, then you will have to set several environment variables for programs, libs and data to be found) 0113 0114 Let's define that destination as `INSTALL_PREFIX` variable; also you can set `JOBS` variable to the number of threads your CPU can offer for builds. 0115 0116 And build the dependencies (MLT) before the project (Kdenlive): 0117 0118 ```bash 0119 INSTALL_PREFIX=$HOME/.local # or any other choice, the easiest would be to leave it empty ("") 0120 JOBS=4 0121 0122 # Only if you want to compile MLT manually 0123 cd mlt 0124 mkdir build && cd build 0125 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX 0126 make -j$JOBS 0127 make install 0128 # 'sudo make install' if INSTALL_PREFIX is not user-writable 0129 0130 # Kdenlive 0131 cd ../../kdenlive 0132 mkdir build && cd build 0133 # Even if you specified a user-writable INSTALL_PREFIX, some Qt plugins like the MLT thumbnailer are 0134 # going be installed in non-user-writable system paths to make them work. If you really do not want 0135 # to give root privileges, you need to set KDE_INSTALL_USE_QT_SYS_PATHS to OFF in the line below. 0136 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DRELEASE_BUILD=OFF 0137 ``` 0138 0139 ```bash 0140 make -j$JOBS 0141 make install 0142 # 'sudo make install' if INSTALL_PREFIX is not user-writable or if KDE_INSTALL_USE_QT_SYS_PATHS=ON 0143 ``` 0144 0145 Note that `make install` is required for Kdenlive, otherwise the effects will not be installed and cannot be used. 0146 0147 #### Run Kdenlive 0148 0149 If you didn't build in a system path in which all libs and data are automatically found, you will need to set environment variables to point to them. 0150 This is done by the auto-generated script in `kdenlive/build` that must be sourced (to keep variables set in current shell, unlike just executing the script): 0151 0152 ```bash 0153 . prefix.sh 0154 kdenlive 0155 ``` 0156 0157 ## <a name="build-craft">Build with KDE Craft (Linux, Windows, macOS)</a> 0158 0159 [Craft](https://community.kde.org/Craft) is a tool to build the sources and its third-party requirements. It is an easy way to build software, but however not ideal if you want to build Kdenlive for development purposes. 0160 0161 1. Set up Craft as described [here](https://community.kde.org/Craft#Setting_up_Craft). (On Windows choose MinGW as compiler!) 0162 2. Start building kdenlive. You can simply run `craft --target=master kdenlive` 0163 3. Within the the craft environment you can running Kdenlive is as simple as `kdenlive` 0164 0165 _Notes for Craft on macOS with arm M1 chip_: currently (april 2022), Craft doesn't support arm toolchain to compile. Therefore, you must compile in x84_64 mode. To do this, before launching craft using the ```craftenv.sh``` script, you must enter the following command: 0166 ``` 0167 arch -arch x86_64 zsh -li 0168 ``` 0169 After this you can follow the standard Craft procedure to compile Kdenlive. 0170 0171 ### Tips for Craft 0172 0173 * If you want to compile kdenlive in debug mode, you can do so by running `craft --buildtype Debug kdenlive` 0174 * If you want to compile the stable version instead of the master with that last changes, remove `--target=master` from the craft command: `craft kdenlive` 0175 * With Craft you can also easily package Kdenlive as `.dmg`, `.exe` or `.appimage` (depending on your platform): `craft --target=master --package kdenlive` The output can be found in `CraftRoot/tmp` 0176 * For more instructions and tipps on Craft see https://community.kde.org/Craft 0177 0178 ## Various development tricks 0179 0180 ### Debugging 0181 0182 Having debug symbols helps getting much more useful information from crash logs or analyzers outputs; this is enabled at configure stage. 0183 - append `-DCMAKE_BUILD_TYPE=Debug` to `cmake` line of kdenlive and/or mlt 0184 0185 0186 ### Running tests 0187 0188 Kdenlive test coverage is focused mostly on timeline model code (extending tests to more parts is highly desired). To run those tests, append to `cmake` line: 0189 `-DBUILD_TESTING=ON` 0190 0191 ### Fuzzer 0192 0193 Kdenlive embeds a fuzzing engine that can detect crashes and auto-generate tests. It requires to have clang installed (generally in `/usr/bin/clang++`). This can be activated in `cmake` line with: 0194 `-DBUILD_FUZZING=ON -DCMAKE_CXX_COMPILER=/usr/bin/clang++` 0195 0196 To learn more fuzzing especially in the context of Kdenlive read this [blog post][fuzzer-blog]. 0197 0198 ### Help file for QtCreator, KDevelop, etc. 0199 0200 You can automatically build and install a `*.qch` file with the doxygen docs about the source code to use it with your IDE like Qt Assistant, Qt Creator or KDevelop. This can be activated in `cmake` line with: 0201 `-DBUILD_QCH=ON` 0202 0203 You can find the `kdenlive.qch` at `build/src` and after `make install` at `${CMAKE_INSTALL_PREFIX}/lib/cmake/kdenlive` 0204 0205 To add the `kdenlive.qch` file to Qt Creator, select **Tools** > **Options** > **Help** > **Documentation** > **Add**. 0206 0207 ### Speeding up compilations 0208 0209 Ninja build systems, compared to make, seems faster and better detecting which files are necessary to rebuild. You can enable it appending `-GNinja` to `cmake` line 0210 CCache also helps: `-DCMAKE_CXX_COMPILER_LAUNCHER=ccache` 0211 0212 ### Analyzers 0213 0214 You can configure Kdenlive to embed tooling for runtime analysis, for example appending to cmake line: 0215 `-DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DECM_ENABLE_SANITIZERS='address'` 0216 0217 This one will report in terminal all memory handling errors found during execution. 0218 0219 ### Building OpenCV tracking module 0220 0221 MLT/Kdenlive tracking effect relies on a "contrib" a OpenCV module that is not shipped by distributions. 0222 We build it in our AppImage but you may want it on your system (note OpenCV deserves its reputation of being difficult to build!). 0223 0224 ```bash 0225 wget https://github.com/opencv/opencv/archive/4.5.5.tar.gz -O opencv-4.5.5.tar.gz 0226 wget https://github.com/opencv/opencv_contrib/archive/4.5.5.tar.gz -O opencv_contrib-4.5.5.tar.gz 0227 tar xaf opencv-4.5.5.tar.gz 0228 tar xaf opencv_contrib-4.5.5.tar.gz 0229 cd opencv-4.5.5 0230 mkdir build 0231 cd build 0232 # Important: if want to install to the default location 0233 # (ie. you left INSTALL_PREFIX empty in the previous step where we configured it) 0234 # remove -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX from the next command! 0235 cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ 0236 -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.5.5/modules \ 0237 -DOPENCV_GENERATE_PKGCONFIG=ON -DBUILD_LIST=tracking -DOPENCV_BUILD_3RDPARTY_LIBS=OFF 0238 make install 0239 ``` 0240 0241 Then you will have to rebuild MLT appending `-DMOD_OPENCV=ON` to `cmake` line! 0242 0243 ### Building frei0r 0244 0245 You may be interested in building latest frei0r effects library. So get dependencies, clone repository, and build-install: 0246 0247 ```bash 0248 sudo apt build-dep frei0r 0249 git clone https://github.com/dyne/frei0r.git 0250 cd frei0r 0251 mkdir build 0252 cd build 0253 cmake .. -DWITHOUT_OPENCV=true -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX 0254 ``` 0255 0256 Note: as of 20.04, frei0r doesn't support recent OpenCV (and effects using it seemed not very stable) 0257 0258 ### Building in Docker 0259 0260 It is possible to run the above commands inside a container, with a fresh Ubuntu for example. 0261 Note that Kdenlive cannot be easily run from inside the Docker container as it is a GUI application. 0262 0263 ```bash 0264 # Spin up a Docker container 0265 # The --rm flag removes the container after it is stopped. 0266 docker run -it --rm ubuntu:22.04 0267 0268 # Now install the dependencies etc. 0269 # Note that you are root in the container, and sudo neither exists nor works. 0270 apt install … 0271 0272 # When you are done, exit 0273 exit 0274 ``` 0275 0276 ## Translating Kdenlive 0277 0278 TODO 0279 0280 [fuzzer-blog]: https://kdenlive.org/en/2019/03/inside-kdenlive-how-to-fuzz-a-complex-gui-application/