Kdenlive and HD video

Tutorials >
I wrote this page while using Kdenlive for all my editing (install notes on my Step2 page).

I've been shooting films with a Panasonic V500 which has pretty reasonable quality and colour, and produces progressive HD video saved as .MTS files. MTS (Mpeg Transport Stream) is something like h264 mp4 AVC compressed video. HD being 1920 x 1080 pixels, interlaced 25fps (1080i), while full HD is progressive 50fps (1080p).

Firstly, compressed HD video files take a lot of cpu power to play or seek through with an editor programme, so unless you have at least a 3rd generation Intel i5 or similar, you will experience staggered playback or pauses while trying to stop and play in Kdenlive (as my old Intel core duo gave me).

[Kdenlive has an auto proxy clip maker for large HD files, so once those have been made - time for a coffee or two if you have a low-spec CPU - playing and cutting is much smoother, but with on-screen quality loss of course from the proxies.]

I locate my STREAM dir on the camera's SD card (inserted) and copy all the MTS files to a raw files disk. Then I use bash to sort the files into folders, by date:

 




Taking still images from MTS

I use Gnome-mplayer to get stills from my film

use these settings:


1. browse to the MTS files, select how many to open and run Gnome MPlayer
the files are added to the play list and you can move to the next easily.

2. space to pause/play, CTRL-T [I change that to CTRL-Z] to capture a still frame (and press space again to un-pause and get the snapshot saved!)
seeking with the left/right keys moves about 10sec onward/back so it might end the film if its short

3. pics saved in the same dir as video files, 6MB .png files
move them to "images/NEW/abc" on your picture storage partition/disk (that's just my way)

-----do 3. after each folder of mts files

4. rename pics in each dir in the /abc dir and run a mogrify command to convert to jpeg format (see my image processing page)

5. once the files are converted, run a couple of commands on them to write the EXIF date to them first, to write the date from the file modify date with
 

and then to adjust the date so that it better matches the real date of the video it came from, e.g.
 
that will set the date on all files, leaving the time stamp as-is



Converting MTS movie files into films

Although it's possible to edit MTS files (though they don't like seeking) and directly render to a finished format with Kdenlive (mpeg2, mp4, h264, webm, vob etc), my rendered movies have been showing pauses at the points where clips join. Even with ffmpeg and melt built from latest snapshots.

I think there's something happening with Kdenlive's MLT in dealing with the compressed MTS files, because the clips are good with no frozen frames if i join them after converting them to mpeg2 or m2ts.

It's like, Kdenlive says, "Oh, the end of a clip, what do we do now? Oh, the next clip, let's start it.." And with that behaviour, there will be frozen frames at the end of nearly every clip. There is a solution though - and at first I tried transcoding to raw formats (see my page transcoding MTS) but results were not perfect either and it ate up hours of CPU intensive work.

What we need to do is simply turn on "Overwrite mode" in kdenlive and move the next clip along to the left so that it slightly (or greatly) overlaps the end of the clip before it. That way MLT will not get to see the end of the clip, but the next one will be starting already!!



Editing films with Kdenlive

For detailed install instruction see my install Step 2 page. I highly recommend doing long video productions/encodes on a desktop PC with a modern multi-core CPU (3rd gen i5 at least) and plenty of RAM (>8gb), as laptops are just not built for it, although they are getting much faster).

Official Manual here.. http://userbase.kde.org/Kdenlive/Manual




1. Add clips to the Project Tree

Click on the black film icon just above the clip tree to open video files from a folder
The clips may take some time to load and you can only use them once they've all appeared as thumbs, and the last clip appears in the Clip monitor.
The cpu will slow down once they're loaded.

When the files open the profile should be set to what files you are using e.g. HD 1080p 50fps 16/9 -this can be set as default also in Settings >Configure Kdenlive >Project Defaults.
Also set the default kdenlive project folder >Configure Kdenlive >Environment >Default folders tab.

You should set videos of over 1000px to have proxy clips made, so that seeking through them in the Timeline will be much smoother than trying to seek huge, compressed and cpu-intensive movie files. (Configure Kdenlive > Project Defaults)

When using proxy clips you will have to leave the PC to build all the clips when you add them to the Project before you can get on with the video editing.

In the Project Tree you can make folders and drag and drop clips into them, or select a folder and click on the add clips button to add new clips into the folder. This is indispensible for a project made of many clips from all sorts of directories on disk -otherwise you'd have them all mixed up, ordered just by file names.

