Basic video processing in Linux
As I became responsible for recording and processing videos from regular CZJUG meetings, I had to learn how to perform basic video processing in Linux - years ago I did this on Windows in Adobe Premiere, so I have been looking fro a similarly comfortable and flexible solution. I guess you are trying to solve about the same problem, so lets review my solution based on ffmpeg and kdenlive.
To record the meetings I use Panasonic VDR-D250 camcorder (using DVD-RAM format) and a voice recorder Philips LFH 0662 (to MP3 format using a lapel microphone). So to process the video it is necessary to do about this:
- prepare video stored on a DVD-RAM (ffmpeg)
- prepare video recorded to MP3 (Audacity)
- edit and export the video (kdenlive)
Lets see discuss these steps in brief - purpose of this article definitely is not a thorough description of these steps, rather a brief outline and a few warnings about possible problems.
Prepare video stored on a DVD-RAM
Theoretically you could take the video stored on a DVD-RAM and load it directly into the video editor, and it is possible to do that (just open the DVD_RTAV/VR_MOVIE.VRO file), but as I have found this results into problems with audio sync in the resulting video.
So you have to recode the video into a suitable format - I do have very good experiences with conversion into a DV format using ffmpeg:
$ ffmpeg -deinterlace -i /mnt/cdrom/DVD_RTAV/VR_MOVIE.VRO \
-target dv ~/working.dv
But I have to warn you - the resulting file is about 15x bigger (e.g. 11,5GB instead of 800MB), but the editor is much faster than when using the original DVD-RAM format. Of course, the conversion takes some time too - on my home workstation with an AMD Athlon64 X2 4400+ CPU (which is rather a below-average workstation nowadays) processing of 1 hour of a video takes about 20 minutes.
Update: If you need a video with a size different from the original one (e.g. I have a standard PAL video with 768x576 at the input and usually I need to get something like 600x450), then you can rescale the video at this phase. Sure, you can do that later when "rendering" the video from a video editor, but according to my experience the results are noticeably worse (squares at edges, etc.). All you have to do is a slight modification to the ffmpeg command, e.g. like this:
$ ffmpeg -i /mnt/cdrom/DVD_RTAV/VR_MOVIE.VRO -deinterlace \
-s 600x450 -sws_flags bicubic -vcodec libxvid \
-acodec libmp3lame -vb 500000 -ab 128000 -ar 44100 \
~/working.avi
This gives you a video with 600x450 resolution, video encoded using an Xvid codec and a 500kbps bitrate, audio encoded using MP3 with 44,1kHz sampling frequency and 128kbps bitrate.
Prepare audio recorded to MP3
Just as in case of the video, you could load the MP3 file recorded using the voice recorder directly into the video editor, but sometimes you need to preprocess the audio.
For example I have found out that although both the camcorder and voice recorder are digital, there is a slight difference in speeds - the audio from the voice recorder is a little bit slower that the video - after 1 hour the difference is about 7 seconds (and that is way too much). So you have to "slow down" the audio a little bit, which is not supported in the video editor I use (kdenlive, see next section). Or at least I don't know how to do that.
That is why I am using Audacity audio editor to slow down the audio:
- I do change the sample rate so that the audio is a little bit slower (I have found uout I have to set the sample rate to 44191 instead of the usual value 44100, which gives me a 0.2% slow down, i.e. 7 seconds per 1 hour).


- Then I resample the audio back to the usual 44100 (this does not change the perceived speed of the audio).


- Export the audio into an uncompressed WAV file (again - it is bigger than a compressed file, but it is much faster to work with - see the next section).
So the result is an uncompressed audio in a WAV format.
Notice that the required slow-down may be different for you - the value 44191 is simply the best in my particular case (combination of a camera / voice recorder), so you have to determine the value yourself. The easiest way to do that is to align the start of the audio and audio tracks in the video editor, check the difference at the end, and compute the required slow-down (and set the frequency that achieves that).
Editing and exporting the video
The last thing you have to do is cut the video - all I have to do is to cut the start / end to get just the talk, add the audio track preprocessed in the previous section, align it to the video and export the result into a suitable format (e.g. Xvid4).
I using kdenlive to do all this, as I find it very easy to use (see the screenshot below), it has all the features I need but it is not too complicated nor oversimplified, and it is very stable.
To export the video I slightly modified one of the predefined profiles (Xvid4 800k 2 pass) - I added this piece into it
ab=96k ar=22050 ac=1
that says the resulting audio is mono (ac=1), the sampling rate should be 22050Hz and bitrate 96kbps, which is suitable for the talks.
Summary
To summarize all this, I had to solve these two problems:
- problem: incorrect synchronization of audio and video in case of using the DVD-RAM video directly, solution: conversion into DV format using ffmpeg (and application of deinterlace filter)
- problem: incorrect synchronization of audio recorded using a voice recorder and video from a camcorder (a slightly different speed), solution: modification (slow-down) of the audio using the Audacity audio editor
Maybe this article helps you at least a little bit ;-)





