UPDATED MAY 2013
Taking still images from MTS
Converting MTS movie files into films
Editing films with Kdenlive
Rendering projects to different movie formats
I use Kdenlive as my dedicated video editor and encoder for all my projects. (Install notes on Xfce step2 page)
I'm currently shooting films with a Panasonic V500 which has really nice quality and colour, and produces .MTS files. You can Google what MTS is, it's something like h264 mp4 AVC compressed video, HD being 1920 x 1080 pixels, interlaced 50fps (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 2nd/3rd generation i5, you will experience staggered playback or pauses while trying to stop and play in Kdenlive (as my current Intel core duo gives me).
I locate my STREAM dir on the camera's SD card (inserted) and copy all the MTS files to an external disk. Then I work by last modified time-date (with a quick play to check) to move files into different directories according to place or day or activity.
Taking still images from MTS
I use Gnome-mplayer to get quality stills from my film -it's also possible to take shots of the film on the camera itself, though I haven't taken to this method.
Player tab: video output = gl or x11 (I don't notice the difference)
Mplayer tab: check Deinterlace + Drop frames
Interface tab: check Only allow one instance + when opening.. replace existing file + When opening file, bring main window to front + Remember Window Location and Size (but will go off screen when opening a large MTS file) + Pause playback on mouse click.
In wheezy gnome-mplayer doesn't resize with each new file loaded. Also setting the half-size video play makes snapshots get blacked out on the lower half. So on the first large HD file played, ALT-F8 (Xfce) and resize the window, or check Half Size (1:2) under View.
1. browse to the MTS files and click one to play the mts file with Gnome MPlayer
the first pause might need a mouse click to do it
2. space to pause/play CTRL-T [I change that to CTRL-Z] to capture still frame (and press space again to un-pause and get the snapshot saved!)
open the next file in the dir list
seeking with the left/right keys move about 10sec on/back so might end the film if its short
*bad clips can be deleted at this stage!
3. pics saved in ~/Documents (or working dir?) as 6MB .png files,
move them to "my pictures/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 using thunar (as it's fast) -they must have .png extension (do not rename as .jpg)
to select a long list of files: press 'end' to select the very last file, then SHIFT-click the top one of all those required.
5. Digikam: select all images in an album (click on album header) and add to a Queue (can keep adding images to the queue before running the conversion)
select convert to JPEG tool and set to 100% quality -produces jpegs of 1-2 MB.
to remove the PNG files afterward, use the filter on mime type PNG, select all and delete (by-pass waste bin -there's a tool bar button for it too)
Alternative: see my Image Processing page for how to convert/resize images with Thunar custom actions!
6. carry out tagging, minor enhancing, deleting bad shots, then send to a Queue
select the Resize tool, set at 1200p to 1400p, 90-95% quality and send to a new album
this should create jpeg files of about 250-300kb (can experiment with the quality % to get a target file size)
Again, I have thunar custom actions to take care of resizing images with two clicks! See the link above.
7. the full-size pics in "NEW/abc" can be backed up on external storage, the 1200p photos are good for showing or sharing online.
this is really just a way to save disk space! When you have 50,000 plus pics it could be a good idea to keep smaller versions on the PC disk and originals on back-up. I use this method (only resizing) with my Nikon D80 photos too, not just the snapshots from MTS files.
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, vob etc), my rendered movies have been showing pauses at the points where clips join. Even with ffmpeg and melt built from latest snapshots.
But has it been my clips that are at fault, with frozen end/start frames? -i think there's something happening while ffmpeg de-compresses the MTS files, because the clips are good with no frozen frames after conversion to mpeg2 or m2ts.
update: I don't get this affect on my videos now, which is either due to getting a new camera or a better kdenlive version.
There is a simple solution to this (see below) but here's all the experiments that I did...
I've experimented with transcoding mts movie files to DNxHD with Kdenlive, and used the transcoded .mov files for editing and rendering to mpeg2, mp4, vob etc. (and you need to make a shortcut key for Transcode or find it on the File menu)
I tried a short project and got some disappointing results, along with an extra 10Gb of mkv files and suffocating RAM. The video quality was not like the AVCHD quality, and had some glitches.
Then I Remuxed the mts movie files to MKV, and MPEG-2 PS/VOB but I had all sorts of jumpy results with one and slight stops on every clip join as well as some slow motion with the other.
I re-encoded the MTS files before committing them to the project, using ffmpeg to do this with a script:
for file in *.MTS; do ffmpeg -i $file -vcodec mpeg2video -b 85000k -threads 2 $file.mpg;done
where mpeg2video is the codec, the k value is bits/sec (i.e. 85Mbps here) and the -threads flag tells ffmpeg to encode using more cpu cores (so it depends on your cpu whether it's dual core, quad core etc) but leaving it out will set to automatic.
I made the script in home dir, named "convert.sh", chmod +x, and made a Thunar custom action with the name "Convert MTS", command /home/username/convert.sh %F and Appearance conditions set to *.MTS;*.mts and check video files. So I just click on an MTS file and hit Convert MTS and all files in the dir are converted. Can easily make a custom action for any particular video format to encode to.
the resulting file is quite good quality (and you can go over 100Mbps but threshhold seems to be around 65-80M) and reasonable x4 file size, but it's not lossless, and it's another compressed video format that a video edito has to decompress and recompress, losing quality.
... but the rendered result in Kdenlive (say, to 18Mb mpeg2) is blocky, poor Q, when looked at close-up. So still not an acceptable solution!
lossless mpeg2 using intra-coded frames (makes files 13-20x orig. file size), use
for file in *.MTS; do ffmpeg -i $file -vcodec mpeg2video -qscale 1 -qmin 1 -intra -an $file.m2v;done
rendering result: smooth joins, high quality
DNxHD (makes files 17x orig. file size), use
for file in *.MTS; do ffmpeg -i $file -vcodec dnxhd -b 120M -an $file.mov;done
(got from superuser answers http://superuser.com/...)
M2TS (mpeg2 transport stream) -which the bundled Panasonic software always converted MTS into when capturing from the camera.
The files produced are just over 3x the orig. file size, and the best thing is, Kdenlive copes really well with them AND the rendered movie is clean and high Q.
M2ts is 1440-1080 but the pixels are not square like AVCHD, but are 1.33 ratio, so the picture remains the same aspect ratio as the MTS 1920-1080.
When rendering the m2ts into mpeg2, it will come back to 1920-1080, (use the HD 1080p 50fps profile in Kdenlive to maintain 50fps).
for file in *.MTS; do ffmpeg -i $file -acodec mp2 -f mpegts -vcodec mpeg2video -s 1440x1080 -vb 45000k -g 12 -trellis 1 $file.m2ts;done
change the k value to suite your quality needs. 85Mb is better.
FROM M2TS, ENCODE TO H264 OR WEBM CODEC FOR *FAIR* RESULTS -ENCODING TO MPEG2 GIVES BAD QUALITY LOSS !
But encoding the 1440x1080 M2ts to HDV 1440 50i gives probably the best result and fastest encoding.
Attempt to Remux to MKV using Mkvmerge!
Mkvmerge GUI is an app for muxing video into a matroska container -worth looking at, from here http://www.bunkus.org/videotools/...
the guide, here http://www.bunkus.org/... and mkvmerge man page here http://linux.die.net/man/1/mkvmerge
Here's a batch script to remux all MTS files in a directory into a matroska container (.mkv). I put this in a Thunar custom action and just right-click in the directory.#!/bin/bash
for file in *.MTS; do mkvmerge $file -o $file.mkv;done
once the AVCHD files are remuxed into a mkv container it seems that ffmpeg is able to read/decompress the files without making frozen frames at start/end of the clips in a Kdenlive project. So the results are
The Simple Solution!
Thanks to Norm2 reporting this on the Mantis Bug Tracker bug report. All we need to do is to overlap every clip at the end i.e. move up each next clip to cover the end of the previous clip by 3-4 frames. To do this make sure the "Overwrite" mode is selected with the button at bottom below the tracks.
Editing films with Kdenlive
There's a graphic 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)
You want to make some short-cut keys to help speed up the work: Settings >Configure shortcuts
2. Adding clips to the Timeline
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.
-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).
Select a clip in the Project Tree and play it in the Clip Monitor (check it under View menu)
Play/pause with Space , or by clicking on the Monitor, and then set in and out points with buttons or I and O
Click on the Clip Monitor and drag it down to the Timeline and the selected part of the clip (within the in/out points) will be added to the Timeline, wherever you like.
3. Using sub-clips
Similarly as above, play a clip in the clip monitor and set in/out points, 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.
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 or V or left/right key)
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).
Press V to move on repeatedly or hold down (if the film moves) or press S and click on timeline to find the next cut place, zoom out with Z if necessary
Use Shift-X again or the scissors at the end of the part to remove.
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.
However, if you need only 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!
I found once with some movie files that I had to check the start and end of the clips for "frozen" or glitched (when the motion jump backwards) frames and chop them off (which was up to ten frames, or sometimes less). So I made use of V to progress the frames at the clip start, then when the frames had motion I press 1 to adjust the start of the clip, then E to go to the clip end, then V, 1, E again, etc. (closing up the spaces afterwards).
The spacer tool M is used to move all the clips up along the track and make some space to insert a clip.
You can select multiple clips in the time-line by right-click and Group clips (or CTRL-G), then CTRL-click on clips.
Release CTRL to move them all together.
But if you want to move them to another part on the time line you'll have to move them onto the second row and then along.
if on occasion Kdenlive deals badly with a certain clip and it appears frozen when you play it in the time-line, it's most likely that the camera did something to it, a write error.
Say you've been working on a few clips on the Timeline and you'd like to use that edit in another Project... you can't drag the in/out zone to the Project Tree, unfortunately, so you have to save that and import the saved project as a clip to the Project Tree in the new Project.
But if you have been using proxy clips in the project you want to import, very strangely the new project will put the proxy files into the rendered film! So you need to turn off proxy clips (select all and right click > Proxy Clip) and save the project before importing it to another project :(
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.
there is a huge amount of effects available -so use any as you desire or have time to try out -on any selected clip(s).
if adjusting brightness (RMB on clip in the timeline >Add Effect >Colour Correction)
stretch the Effects Stack so you can adjust the value manually
-increase brightness: you need to increase the contrast also (RMB on clip in the timeline >Add Effect >Colour) and perhaps saturation a very little
-increase brightness from 500 to 700 and contrast from 250 to 350 for example and adjust further until the right colour is obtained
-if reducing brightness there's no need to adjust contrast
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 the right option.
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.
Note that the guide will stick to its time placement, so if you close up gaps or edit stuff before it on the timeline, the guide will need moving again (it will snap to a clip end).
In the render dialogue select the area on the project to be encoded Full.. Selected Zone.. Guide Zone.
render or generate script
You can also create your project, set the render options and make a script for it so that it can be started later (that's especially good if your processor is not quite i5 or i7 speed and needs to be left alone!) 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 "backup" copy of my film to mpeg2 @ 12000 K bitrate, which is an easier format to deal with later.
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 less time it will take. I often 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.
1. Avidemux: take care using Avidemux to cut and join mpeg2, only make cuts at KEYFRAMES! If you don't it will cause smearing of frames at the joins in the resulting movie.
You can quite easily use Avidemux to cut an mpeg2 film shorter, using Same for video and audio, but +40 ms to correct the audio lag. But it doesn't work well with h264 encoded video!
SEE NEXT PAGE!!
2. Bombono: add the vob files made with the DVD render to bombono and create the DVD files (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 file set with k3b Video DVD project (put all the files in the VIDEO folder).
Or create the iso image in bombono, then burn image with k3b -for a more stable burn. Or burn from command line with:
growisofs -dvd-compat -Z /dev/dvd=file.iso
3. Handbrake: convert the 1920p mpeg2 with h.264 codec 2pass @ 2000 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.