Posts Tagged ‘FFmpeg’

Open Movie Editor How-To: Fade to Black Transition

January 31, 2008 1 comment

After my previous overview of Open Movie Editor (OME), I decided to create a small How-To regarding an easily obtainable piece of functionality that’s not yet standard within OME.

Open Movie Editor natively contains only one transition between clips – a simple cross fade. However, one of the most used transitions in video editing is a fade to black. By adding a black still image, between two clips on a single video track in OME, it is possible to generate exactly what you need.

Here’s how by following the steps below:

1. Open your favourite image editor, in this example we’ve used the GIMP.
2. Create a new image with a solid black background, at the same size as your video clips. We’ve used PAL 720×576.
3. Save the image as a PNG, although JPG will also work.
4. Switch to Open Movie Editor and navigate to your footage in the Media Browser window. We’ve previously downloaded two QuickTime clips from stock footage supplier BBC Motion Gallery, to use in this example.
5. Add the first clip to video track one.
6. Add the black still image to the same video track.
7. Add the second video clip to the same video track.
8. Now, overlap the beginning of the black still image with the end of the first clip. A blue area with a red cross through it should appear – this is the length of time that the fade will occur.
9. Adjust the length of the black still image to suit the speed of the fade to black required.
10. Now, drag the beginning of the second video clip over the end of the still image, so that another blue box and red cross appears.
11. Move the timeline marker before the first blue box and test your fade out to and in from black.

Easy! Move the clips, and adjust the length of the black still image until you are happy with the fade.

To make is even easier, we’ve created a screen cast for you to watch, complete with a couple of extra fades created in OME. Don’t adjust your volume, there is no sound.

Get Flash Player 9 to see this movie.

var so = new SWFObject(‘’,’player’,’640′,’500′,’9′);
so.addVariable(“screencolor”, “0×000000″);
so.addVariable(“autostart”, “false”);
so.addVariable(“shownavigation”, “false”);
so.addVariable(“overstretch”, “fit”);

This screen cast was created with RecordMyDesktop, edited with Open Movie Editor, and transcoded into an x264 file, using a custom Perl script to control FFmpeg.

Open Movie Editor – Surprisingly Robust

January 30, 2008 1 comment

Despite some commentators deploring the state of Linux video editing tools, I continue to believe that somewhere out there is a non-linear editing program that is feature rich, intuitive and stable for the Linux platform. Maybe I’m deluded, but I would settle for a nice tool in its current state, that has an active community, a development road map and doesn’t crash all the time!

Yesterday, I decided to give Open Movie Editor a chance. I thought this project was largely dead, but a new release was made on January 2nd 2008, so it looks to be still very much alive. I was also somewhat put off by the screenshots on the website. The GUI looks poor and clunky. After installation I am pleased to say that this isn’t entirely the case.

Unfortunately, the packages in the Ubuntu repository are only for older versions. Installing Open Movie Editor (OME) from source was reasonably straight forward, but there are some tips and tricks worth following. To maximise the number of video formats that OME can decode, be sure to have a reasonably new version of FFmpeg installed. For rendering (encoding) output, OME uses Libquicktime. I already had FFmpeg installed, with a lot of extra libraries to cater for x264 and FAAC encoding, amongst others. I also decided to install Libquicktime from source, rather than the Ubuntu package, as configuring with –enable-shared will pickup additional libraries, like libmp3lame, libx264 and libfaac if they’re present.

Configuring OME also meant adding some new libraries to the default Ubuntu set, these included Gmerlin, libsndfile and the Alsa dev libraries. I sourced all of these from Ubuntu’s repositories and installed through Synaptic. Building OME went smoothly, although it should be noted that at the end of the process, there will not be a nice icon in the application menus. OME needs to be launched from the command line, which is actually quite handy for viewing error messages.

Once up and running, I was surprised by the GUI. It’s not nearly as bad as I feared from the screenshots, although there is still plenty of room for improvement. There are also two other skins to choose from, but unfortunately these and any other layout changes made are not remembered by OME between sessions, meaning everything needs to be setup again at startup.