You can close some of the Kdenlive components so that its less cluttered, under View (you just need Clip tree, Clip monitor and Project monitor, and Effects stack if you add effects and have to adjust them)


Shortcut Keys

You want to make some short-cut keys to help speed up the work: Settings > Configure > shortcuts...

 X  razor tool  C  or right, backward one frame  A  zoom in
 S  select  V  or left, forward one frame   Z  zoom out
 D  delete selected item  L / J  Fast forward / Rewind  Q  fit zoom to project -very useful too
 Shift-X  cut clip (at seek point)  E  or end key, go to clip end  G  insert marker
 M  spacer tool  W  or home key, go to clip start  Alt-N  create folder 
 P  snap to  toggle        



2. Adding clips to the Timeline


Quick

Select the needed clips (or click in the clip tree and CTRL-A) and drag down to the time-line, they will snap to the start as you move them close.

     -if the film looks too long and you need less clips on the time-line, press D as soon as they are dropped there (to remove the whole lot from Timeline) and the duration will be given.
     -also you can press Q to show the whole length of the clips in Timeline, without them going off the end.

at this moment it is good to click the save icon (CTRL-S) and give the project a name.

now click on the Project Monitor tab (the marker will be set to the start of the project) and the project will start playing, pause with Space (or press L to fast forward).


Specific




3. Using sub-clips

Similarly as above, play a clip in the clip monitor and set in/out points with I and O , then click and drag from the Clip Monitor to the Project Tree -the clip segment will be listed under its parent clip (with time of segment start).
Thus the segment of the clip (between in/out points) becomes a sub-clip in the Project Tree (much like a bookmarked part of a clip) ready for use on the Timeline.
    -select the parent clip in the Project Tree to make more sub-clips
    -select a sub-clip, adjust the in/out points in the Clip Monitor and the sub-clip will be updated.

Another way, you can right click on the Monitor and click on Extract Zone, to save the clip segment as a file, and list it in the Project Tree.
This method makes for a good video cutter! Works cutting h264 film. It's just that joining files you have to render them, there's no joiner!


4. Cutting clips on the Timeline

when you hit a part of the clip that's unneeded, pause with Space, find the exact place to make a cut by moving backwards/forwards by one second ( Shift-left or Shift-right ) or by one frame ( C and V or left/right key)

You can also use the mouse scroll button on the Monitor, using normal scroll for moving frame-by-frame in the video from the seek point, or holding Ctrl with the mouse scroll to move a second at a time.

    -Zoom in with A to get to a more accurate place to cut the clip ( Ctrl-mouse scroll button on the Timeline as well)
    -then click on the clip in Timeline to highlight it and use Shift-X to cut at the seek point or press X for the razor/sissor tool and click on the clip at the seek point (not accurate).

But you may need to cut the clip just before/after some audio part, so to do that you need to click at a point under the clip and hit Space to play. Keep adjusing where you click and play from, but keep the mouse at that point. Once you have the exact place to cut, switch to cut tool with X, and click on the clip at the cursor (press A to zoom in if needed.)

    -press S and click on the part to remove to select it.
    -press D to remove it.
    -right click in the empty space and press R to close the gap (or you can leave the gaps and close them later)

! Caution! If you close a gap and you have clips on multiple Video/audio tracks then only one track moves along, disrupting the alignment. Therefore it is better to use the Spacer tool with M in that case and drag the whole proceeding part of the project up.

Instead of cutting, you can just drag the ends of a clip to change the clip's length i.e. make the clip "time out" before it's end or beginning - to do this hover near the clip end and select and drag the green arrow that pops up.

To get this more accurate, you can seek where the clip needs to begin or end, and as you drag the actual beginning or end of the clip, it will snap to the seeking line.

To make this even faster, select the clip and press 1 to move the selected clip's start point up to the seek point, or 2 to move the clip's end point up, which does the same as dragging start/end.

Another way, if you know exactly how much time a clip should duress, you can double click on a clip on Timeline and set start/end points.

However, if you only need to cut a piece out of a clip, it will not help if you reset the start or end of the clip, you will need the razor tool or Shift-X on seek point at the start and end of the piece to remove.

Keep saving the project as you go along -just in case there's a crash!



Note about frozen frames after joining MTS clips

The only way to get around this problem (unless its fixed in a new build of MLT) is to overlap the near end of the clip to the right onto the far end of the previous clip. So to do this, turn on "Overwrite mode" (button at bottom left) and just move up the clip on the right so that it overlaps the end of the clip to its left.

But to do this while editing, just click the point at which normally you'd cut the clip (to remove the end) and then overlap the clip on the right (move it to the left) up to the seek line.

