Kdenlive/Development/KF5: Difference between revisions

From KDE Community Wiki
(75 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Working with Kdenlive on KF5 ==
== Working with Kdenlive on KF5 ==
'''If you want to test the KF5 (KDE Frameworks 5, based on Qt5) version of Kdenlive, you need a distribution that provides a running KF5 environnment, like Kubuntu artful (17.10) preview releases.'''<br>
Some outdated infos about the KF5 refactoring process can be found on  [[Kdenlive/Development/KF5/Refactoring|Refactoring page]]


=== Compiling MLT with Qt5 support ===
=== Compiling MLT with Qt5 support ===


The first step is to recompile MLT with Qt5 support.
The first step is to compile MLT with Qt5 support. This is only required if you don't have a recent distribution or want to try recent features/fixes introduced in MLT. Otherwise you can skip and go directly to the next chapter - compiling Kdenlive.


First install dependencies, on ubuntu:
To prevent conflicts, it is recommended to remove your distribution packages (melt, libmlt, libmlt++).


* First install the dependencies:
On ubuntu:
  sudo apt-get install build-essential pkg-config \
  sudo apt-get install build-essential pkg-config \
libavformat-dev libavdevice-dev frei0r-plugins-dev libgtk2.0-dev libexif-dev \
  libavformat-dev libavdevice-dev frei0r-plugins-dev frei0r-plugins libgtk2.0-dev libexif-dev \
libmovit-dev libsdl1.2-dev libsox-dev libxml2-dev \
  libsdl2-dev libsox-dev libxml2-dev \
ladspa-sdk libcairo2-dev libswscale-dev qtscript5-dev libqt5svg5-dev libqt5opengl5-dev
  ladspa-sdk libcairo2-dev libswscale-dev qtscript5-dev libqt5svg5-dev \
  libqt5opengl5-dev libepoxy-dev libeigen3-dev libfftw3-dev \
  git  yasm libtool automake  autoconf  libtool-bin  libtheora-bin  libtheora-dev \
  intltool swig libmp3lame-dev libgavl-dev libsamplerate0-dev  libjack-dev  libsoup2.4-dev  \
  python-dev  libkf5crash-dev  libkf5filemetadata-dev


Then configure (enabling all components, selecting target install dir, and pointing to Qt5 - ubuntu 15.04 flavor with multiarch enabled):
(optional packages: libmovit-dev)


  ./configure --enable-gpl --enable-gpl3 --prefix=/opt/kdenlive5 \
On OpenSuse 13.2, for MLT+Kdenlive (not very used to that system, please correct me):
  --qt-includedir=/usr/include/x86_64-linux-gnu/qt5 --qt-libdir=/usr/lib/x86_64-linux-gnu
  zypper ar -f http://download.opensuse.org/repositories/KDE:/Qt5/openSUSE_13.2 Qt5
zypper ar -f http://download.opensuse.org/distribution/13.2/repo/oss/ oss
zypper ar -f http://download.opensuse.org/source/distribution/13.2/repo/oss/ oss-src
zypper refresh
zypper si kdenlive libmlt
  zypper install libqt5-qtscript-devel libqt5-qtsvg-devel \
  libQt5OpenGL-devel libQt5Concurrent-devel kplotting-devel \
  libQt5Test-devel kparts-devel knotifications-devel


Compile and install:
If you want to use MLT's Motion Tracker filter, you need to install OpenCV >= 3.1 with its contrib module.
This can be done with the following commands:
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake .. -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
make -j5
sudo make install


make install
* Then get the source code for MLT:


And make sure it works:
git clone https://github.com/mltframework/mlt.git
or download the latest release from https://github.com/mltframework/mlt/releases/latest.


* Configure and build
By default, MLT will be installed in /usr/local. If you want to install to a non-standard local path, you can set it by adding "--prefix=/path/to/your/install"
cd mlt
export CXXFLAGS=-std=c++11
./configure --enable-gpl --enable-gpl3
make
sudo make install
* Check that your compiled melt  works:
melt color:red
Should play open a preview window with a red color clip
  melt myclip.mp4
  melt myclip.mp4
Should play your test file in a video window.


As Dan Dennedy recently pointed out, the frei0r package, which contains many effects, sometimes causes crashes because 2 of its filters are usually compiled against Qt4, which conflicts with Qt5.
=== Get the Qt5/KF5 branch of Kdenlive ===
The solution is to balcklist these 2 filters, by adding them in MLT's blacklist.txt file, found in:
We are cloning the git repository for kdenlive into a local folder on your hard drive. This step will create a new kdenlive folder in the current directory. In this example I cloned into ~/kdenlive/kdenlive_git. Which creates ~/kdenlive/kdenlive_git/kdenlive


$INSTALL_PREFIX/share/mlt/frei0r/blacklist.txt
<pre>
cd ~/kdenlive
mkdir kdenlive_git
cd kdenlive_git
git clone git://anongit.kde.org/kdenlive.git
</pre>


Just add these lines to the file:
Success looks like:


frei0r.facebl0r
<pre>
frei0r.facedetect
Cloning into 'kdenlive'...
remote: Counting objects: 67026, done.
remote: Compressing objects: 100% (12978/12978), done.
remote: Total 67026 (delta 54842), reused 65893 (delta 53935)
Receiving objects: 100% (67026/67026), 22.35 MiB | 582.00 KiB/s, done.
Resolving deltas: 100% (54842/54842), done.
Checking connectivity... done.
</pre>


=== Get the frameworks branch of Kdenlive ===
The development branch is currently in 'refactoring_timeline'. So to get the latest code:
<pre>
cd kdenlive
git checkout -b refactoring_timeline origin/refactoring_timeline
</pre>


# Get the sources:
Create a build directory inside the kdenlive directory that git created:
#: git clone git://anongit.kde.org/kdenlive
# Get the frameworks branch:
#: git checkout -b frameworks origin/frameworks


Create a build directory:
<code>mkdir build;cd build</code>


cd kdenlive;mkdir build;cd build
(working dir now ~/kdenlive/kdenlive_git/kdenlive/build in our eg )


=== Compile Kdenlive ===
=== Compile Kdenlive ===
(These  instructions do not include a build of the vidstab package and thus your built kdenlive will be missing the stabilization feature)
You will need to install several Qt/KDE devel packages to successfully compile.
On Ubuntu the following packages might pull all the necessary dependencies:


You will need to install several Qt/KDE devel packages to successfully compile. On Ubuntu 15.04 the following packages will pull all the necessary dependencies:
sudo apt-get install \
  libkf5archive-dev libkf5bookmarks-dev libkf5coreaddons-dev libkf5config-dev \
  libkf5configwidgets-dev libkf5dbusaddons-dev libkf5kio-dev libkf5widgetsaddons-dev \
  libkf5notifyconfig-dev libkf5newstuff-dev libkf5xmlgui-dev libkf5declarative-dev \
  libkf5notifications-dev libkf5guiaddons-dev libkf5textwidgets-dev libkf5iconthemes-dev \
  kdoctools-dev libkf5crash-dev libkf5filemetadata-dev extra-cmake-modules \
  libsm-dev cmake qtdeclarative5-dev kde-runtime kinit  kio \
  qml-module-qtquick-controls


  sudo apt-get install libkf5newstuff-dev libkf5notifications-dev libkf5notifyconfig-dev libkf5plotting-dev \
The main problem with completing the build is often ensuring you have all the required dependencies.  
  extra-cmake-modules kdoctools-dev libsm-dev libv4l-dev libav-tools cmake
A trick for ensuring you do have them built - since the list changes all the time is as follows:
In your package manager (eg synaptic) turn on sources from deb-src main restricted,  universe and multiverse for both the bionic and bionic-updates (in synaptic Settings > Repositories) and then execute this command.
  sudo apt-get build-dep kdenlive


Then build Kdenlive with the following options (in your build dir):
To avoid problems with plugins and libraries, it is easier to install Kdenlive in /usr:
export LD_LIBRARY_PATH=/opt/kdenlive5/lib
  cmake .. -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_INSTALL_PREFIX=/usr
export XDG_DATA_DIRS=/opt/kdenlive5/share:$XDG_DATA_DIRS:/usr/share
  PKG_CONFIG_PATH=/opt/kdenlive5/lib/pkgconfig cmake .. -DCMAKE_INSTALL_PREFIX=/opt/kdenlive5
make -j4 install


And test
However if you prefer to install to a custom prefix (recommended only if you know what you are doing) :
  /opt/kdenlive5/bin/kdenlive
  export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX


Frameworks 5 packages are hard come by in current linux versions. Beta versions of Ubuntu/Kubuntu 15.04 are a safe bet for getting these packages. Consider installing a virtual Ubuntu/Kubuntu 15.04 for testing the frameworks branch.
Then build and install:
make -j5
sudo make install
 
===Execute the Built Kdenlive ===
Test the built kdenlive by executing the kdenlive binary in the bin folder in your install path (again making use of the INSTALL_PREFIX shell variable we defined during the melt build)
 
<code>
$INSTALL_PREFIX/bin/kdenlive
</code>
 
The above command should start kdenlive. However, It is important to have especially the environment variable <code>XDG_DATA_DIRS</code> correctly set to point to the share dir inside the Kdenlive installation directories. The given standard paths for <code>XDG_DATA_DIRS</code> are typically /usr/share as well as /usr/local/share. So if you install Kdenlive to some other place, such as within your own home directory, make sure to add the path to your home-based share dir to <code>XDG_DATA_DIRS</code> before attempting to start Kdenlive. Failing to do so causes Kdenlive to crash in unexpected situations, such as when trying to select a transition in the timeline.
 
Here's a nifty little script that sets up the environment variables automatically, then fires up Kdenlive; place this script next to your kdenlive executable (ie in $INSTALL_PREFIX/bin/). And don't forget to make it executable (chmod u+x kdenlive.sh).
 
#!/bin/bash
SCRIPT_NAME=$(readlink -f "$0")
SCRIPT_PATH=$(dirname "$SCRIPT_NAME")
export INSTALL_PREFIX=$(dirname "$SCRIPT_PATH")
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share
export XDG_CONFIG_DIRS=$INSTALL_PREFIX/etc/xdg:$XDG_CONFIG_DIRS
echo "Environment set up for $INSTALL_PREFIX"
$INSTALL_PREFIX/bin/kdenlive
 
If you want to be sure that you are executing the kdenlive you just built you might want to increase the version number of the build. This can be done by editing src/kdenlive/CMakeLists.txt
 
=== Older Linux Distributions ===


A light virtualization option is using chroot, setting it up in a ubuntu/debian environment is as simple as:
A light virtualization option is using chroot, setting it up in a ubuntu/debian environment is as simple as:


  sudo -s
  sudo -s
  apt-get install schroot debottstrap
  apt-get install schroot debootstrap
  debootstrap --arch amd64 vivid $CHROOTDIR http://us.archive.ubuntu.com/ubuntu/
  debootstrap --arch amd64 artful $CHROOTDIR http://us.archive.ubuntu.com/ubuntu/
  cat << === >> /etc/schroot/chroot.d/vivid.conf
  cat << === >> /etc/schroot/chroot.d/artful.conf
  [vivid]
  [artful]
  aliases=default
  aliases=default
  description=vivid
  description=artful
  type=directory
  type=directory
  profile=desktop
  profile=desktop
Line 78: Line 168:
  users=$USER
  users=$USER
  ===
  ===
  schroot -c -p vivid
  schroot -c artful -p
 
after running the above you will get a prompt like
(artful)root@pcname:


== Refactoring and code cleanup ==
You can then follow the install instructions above for melt and kdenlive.  Note that many of the required packages are in the "Universe" repository - which is not enabled by default on the chroot setup.  So you will need to add that repository to the package manager (edit your chroots  /etc/apt/sources.list ) in order to be able to find the required packages.  Don't forget the  ''apt-get update'' afterwards.


Some parts of the code really need a refactoring to make the code cleaner and easier to maintain / change. Some work has already been done by separating functions in files and folders.
If, when you test melt, it complains
./melt: error while loading shared libraries: libmlt.so.6: cannot open shared object file: No such file or directory


The plan is now to rework how Kdenlive interacts with MLT, taking ideas from [http://www.shotcut.org Shotcut] which is a video editor written by Dan Dennedy, author of MLT.
Then try setting shell variables LD_LIBRARY_PATH and  XDG_DATA_DIRS
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share


As a coordination effort, we created a Kdenlive entry in [http://todo.kde.org todo.kde.org] (identity login required), so that developers can display what they are working on. A public version is available [https://todo.kde.org/?controller=board&action=readonly&token=12c577c6fa43a6f57160b0c8e7763920c2e2f0ae058dc7a0fd061815a1ce here].
== Installing a recent git version of FFmpeg for Kdenlive (optional) ==


Basically the Kdenlive/MLT refactoring is a 3 step plan:
The LibAV/FFmpeg libraries that do all the encoding/decoding stuff are evolving quickly, but distributions do not always provide a recent version of these libraries. If you want to benefit from the latest features / fixes from these libraries, here is a quick howto on installing a recent FFmpeg version for MLT/Kdenlive without touching your system's LibAV/FFmpeg official version. This howto provides details for FFmpeg, but can probably be easily adapted for LibAV if you have a preference.
* Get required libraries:
  sudo apt-get install libfaac-dev libgsm1-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev
libschroedinger-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev libx265-dev libxvidcore-dev libdc1394-22-dev yasm


=== Step 1: Handling of project clips ===
* Get the latest FFmpeg sources:
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg


Currently, Mlt clips are stored in the DocClipBase class. A lot of the clip properties are stored in QMap or QDomDocument there. The idea is to:
* configure the FFmpeg build with the "'''suffix'''" option. It means all FFmpeg programs/libraries will be renamed to use that suffix so that they do not mess up your system's official versions (in my exemple, the suffix is <em>mlt</em>, so ffplay will be called ffplaymlt). Choose the install prefix of your choice, but do not install in /usr. Here is a sample configure:
* Move to a structure closer to Shotcut, by storing all the project clips in a special playlist that is not displayed in timeline. Then, the DocclipBase class can be simplified to just read properties directly from the clip in this special playlist, and we stop storing xml properties.  
./configure --prefix=/usr/local --progs-suffix=mlt --build-suffix=mlt --enable-shared --enable-libmp3lame \
* Rewrite the project bin (tree) to use the model / view that was featured in Till Theato's refactoring branch
--enable-gpl --enable-libfaac --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid \
* Simplify the Kdenlive file format which currently mostly clips twice (once in the usual MLT playlist and once in "kdenlive_producer" list). This should also improve compatibility with Shotcut project files.
--enable-x11grab --enable-libgsm --enable-libx264 --enable-libtheora --enable-libdc1394 --enable-nonfree \
* As a bonus, this should allow to add effects to clips in the project tree which will be a very useful feature (especially for color correction).
--disable-stripping --enable-avfilter --enable-libschroedinger --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-version3 --enable-libvpx
'''Status''': in progress, mostly done. [https://todo.kde.org/?controller=task&action=readonly&task_id=701&token=12c577c6fa43a6f57160b0c8e7763920c2e2f0ae058dc7a0fd061815a1ce Detailled infos]
 
* compile the ffmpeg build
<code>
make -j4
</code>
<ref>The -j4 parameter - this controls the number of parallel compilation jobs. -j4 is fine for a Core i3/i5, while it bores a Core i7 to death. On a Core i7 thus better use -j8 as it speeds up compilation a lot and makes use of all available real cores...</ref>


=== Step 2: Rewrite Monitor code ===
* Install the build ffmpeg
<code>make install
</code>
* Next, recompile MLT to use this special FFmpeg version. Just add these 2 parameters to the MLT configure, where avformat-shared points to the install prefix of your custom FFmpeg, and avformat-suffix is the suffix used in previous step:
--avformat-shared=/usr/local --avformat-suffix=mlt
* Recompile Kdenlive.
* After running the newly compiled Kdenlive ensure that, in the settings dialog under environment,  the FFmpeg and FFplay paths point to your newly compiled versions (in my example it will be /usr/local/ffmpegmlt and /usr/local/ffplaymlt)


The idea is to kind of import Shotcut's monitor code and adapt it to Kdenlive. This will bring back the Movit integration and will require work in several parts to make sure everyone is aware when we use Movit (some effects should be enabled/disabled depending on this, etc).
==A build script==
[[File:build-kdenlive_v26b.sh.zip]]


'''Status''': todo. [https://todo.kde.org/?controller=task&action=readonly&task_id=711&token=12c577c6fa43a6f57160b0c8e7763920c2e2f0ae058dc7a0fd061815a1ce Detailled infos]
This is a script to  build kdenlive and dependencies in a sandbox. Downloads sources from repositories and does the build.  
Based on Dan Dennedy version 26 of the build-kdenlive.sh script


=== Step 3: The Timeline ===
http://www.mltframework.org/twiki/bin/view/MLT/BuildScripts#Kdenlive
http://github.com/mltframework/mlt-scripts/raw/master/build/build-kdenlive.sh
This  version differs from the Dan Dennedy script  in that it builds the KF5 version of the application
Works with ver 15.NN and higher versions of kdenlive<ref> If you want to build a specific version of kdenlive then you can edit the build script to set KDENLIVE_HEAD=0 (instead of 1) and supply the version in the KDENLIVE_REVISION var. eg
<br>KDENLIVE_REVISION=remotes/origin/Applications/15.08
<br>To see what remote branches you could specify for kdenlive
<br> cd $INSTALL_DIR/src/kdenlive
<br>git branch -r
<br>choose a branch from the list and prefix its name with remotes/ when you include it as the KDENLIVE_REVISION option
</ref>


Currently the timeline stores all clips positions internally, being completely independant of the MLT playlist. This is due to historical reasons, but now leads to the infamous "timeline corruption" bugs that we have been fighting for years. We should now rework on this to have a direct connection between the timeline and MLT's playlist so that the timeline is a direct representation of MLT's data.
* Create a folder where you would like kdenlive installed. Eg ~/development/kdenlive
* Extract the build-kdenlive_v26b.sh to a folder anywhere.
* Make build-kdenlive_v26b.sh executable
* Edit build-kdenlive_v26b.sh  and set the INSTALL_DIR var 
eg INSTALL_DIR="$HOME/development/kdenlive"


'''Status''': todo. [https://todo.kde.org/?controller=task&action=readonly&task_id=750&token=12c577c6fa43a6f57160b0c8e7763920c2e2f0ae058dc7a0fd061815a1ce Detailled infos]
Look in the comments at the start to see the list of dependencies you should install before hand.
Install them using the sudo apt-get install ... commands shown.


=== Step 4: everything else ===
in a terminal execute ./build-kdenlive_v26b.sh


There are many other tasks, one of the biggest will be a rewrite of the titler code, which currently uses MLT's kdenlivetitle module that was fine for very basic titles but should now be ported to something based on an HTML overlay, like webvfx which would allow animations and many other improvements.
When the job finishes cd to the INSTALL_DIR choosen above and then into the folder named for today's date <ref>You can turn off the feature of the script that builds to a folder named for today's date by setting AUTO_APPEND_DATE=0 in the script</ref>


The Animation feature of effects parameters also should be integrated.
eg
cd /home/ttguy/development/kdenlive/20151007/


execute this to start the application
./start-kdenlive


== What's new in Kdenlive/KF5 ==
==Footnotes==
=== File format ===
<references />
The Kdenlive project file format has changed. In previous KDE4 Kdenlive versions, some xml was manually added to MLT's xml output to store Kdenlive specific data. This has now changed and all data will be read / written by MLT's XML module. This means that all Kdenlive properties must be passed onto MLT objects (tractor, playlist, clips, etc).
A description of these new properties can be found on the [[Kdenlive/Development/File format | File Format Info Page]]

Revision as of 13:48, 17 November 2018

Working with Kdenlive on KF5

If you want to test the KF5 (KDE Frameworks 5, based on Qt5) version of Kdenlive, you need a distribution that provides a running KF5 environnment, like Kubuntu artful (17.10) preview releases.
Some outdated infos about the KF5 refactoring process can be found on Refactoring page

Compiling MLT with Qt5 support

The first step is to compile MLT with Qt5 support. This is only required if you don't have a recent distribution or want to try recent features/fixes introduced in MLT. Otherwise you can skip and go directly to the next chapter - compiling Kdenlive.

To prevent conflicts, it is recommended to remove your distribution packages (melt, libmlt, libmlt++).

  • First install the dependencies:

On ubuntu:

sudo apt-get install build-essential pkg-config \
 libavformat-dev libavdevice-dev frei0r-plugins-dev  frei0r-plugins libgtk2.0-dev libexif-dev \
 libsdl2-dev libsox-dev libxml2-dev \
 ladspa-sdk libcairo2-dev libswscale-dev qtscript5-dev libqt5svg5-dev \
 libqt5opengl5-dev libepoxy-dev libeigen3-dev libfftw3-dev \
 git  yasm libtool automake   autoconf  libtool-bin  libtheora-bin  libtheora-dev \
 intltool swig libmp3lame-dev libgavl-dev libsamplerate0-dev   libjack-dev  libsoup2.4-dev   \
 python-dev  libkf5crash-dev  libkf5filemetadata-dev

(optional packages: libmovit-dev)

On OpenSuse 13.2, for MLT+Kdenlive (not very used to that system, please correct me):

zypper ar -f http://download.opensuse.org/repositories/KDE:/Qt5/openSUSE_13.2 Qt5
zypper ar -f http://download.opensuse.org/distribution/13.2/repo/oss/ oss
zypper ar -f http://download.opensuse.org/source/distribution/13.2/repo/oss/ oss-src
zypper refresh
zypper si kdenlive libmlt
zypper install libqt5-qtscript-devel libqt5-qtsvg-devel \
 libQt5OpenGL-devel libQt5Concurrent-devel kplotting-devel \
 libQt5Test-devel kparts-devel knotifications-devel

If you want to use MLT's Motion Tracker filter, you need to install OpenCV >= 3.1 with its contrib module. This can be done with the following commands:

git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build
cd build
cmake .. -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules
make -j5
sudo make install
  • Then get the source code for MLT:
git clone https://github.com/mltframework/mlt.git

or download the latest release from https://github.com/mltframework/mlt/releases/latest.

  • Configure and build

By default, MLT will be installed in /usr/local. If you want to install to a non-standard local path, you can set it by adding "--prefix=/path/to/your/install"

cd mlt
export CXXFLAGS=-std=c++11
./configure --enable-gpl --enable-gpl3
make
sudo make install
  • Check that your compiled melt works:
melt color:red

Should play open a preview window with a red color clip

melt myclip.mp4

Should play your test file in a video window.

Get the Qt5/KF5 branch of Kdenlive

We are cloning the git repository for kdenlive into a local folder on your hard drive. This step will create a new kdenlive folder in the current directory. In this example I cloned into ~/kdenlive/kdenlive_git. Which creates ~/kdenlive/kdenlive_git/kdenlive

cd ~/kdenlive
mkdir kdenlive_git
cd kdenlive_git
git clone git://anongit.kde.org/kdenlive.git

Success looks like:

Cloning into 'kdenlive'...
remote: Counting objects: 67026, done.
remote: Compressing objects: 100% (12978/12978), done.
remote: Total 67026 (delta 54842), reused 65893 (delta 53935)
Receiving objects: 100% (67026/67026), 22.35 MiB | 582.00 KiB/s, done.
Resolving deltas: 100% (54842/54842), done.
Checking connectivity... done.

The development branch is currently in 'refactoring_timeline'. So to get the latest code:

cd kdenlive
git checkout -b refactoring_timeline origin/refactoring_timeline

Create a build directory inside the kdenlive directory that git created:

mkdir build;cd build

(working dir now ~/kdenlive/kdenlive_git/kdenlive/build in our eg )

Compile Kdenlive

(These instructions do not include a build of the vidstab package and thus your built kdenlive will be missing the stabilization feature)

You will need to install several Qt/KDE devel packages to successfully compile.

On Ubuntu the following packages might pull all the necessary dependencies:

sudo apt-get install \
 libkf5archive-dev libkf5bookmarks-dev libkf5coreaddons-dev libkf5config-dev \
 libkf5configwidgets-dev libkf5dbusaddons-dev libkf5kio-dev libkf5widgetsaddons-dev \
 libkf5notifyconfig-dev libkf5newstuff-dev libkf5xmlgui-dev libkf5declarative-dev \
 libkf5notifications-dev libkf5guiaddons-dev libkf5textwidgets-dev libkf5iconthemes-dev \
 kdoctools-dev libkf5crash-dev libkf5filemetadata-dev extra-cmake-modules \
 libsm-dev cmake qtdeclarative5-dev kde-runtime kinit  kio \
 qml-module-qtquick-controls

The main problem with completing the build is often ensuring you have all the required dependencies. A trick for ensuring you do have them built - since the list changes all the time is as follows: In your package manager (eg synaptic) turn on sources from deb-src main restricted, universe and multiverse for both the bionic and bionic-updates (in synaptic Settings > Repositories) and then execute this command.

sudo apt-get build-dep kdenlive

To avoid problems with plugins and libraries, it is easier to install Kdenlive in /usr:

cmake .. -DKDE_INSTALL_USE_QT_SYS_PATHS=ON -DCMAKE_INSTALL_PREFIX=/usr

However if you prefer to install to a custom prefix (recommended only if you know what you are doing) :

export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX

Then build and install:

make -j5
sudo make install

Execute the Built Kdenlive

Test the built kdenlive by executing the kdenlive binary in the bin folder in your install path (again making use of the INSTALL_PREFIX shell variable we defined during the melt build)

$INSTALL_PREFIX/bin/kdenlive

The above command should start kdenlive. However, It is important to have especially the environment variable XDG_DATA_DIRS correctly set to point to the share dir inside the Kdenlive installation directories. The given standard paths for XDG_DATA_DIRS are typically /usr/share as well as /usr/local/share. So if you install Kdenlive to some other place, such as within your own home directory, make sure to add the path to your home-based share dir to XDG_DATA_DIRS before attempting to start Kdenlive. Failing to do so causes Kdenlive to crash in unexpected situations, such as when trying to select a transition in the timeline.

Here's a nifty little script that sets up the environment variables automatically, then fires up Kdenlive; place this script next to your kdenlive executable (ie in $INSTALL_PREFIX/bin/). And don't forget to make it executable (chmod u+x kdenlive.sh).

#!/bin/bash
SCRIPT_NAME=$(readlink -f "$0")
SCRIPT_PATH=$(dirname "$SCRIPT_NAME")
export INSTALL_PREFIX=$(dirname "$SCRIPT_PATH")
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share
export XDG_CONFIG_DIRS=$INSTALL_PREFIX/etc/xdg:$XDG_CONFIG_DIRS
echo "Environment set up for $INSTALL_PREFIX"
$INSTALL_PREFIX/bin/kdenlive

If you want to be sure that you are executing the kdenlive you just built you might want to increase the version number of the build. This can be done by editing src/kdenlive/CMakeLists.txt

Older Linux Distributions

A light virtualization option is using chroot, setting it up in a ubuntu/debian environment is as simple as:

sudo -s
apt-get install schroot debootstrap
debootstrap --arch amd64 artful $CHROOTDIR http://us.archive.ubuntu.com/ubuntu/
cat << === >> /etc/schroot/chroot.d/artful.conf
[artful]
aliases=default
description=artful
type=directory
profile=desktop
directory=$CHROOTDIR
users=$USER
===
schroot -c artful -p

after running the above you will get a prompt like

(artful)root@pcname:

You can then follow the install instructions above for melt and kdenlive. Note that many of the required packages are in the "Universe" repository - which is not enabled by default on the chroot setup. So you will need to add that repository to the package manager (edit your chroots /etc/apt/sources.list ) in order to be able to find the required packages. Don't forget the apt-get update afterwards.

If, when you test melt, it complains

./melt: error while loading shared libraries: libmlt.so.6: cannot open shared object file: No such file or directory

Then try setting shell variables LD_LIBRARY_PATH and XDG_DATA_DIRS

export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib
export XDG_DATA_DIRS=$INSTALL_PREFIX/share:$XDG_DATA_DIRS:/usr/share

Installing a recent git version of FFmpeg for Kdenlive (optional)

The LibAV/FFmpeg libraries that do all the encoding/decoding stuff are evolving quickly, but distributions do not always provide a recent version of these libraries. If you want to benefit from the latest features / fixes from these libraries, here is a quick howto on installing a recent FFmpeg version for MLT/Kdenlive without touching your system's LibAV/FFmpeg official version. This howto provides details for FFmpeg, but can probably be easily adapted for LibAV if you have a preference.

  • Get required libraries:
 sudo apt-get install libfaac-dev libgsm1-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev 
libschroedinger-dev libtheora-dev libvorbis-dev libvpx-dev libx264-dev libx265-dev libxvidcore-dev libdc1394-22-dev yasm
  • Get the latest FFmpeg sources:
git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
  • configure the FFmpeg build with the "suffix" option. It means all FFmpeg programs/libraries will be renamed to use that suffix so that they do not mess up your system's official versions (in my exemple, the suffix is mlt, so ffplay will be called ffplaymlt). Choose the install prefix of your choice, but do not install in /usr. Here is a sample configure:
./configure --prefix=/usr/local --progs-suffix=mlt --build-suffix=mlt --enable-shared --enable-libmp3lame \
--enable-gpl --enable-libfaac --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid \
--enable-x11grab --enable-libgsm --enable-libx264 --enable-libtheora --enable-libdc1394 --enable-nonfree \
--disable-stripping --enable-avfilter --enable-libschroedinger --enable-libopencore-amrnb \
--enable-libopencore-amrwb --enable-version3 --enable-libvpx
  • compile the ffmpeg build

make -j4 [1]

  • Install the build ffmpeg

make install

  • Next, recompile MLT to use this special FFmpeg version. Just add these 2 parameters to the MLT configure, where avformat-shared points to the install prefix of your custom FFmpeg, and avformat-suffix is the suffix used in previous step:
--avformat-shared=/usr/local --avformat-suffix=mlt
  • Recompile Kdenlive.
  • After running the newly compiled Kdenlive ensure that, in the settings dialog under environment, the FFmpeg and FFplay paths point to your newly compiled versions (in my example it will be /usr/local/ffmpegmlt and /usr/local/ffplaymlt)

A build script

File:Build-kdenlive v26b.sh.zip

This is a script to build kdenlive and dependencies in a sandbox. Downloads sources from repositories and does the build. Based on Dan Dennedy version 26 of the build-kdenlive.sh script

http://www.mltframework.org/twiki/bin/view/MLT/BuildScripts#Kdenlive http://github.com/mltframework/mlt-scripts/raw/master/build/build-kdenlive.sh This version differs from the Dan Dennedy script in that it builds the KF5 version of the application Works with ver 15.NN and higher versions of kdenlive[2]

  • Create a folder where you would like kdenlive installed. Eg ~/development/kdenlive
  • Extract the build-kdenlive_v26b.sh to a folder anywhere.
  • Make build-kdenlive_v26b.sh executable
  • Edit build-kdenlive_v26b.sh and set the INSTALL_DIR var
eg INSTALL_DIR="$HOME/development/kdenlive"

Look in the comments at the start to see the list of dependencies you should install before hand. Install them using the sudo apt-get install ... commands shown.

in a terminal execute ./build-kdenlive_v26b.sh

When the job finishes cd to the INSTALL_DIR choosen above and then into the folder named for today's date [3]

eg

cd /home/ttguy/development/kdenlive/20151007/

execute this to start the application

./start-kdenlive

Footnotes

  1. The -j4 parameter - this controls the number of parallel compilation jobs. -j4 is fine for a Core i3/i5, while it bores a Core i7 to death. On a Core i7 thus better use -j8 as it speeds up compilation a lot and makes use of all available real cores...
  2. If you want to build a specific version of kdenlive then you can edit the build script to set KDENLIVE_HEAD=0 (instead of 1) and supply the version in the KDENLIVE_REVISION var. eg
    KDENLIVE_REVISION=remotes/origin/Applications/15.08
    To see what remote branches you could specify for kdenlive
    cd $INSTALL_DIR/src/kdenlive
    git branch -r
    choose a branch from the list and prefix its name with remotes/ when you include it as the KDENLIVE_REVISION option
  3. You can turn off the feature of the script that builds to a folder named for today's date by setting AUTO_APPEND_DATE=0 in the script