My aim with OME was to perform some simple editing tasks and here’s what I found:

  • Adding clips to a project is very simple, just navigate to the folder on your local hard drive where the clip is stored, then drag it to the timline. There’s no time consuming re-factoring of clips when adding them to a new project.
  • OME supports a wide range of formats. I threw MPEG2 (m2t and vob), MOV (MJPEG and x264) and AVI (xVid and x264) files at it. They were all handled correctly. Although, it should be noted that the range of formats is dictated by your FFmpeg setup.
  • Adding new video and audio tracks is easy and straightforward
  • Splitting clips is possible using mouse clicks, but could be better with keystrokes for more accuracy.  Splitting should be performed at the exact current frame of the marker position.
  • Merging two clips together on the timeline creates a nice video crossfade, but this is the only transition available by default. To create a fade out to black, and in for the next clip, a black image must be added to the timeline between existing clips. The two existing clips then crossfade to the black image. The length of the fade is determined by the amount of clip overlap and the length of the black “image”. A little clunky, but it works well.
  • If a video clip has original audio, this can either be entirely muted, or the volume adjusted using the “Automator” tool.
  • If you just want to edit the audio of an existing video, drag and drop the file to an audio track on the timeline, rather than a video track.
  • Various effects are supported by the Frei0r video plugins. I have installed them, but not really used them, although there appears to be a wide range available.
  • There is currently no video preview available, unless the clip is already on the timeline. This means that viewing clips not already on the timeline, needs to be done outside of OME. This is a productivity loss.
  • Arbitrary clip padding, cropping and rotation is not available.
  • HD support currently not available.
  • It is not possible to move along the timeline one frame at a time with keystrokes. This can only be achieved by dragging the timeline marker with a mouse, which is not very accurate.
  • Rendering a project is straightforward with many options to choose from. This is a major strength of OME. Render options, as mentioned before, are handled through Libquicktime and so far I have no complaints.

However, the one biggest positive of OME for me is stability. I have had only two segfault crashes so far, and this was when zooming in and
out, or moving left/right on the timeline very quickly. Other Linux
NLEs I have tried – say KDEnlive or PiTiVi – crash very regularly. It
is a real plus that OME is so stable.

I’ve also had some interesting conversations with OME’s lead (and currently only) developer Richard Spindler. He’s been very helpful and patient with my inquiries. When asked about a future roadmap for OME, Richard said that it revolved around the following two points:

  • Improve the User-Interface and Editing-Feature-Set to cover most of the Basic Use Cases that an Amateur/Indie Movie Artist and Home Video Producer needs. This includes basic Compositing. 
  • Improve the Technical Backends, to RELIABLE deal with “legacy” Video Technology that is available to the general public. Compatibility to Camcorders, Video-Files and Formats, DVD-Players, etc. There remains a lot of stuff to do in that Field, for Open Movie Editor, as well as for the Linux and the Open Source/Free Software Community as a whole.

When asked if there was a desire for OME to become a Professional level video editing tool, or always aim at the Amateur/Indie/Home User, Richard felt that, “The Lines between Professional/Amateur are blurring, you can do quite amazing stuff with “cheap” HDV Camcorders today.

With Open Movie Editor I will try to do both, provide a level of quality in Image Processing and Format support that is good enough for the “Professional”, while keeping the Interface User friendly enough for Newbie users. Of course, I am not yet finished with those requirements.

As for the Interface: Ideally, the default will be simple and plain, but the more complex tools would live in Plugins and Extensions. So the Goal is definitly having both: iMovie and Final Cut Pro in one  Application. I think it is possible, the question is only how long it will take.”

I was surprised by the stability of Open Movie Editor. The interface is easy enough to use, although still with plenty of room for improvement. The addition of some extra productivity features and shortcuts will really enhance the power of Open Movie Editor. Give it a try, you might just be surprised.

Optimised x264 Encoding with FFmpeg

January 28, 2008 Leave a comment

A request on the Ubuntu forums asked for some assistance creating x264 files from footage originating on DVD. The following FFmpeg command represents input from a couple of users regarding what might be the best options:

ffmpeg -y -i input_file -an -v 1 -threads auto -vcodec libx264 -deinterlace -b 5000k -bt 175k -flags +loop -coder ac -refs 1 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me epzs -subq 1 -me_range 21 -chroma 1 -slice 2 -bf 3 -b_strategy 1 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 5000k -bufsize 2M -cmp 1 -s 720x480 -f mp4 -pass 1 /dev/null

ffmpeg -y -i input_file -v 1 -threads auto -vcodec libx264 -deinterlace -b 5000k -bt 175k -flags +loop -coder ac -refs 5 -loop 1 -deblockalpha 0 -deblockbeta 0 -parti4x4 1 -partp8x8 1 -me full -subq 6 -me_range 21 -chroma 1 -slice 2 -bf 3 -b_strategy 1 -level 30 -g 300 -keyint_min 30 -sc_threshold 40 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.7 -qmax 51 -qdiff 4 -i_qfactor 0.71428572 -maxrate 5000k -bufsize 2M -cmp 1 -s 720x480 -acodec libfaac -ab 256k -ar 48000 -ac 2 -f mp4 -pass 2 new_file.mp4