If you've already made edits, cutting clips, and you want to overlap clips, you'll need to use the move tool to move all the clips to the right, to make some space.
     -click on the first clip and press "end" key to set the seek at the clip end.
     -Try to move the clip out to the right by hovering the end and dragging on the green arrow.
     -If it moves out (which means you made a cut there) then move it a little way, and then hit S and drag the clip on the right to overlap, up to the seek point (which will be where you wanted the clip to be cut).
     -If it doesn't move out (means there's no cut made) then you'll just have to overlap the clip on its right a little on it.
     -Do that for all clips on the project time-line before rendering.

Results?? No more frozen frames at all. But, there may be some audio artifact found at joins! A very short crackle at the start of new clips. :(


Other notes




5. Adding Sub-titles

to add sub-titles you need to make a Title clip, with transparent back-ground. Move the clip which the Title clip will coincide with down onto video track 2, drag the Title clip from the Project Tree on to Track 1 and resize it to the right duration.



6. EFFECTS

there is a huge amount of effects available.
if adjusting brightness (RMB on clip in the timeline >Add Effect >Colour Correction)
stretch the Effects Stack so you can adjust the value manually


To apply an effect to multiple clips,



7. Rendering / Encoding

when ready, click on the Render icon on tool bar or press R !

You can also render a selection of the project by using the in/out zone markers -set these by pressing I for the in marker and O for the out, then in render dialogue check "selected zone".

Another way is to set guides and that way you can chop up the finished movie into segments and render each segment at a time.
set a guide at the end of a clip: press "end" key, use shortcut G for Add marker/guide quickly.

In the render dialogue select the area on the project to be encoded Full.. Selected Zone.. Guide Zone. then render or generate a script to render it later.

You can also create your project, set the render options and make a script for it so that it can be started later - this will give you maximum system resources with which to play and seek the clips of another project.

When ready to make the next project from other files, click on New. Trying to remove the clips from the time-line is a bit of a pain, and unnecessary. You can however, clear the timeline if you need to, with just Ctrl-A and press D (with Timeline active)



Rendering projects to different movie formats

I often render a "raw-ish" copy of my film to mpeg2 @ 12000 K bitrate, which is an easier format to deal with later.

Then to h264 @ 2000 K, resized to 1024p, for viewing on mobile devices, which gives OK video quality. Without rescaling, video from 1080 profile will easily merit HD display on a video share website.

I'll make a lower quality mp4 render for some cases where laptop performance is low or where a DVD player can handle mp4 movies from flash stick.

For making DVD's, I'll render the same project to DV/DVD (must change project profile to 25 fps) which renders @ 8000 K bitrate and the result is 720p. This can be added to a DVD project in bombono with ease.

EXPERIMENTAL: TO FORCE WIDESCREEN PLAY OF 16:9 VIDEO ON A 4:3 DISPLAY, SELECT DVD 4:3 WITH THE 16:9 SOURCE. YOU GET A 16:9 PICTURE ON A 4:3 SCREEN -BUT NO GOOD FOR A WIDESCREEN TV.

Add your best encoding profiles to favorites.

Rendering takes time! The faster your processor the better. I would leave the render queue going all night on my Intel dual core.

If you are confident with your rendered film then you can dispose of the MTS files, unless you want to keep them for a while.


Notes






Avidemux

If cutting up mp4/m4v/h264 you are limited to making cuts only on KEYFRAMES! If you cut on any frame between it will cause smearing of where the frames get joined in the resulting movie - ie, blocky or jittery picture tor a split second.

It's much easier to cut up an mpeg2 film, while using Same for video and audio, but +40 ms to correct the audio lag. Still best to use key frames for cuts as mpeg2 is also compressed.

More on Avidemux on the next page, Dvd-authoring.


Bombono

add the vob files made with the Kdenlive DVD render to bombono and create ("render only") the DVD ISO (which you can move to a folder).
I used to use DVD Styler, but it remuxes the films (whether 720p mpeg2 or vob files) and that takes a long time.

Then burn the DVD iso file, from command line with:
 

(use /dev/dvd1 or /dev/dvd2 for an external DVD writer)


Handbrake

convert 1920p mpeg2 with h.264 codec 2pass @ 2500 kbps for Youtube.
Convert to mp4 with mpeg4 codec @ constant quality=8 and resize to 820p for showing on TV with a thumb-drive.

Also just "decomb" the video (Picture settings >Filter), don't force deinterlace, as not all frames are interlaced, so combing gets those that are and the result is a nice picture.