This command, as an overview does the following:

  • Uses libx264 as the output video codec
  • Uses libfaac as the output audio codec
  • Deinterlaces the original DVD sourced footage
  • Allows FFmpeg to choose the number of threads to use for multi-core systems
  • Sets the output video bitrate at 5000kbps (or roughly 5Mbps)
  • Sets the output audio bitrate at 256kbps
  • Deblocks the output footage
  • Uses CABAC encoding
  • Uses .mp4 as the output file container
  • Uses B-Frames
  • Uses 2 pass encoding – directing the first output to /dev/null and the second pass to a new file

There are of course many other options included in this command. Further useful reading can be found on the FFmpeg documentation page:

Also, this Mencoder specific page has some useful information regarding encoding using x264:

Categories: FFmpeg, Video Tags: , , , ,

FFmpeg Codec Comparison Test – xVid vs x264

January 23, 2008 Leave a comment

Recently I took the time to run a quick comparison test using FFmpeg for producing content with the x264 and xVid codecs. x264 produces H.264 content, while xVid encodes in MPEG4. I was a little surprised with the results.

The input file was sourced from BBC Motion Gallery.
It was an MPEG2 Program Stream with I-Frames, encoded at approximately
50Mbps. It also contained a single MP2 audio track at approximately
356kbps. To see the clip on BBC Motion Gallery, click here.
The clip was chosen because it is only 2 seconds long, so I could
transcode it quickly, and there is also lots of movement, so I expected

The output file container is QuickTime MOV, the video bitrate
around 2Mbps, the audio codec aac (through libfaac) at 128kbps. I
performed a 1 pass and 2 pass encode with x264 and xVid. The output
file was to be 720×404 in size, this is 16:9 aspect ratio. All files
were played back on a Windows XP machine using QuickTime Player 7.1.3.
Some cropping of the original MPEG2 was required to remove VITC at the
top and some black padding left and right. An example FFmpeg command
line I used is outlined below. As you can see, there are very few
optimisations other than the base settings.

FFMPEG command for the second pass x264 encode:

ffmpeg -i 2573-9.mpg -vcodec libx264 -f mov -b 2000k -acodec
libfaac -ab 128k -s 736×442 -croptop 34 -cropbottom 4 -cropleft 8
-cropright 8 -deinterlace -pass 2

The final output file sizes are as follows:

  • x264 1 pass: 599.558 kilobytes
  • x264 2 pass: 553.767 kilobytes
  • xVid 1 pass: 577.232 kilobytes
  • xVid 2 pass: 559.947 kilobytes

So, while xVid one pass produced smaller file sizes than x264 one
pass, the x264 2 pass file is smaller than the xVid 2 pass file. Due to
the short duration of the input file, no comparison of encoder speed
could really be made. However, anecdotally from other ad hoc encoding
jobs, xVid does seem to be quicker.

Now, to the real proof of the pudding, what was the quality like. Have a look at the following image file, click the thumbnail for a larger version:

This is where I was surprised. The x264 files are on the left. 1
pass is bottom left. 2 pass is top left. The xVid files are on the
right. 1 pass bottom right. 2 pass top right. Clearly, the 1 pass xVid
file is superior to the 1 pass x264 file. I also believe that the 2
pass xVid file is slightly better quality then the 2 pass x264 file.
Areas for close inspection (we’re looking at the two top files here):

  • Bottom right corner. There is more blocking and artifacts on the x264 file.
  • Top right wing tip. The xVid file has better definition here.
  • The underside of the wings and tail. Again the xVid file has better definition.
  • The background fire. I think the xVid file has less artifacts and better definition in general.
  • As there aren’t a lot of colours in the example video, it’s hard to
    say which codec handles colour better, but there is obviously more
    depth in each of the 2 pass samples, compared to the 1 pass output.

I was surprised that to my eye the xVid
content appeared to be superior to the x264 output. Perhaps with a more
complext FFmpeg command and options this would have changed.

After a couple of tips on the FFmpeg user mailing list, I re-ran this test with some command optimisations. Specifically:

  • De-blocking loop filter enabled with -flags +loop
  • CABAC enabled with -coder ac

New FFMPEG command example for x264, second pass is:

ffmpeg -i 2573-9.mpg -vcodec libx264 -flags +loop -coder ac -f
mov -b 2000k -acodec libfaac -ab 128k -s 736×442 -croptop 34
-cropbottom 4 -cropleft 8 -cropright 8 -deinterlace -pass 2

New screen grab is here, again click for a larger version:

x264 still on the left, xVid on the right. Old 2 pass files
bottom. New 2 pass files, with – coder ac and – flags +loop added to
the FFmpeg command, on top.

The new x264 file is slightly larger than the old one (50 bytes increase). The xVid file is the same size.

From the new screen grab, it can be seen that the x264 output is
now clearly superior. In this case it can be really proved that
optimising the FFmpeg command can truly make a difference.

How-To: Find and Extract Video File Details

January 22, 2008 Leave a comment

Using FFMpeg it is relatively simple to query an existing video file to find details such as video codec, audio codec, bitrates, duration and dimensions.

Use the following FFmpeg command in a terminal window:

ffmpeg -i input_file.extension

FFmpeg will just open your input file without doing anything to it. Something like this will be returned in the terminal window:

phillc@phillc-laptop:~$ ffmpeg -i
FFmpeg version SVN-r11213, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: –enable-gpl –enable-pp –enable-libvorbis
–enable-libtheora –enable-liba52 –enable-libdc1394 –enable-libgsm
–enable-libmp3lame –enable-libfaad –enable-libfaac –enable-libxvid
–enable-pthreads –enable-libx264
libavutil version: 49.6.0
libavcodec version: 51.49.0
libavformat version: 52.2.0
built on Dec 13 2007 20:20:36, gcc: 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ’’:
Duration: 00:00:51.7, start: 0.000000, bitrate: 862 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 480×360 [PAR 0:1 DAR 0:1], 25.00 tb(r)
Stream #0.1(eng): Audio: mpeg4aac, 44100 Hz, stereo
Must supply at least one output file

All very interesting, but what if you want to do something more with this information, like write it to a file for use in another program, or just want a more convenient way of viewing the details without having to remember an FFmpeg command? Write a small script to do the work for you. Here’s one I created earlier in Perl…….


# Read command line input file

$input_file = shift;

# Read details of input file and display to user

$ffmpeg_input_details="ffmpeg -i ${input_file} 2>input_file.txt";



@inputfile = <INPUTFILE>;

@input_file_video = grep (/Video:/i, @inputfile);

@input_file_audio = grep (/Audio:/i, @inputfile);
@input_file_duration = grep (/Duration:/i, @inputfile); 
print "Details for the file $input_file.\n";

print "It contains the following video data:\n"; 

print "@input_file_video\n";

print "It contains the following audio data:\n"; 

print "@input_file_audio\n";
print "It has a duration and bitrate of:\n"; 

print "@input_file_duration\n";

To use this script simply type the following at your command prompt:

perl input_file.extension

Good luck extending this small script for your own uses.

How-To: Install FFMPEG on Ubuntu Gutsy

January 20, 2008 Leave a comment

I wanted to install FFmpeg on my Ubuntu Gutsy
Gibbon (7.10) desktop machine. This is so I can encode and transcode
video files to various formats locally, and also render projects from
the non-linear editor (NLE) PiTiVi.

This post will mainly cover just the commands I used to install FFmpeg on Gutsy, with very little commentary regarding why or how
things work. If you want a more in-depth look at installing FFmpeg, you
can read about the installation
of FFmpeg on my Debian Etch server earlier today – which ultimately
moves me closer to on-the-fly video transcoding of user submitted
content on Kapital Moto TV

Installing FFmpeg on Ubuntu Gutsy:

sudo apt-get build-dep ffmpeg

sudo apt-get install liblame-dev libfaad2-dev libfaac-dev
libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev libdts-dev
checkinstall build-essential subversion

svn checkout svn:// ffmpeg

cd ffmpeg

make distclean (I used this because I already had an older SVN snapshot of FFMPEG downloaded, configured and made from last night)

./configure –enable-gpl –enable-pp
–enable-libvorbis –enable-libtheora –enable-liba52
–enable-libdc1394 –enable-libgsm –enable-libmp3lame –enable-libfaad
–enable-libfaac –enable-libxvid –enable-pthreads –enable-libx264 –enable-shared


sudo checkinstall

Some things you might want to do when prompted to by checkinstall:

  • Select 0 change maintainer name
  • Select 3 to set version name. I used svn11213-ubuntu-gutsy-20071213

And that’s it FFmpeg installed on Ubuntu Gutsy.

Other links:

Categories: FFmpeg, How-To, Video Tags: , , ,

How-To: Install FFmpeg on Debian Etch

January 20, 2008 8 comments

NB: This How-To is now almost totally worthless as it is so out of date. Please click here for an updated version explaining how to install FFmpeg on Debian Squeeze.

I have to say, that the video manipulation
program FFmpeg, while very powerful, is not very user-friendly when it
comes to installation. While many Linux programs can be happily
installed from either a pre-compiled package, or downloading source and
compiling yourself, this isn’t necessarily the case with FFmpeg. The
ease of FFmpeg installation largely depends on how many different video
codecs and containers you want to be able to input or output. The
greater the number, the exponential increase in installation
difficulty. My main need was for FFmpeg to accept a wide range of input
formats, while outputting H.264 encoded QuickTime (MOV) files. Here’s
how I achieved this on a Debian Etch server……..

I’m going to assume that you are familiar with using the Linux
command prompt, moving between directories, editing text files and have
at least some experience compiling programs.

The first thing I would recommend doing is making an addition to your source repository lists.

pico /etc/apt/sources.list

Add the following line:

deb stable main

This repository contains some essential libraries for xvid and
x264 (an open source H.264 codec) amongst other things. You’ll need to
install some software from here. The software may well be available
from other repositories too, that are already in your sources.list
file, but add this one to be safe.

Next rebuild your sources:

apt-get update

I would also recommend installing checkinstall. This program can
be used instead of a regular “make install” command and produces a deb
package file that will make re-installation or multiple machine
installs much easier. If checkinstall isn’t already on your machine
download it from:

Maybe navigate here with lynx, maybe use wget once you’ve found
the actual file you need, maybe download it with a GUI based web
browser and then copy it to your desired directory. It’s your choice. I
grabbed the latest .deb package. After the download, execute the following as root:

dpkg -i checkinstall_1.6.1-1_i386.deb

Checkinstall should have happily installed on your system. Now it’s time to really get into FFmpeg.

Build the dependencies:

apt-get build-dep ffmpeg

Next we’re going to install a whole lot more useful software
that will allow FFmpeg to output many more than just the minimal file

apt-get install liblame-dev libfaad-dev libfaac-dev
libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev
build-essential subversion,

We’ve also ensured that you have the necessary tools installed
to compile from source (build-essential) and obtain files from the Subversion version control repositories.

We’re ready to checkout FFmpeg itself:

svn checkout svn:// ffmpeg,

At the time of writing the latest revision was 11212. If you’d
feel more comfortable not using the lastest bleeding edge version of FFmpeg, issue the Subversion command as follows:

svn checkout -r 11212 svn:// ffmpeg

This will ensure that you are also downloading the 11212 revision. Once downloaded, move into the ffmpeg directory (cd ffmpeg) and configure:

./configure –enable-gpl –enable-pp
–enable-libvorbis –enable-liba52 –enable-libdc1394 –enable-libgsm
–enable-libmp3lame –enable-libfaad –enable-libfaac –enable-pthreads
–enable-libx264 -enable-libxvid

So, what have we done here……

The essence of his information, and many more options, can be found by typing ./configure –help first.

(You might also consider including libtheora in your configuration, but I forgot at the time)

We’re now ready to make the installation files so at the command prompt:


If something goes wrong, and you need to start again, a useful command to know is:

make distclean

Make sure you do this first and then run the configure command again.

A finally:


You will be asked a few questions, which should be
straightforward enough to answer – yes to creating the documentation,
choose a name, select D for Debian package, lastly select number 3 and
type a version name that means something to you. Mine was
svn11212-etch-20071213. Checkinstall will now create a Debian package
of FFmpeg, bespoke for your system with the configuration options
you’ve selected earlier. Checkinstall WILL NOT install the package, so
don’t forget to do that:

dpkg -i ffmpeg_svn11212-etch-20071213-1_i386.deb

With some small amount of luck, you should now have a working
version of FFmpeg installed on your Debian Etch server. You will be
able to output H.264 encoded files in a variety of containers.

Now the fun part really begins as you spend days tinkering with
commands to output the best possible files. Documentation for using
FFMPEG can be found at:

Have fun!

(Credit for getting me started in the right direction goes to Paul Battley and his FFmpeg Ubuntu Feisty install how-to)

Categories: FFmpeg, How-To, Video Tags: , , ,

Get every new post delivered to your Inbox.