Results tagged “FFmpeg” from Stream #0

FFMBC 0.4 Now Available

|
A little over one month since the release candidate was made available, FFMBC has officially rolled our version 0.4. Lots of useful and interesting updates for our favourite open source video transcoding tool:

- Sync on FFmpeg svn r21845.
- Full support for reading and writing covert art in mp3 and iTunes m4a,m4v,mp4.
- "-coverfile" commandline option to set a cover file. png,jpg,bmp supported.
- Correctly write Quicktime metadata as utf-8.
- Fixed a bug with temporal offset when muxing mpeg-2 long gop in MXF.
- Huge speedup when opening Quicktime and mpeg-4 files.
- Timecode for Quicktime and MXF files can now be set when stream copying.
- Added x264 sources in contrib directory, git 5b86182d1240b441f28462abf3d40b7371de5ba3
- Enable pthreads by default.
- Fixed a bug with interlaced VC-3 decoding.
- Integrate libavfilter. New commandline option -vf, see doc/libavfiter.texi
- Auto-rotate iPhone 3GS files.
- Support lyrics in mp3 and iTunes m4a,m4v,mp4.
- Automatically set current UTC time in created files.
- New AVFMT_HAS_PTS flag in AVInputFormat to specify that format has pts.
- Write and read metadata "reel_name" in mov timecode track if present.
- MPEG TS muxer now produces streams playable by VLC and Quicktime.

For me, the two most interesting updates in this list are the fixed VC-3 bug and the ability to now set timecode when copying QuickTime and MXF files.

FFMBC version 0.4 can be directly downloaded from here.
As could probably be predicted, there's been a lot more press around WebM over the last ten days or so. A few articles are worth noting.

CNET posted a reasonably ordinary piece regarding the quality of WebM, when compared against H.264. However, there were two interesting links in this piece. 

The first pointed to a WebM project page where the indepth encoding parameters for WebM content are outlined. If you're planning to create WebM files, reading this page is essential. 

The second link, to the quAVlive website provides some various examples of H.264 (using x264) encoding compared against WebM. I can't really see a lot of visual difference in the "Sunflower" example. However, it is easily clear to my eyes, without even enlarging the screenshots, that in "Park Joy" and "Riverbed" H.264 is certainly superior. I would like to have seen more information regarding the time taken to transcode these examples, with each codec, and the resulting file sizes. Picture quality isn't always everything, transcode time and storage requirements should also be taken into consideration.

Everyone's jumping on the WebM bandwagon with software and hardware support. Gstreamer claims full plugin support, which means in turn there is Moovida support and the Transmaggedon transcoder can also output VP8 codec files, although not in the Matroska/WebM container yet. Not to be outdone, Flumotion, will also stream live VP8/WebM content. The Miro Video Converter will also output valid VP8/WebM files, claiming to be the first to do so. The list could go on, but the easiest thing is to probably just keep tabs on the WebM project page listing all the supported devices and software tools, both commercial and open source.

Also worth a shout is the fact that both Mozilla and Opera are pushing for VP8/WebM to be specifically included in the HTML5 specification. Previously, major browser makers couldn't agree on one specific video file format - Mozilla and Opera backing Ogg Theora and Apple sticking with H.264. I can't see that particular situation changing now. 

In August 2009, Google acquired codec developer On2 Technologies for a rumoured $106 million. The flagship On2 codec was VP8 and it was also rumoured at the time that Google may open source this technology in the future, although a number of challenges lay ahead.

Late last week this rumour became reality and WebM was born. Alongside Theora and Dirac, WebM now enters the open source HTML 5 ready codec battle. Almost immediately all major web browsers, except one, but including Internet Explorer announced support for the codec. Using the might and muscle of Google WebM must have a solid chance of taking on the dominance of H.264 in the web video delivery battle. This really will be a solid kick in the pants for Theora, which now seems destined to remain a reasonably niche product, even with direct HTML 5 support from Firefox.

In short order some early comparisons between H.264 and WebM appeared online. Some with more technical detail than others. The debate also began as to whether Google was benevolent or evil. Did WebM contain submarine patents that not even Google were aware of?

Producing WebM video for the masses was the next step. Easy to follow FFmpeg tutorials are available and just a few days ago a major commercial transcoding software vendor announced WebM/VP8 support.

WebM video is already available on YouTube, in experimental form. How long before at least all new YouTube video is transcoded to this format? If WebM quality is on parity with H.264, and the jury is still out on that, what is the unique selling point of H.264? Why would anyone continue to use it? 

There will be a substantial legacy component to overcome. Many people and organisations have invested heavily in H.264 technology, and a move to WebM may represent an operational, although not licensing, cost. However, with Google behind it, many of Big Business' concerns around open source projects may be alleviated.

Adding to this, H.264 video within a Flash player still has significant advantages over HTML 5 delivered video content, in terms of presentation flexibility and perceived security.

H.264 video is of course still dominant for web delivery, just as VP6 and VP7 was in the past. However, WebM is an exciting development with a bright future. Using the collective power of open source development, and no small amount of corporate backing from Google, watch out for WebM to challenge MPEG-LA's codec in the future.


New FFmbc Release 0.3

|
Just days after I first wrote about FFmbc (FFMedia Broadcast) the team have released a new version, marked as 0.3.

Enhancements in this version include:

  • Sync on FFmpeg svn r20539.
  • Write Quicktime timecode track.
  • Set closed gop flag for first gop when encoding with b frames.
  • Search relative path when opening Quicktime reference files.
Download the latest source, or a Windows binary, from the project homepage.

Also now included on the FFmbc wiki is a list of requested enhancements. These include support for additional codecs, bitstream validation for MPEG2 files and support for DNxHD 10-bit files. Go to the requested enhancements page to review and add your own requests to the FFmbc-user discussion group.

FFmbc (FFMedia Broadcast) is an off-shoot of the FFmpeg project that is targeted squarely at the broadcast media world. The project while still in its infancy, but available for around 6 months already, is currently at release version 0.2. Launched and managed by Baptiste Coudurier, well known for his work on the FFmpeg project, FFmbc rolls out the following enhancements:

Import your files in Final Cut Pro or AVID Media Composer by
Creating XDCAM HD422 files in .mov or .mxf
Creating XDCAM IMX/D-10 files in .mov or .mxf
Creating AVID DNxHD files in .mov
Transcode your MPEG-2 4:2:2 Tranport stream files containing S302M audio.
Transcode your AVCHD Camera files correctly.
Merge and split your audio tracks.
Create Quicktime files containing time code tracks.
Advanced Metadata support.
ID3v2 complete support.
Itunes complete support.

We've been meaning to test some of FFmbc's functionality for a while now and after a couple of false starts, we've been successfully able to convert a generic MPEG2 50i (50Mbps all Intra-Frame) 4:2:2 Transport Stream to IMX D-10 in a .mov container. This file contained PCM audio, which version 0.1 of FFmbc baulked at, but the latest version handled perfectly. The output IMX D10 file was imported without error directly into Final Cut Pro for editing. FFmbc has not yet renamed any FFmpeg libraries, so the same conversion syntax and commands can be used across both. Although, be careful as this may create some library conflicts if you try to have both FFmbc and FFmpeg installed at the same time.

Why would we want to use an Open Source transcoding tool in a predominantly proprietary video production environment? The answer is simple. Every commercial product we've investigated (Telestream's Episode Engine and Flip Factory, Rhozet's Carbon Coder, Digital Rapid's Streamz) wanted to transcode our MPEG2 source file to IMX, rather than simply re-wrap the essence into IMX. Transcoding takes a considerable amount of time and will always lower the quality of the final output, no matter how minutely. FFmbc instead took our video and audio essence, extracted it from the MPEG2 Transport Stream and re-wrapped it all to IMX D10. 

Our 30 minute test file was around 16GB in size. Our test machine was a puny eeePC, with an Intel Atom N280 1.66Ghx processor, running Ubuntu Karmic Koala Netbook remix (hardly ideal for transcoding video). The entire conversion process took a little over 7 minutes, at a rate of approximately 110fps (frames per second). Pretty impressive!

There are a couple of caveats to mention with regards to FFmbc. The software is very new and Baptiste is very busy. I'm sure more developers would be a welcome addition to the project. We used the earlier Stream#0 tutorial for installing FFmpeg to achieve the same for FFmbc. However, FFmbc v0.2 didn't like the latest SVN of x264, which is a bug that won't be fixed until the next FFmbc release. Instead, we used the packaged libx264 from the Ubuntu repository. FFmbc then compiled and installed without error. Checking out the latest FFmbc from GIT also caused some issues The source compilation complained and failed regarding the absence of swscale. However, working around these small issues, we've achieved our goal - a quick conversion of a generic MPEG2 file to something that can be edited using Final Cut Pro.

FFmbc is an exciting prospect, targeted directly at the broadcast media world. If you're looking for an open source file transcoding solution, to integrate with your Avid or Final Cut Pro editing environment, give FFmbc a chance to prove itself.
Recently posted on the FFmpeg Developers mailing list was a request for comment from Ronald Bultje regarding the intention to form an FFmpeg Foundation (although not using that name). 

Full text of Ronald's post is as follows:

Hi,

some developers have stated the intent to set up a NGO (non-governmental organization) to help us bring some structure, support and funding into the project. We haven't decided on a name yet, although people agree that we dislike "FFmpeg Foundation" - if you can suggest better names, please do so in this thread. Right now, we're at a point where I think most of the stuff is decided and there is just some paperwork to be filled out. All this with many thanks to Karen at the SFLC who helped to get all this going. The NGO will be registered in Delaware, USA (for administrative reasons). Its goal will be to "advance the state of free and open multimedia" or something like that.

For the time being, this organization will be run by a board consisting of 7 members. For the starting board, the following developers have volunteerd:

- Baptiste Coudurier
- Benjamin Larsson
- Carl Eugen Hoyos
- Diego Biurrun
- Mans Rullgard
- Michael Niedermayer
- Ronald S. Bultje

If you feel that these members will not be able to appropriately represent this project, now would be a good time to speak up and suggest something better. For the near future, the directors will elect a new board at the end of their yearly term (and that might end up in the same 7 members). If there's enough interest, we might set up a member-structure so the board can be properly elected by its members (=developers, contributors, etc.), but ATM we lack the structure for even that ample task, so not for now.

The NGO will set up a bank account to accept tax-deductible donations (bank, paypal, etc.) from organizations, users and companies to benefit the further advance of "open / free multimedia". These might be spend on FFmpeg development, FFmpeg development hackparties, FFmpeg developers attending conferences or anything else that we will would serve the greater good of "open / free multimedia" (i.e. it doesn't have to be FFmpeg, specifically). We will also accept donations for a specific purpose (e.g. Snow, etc.). Lastly, we will host a bank account for MPlayer for donations intended specifically for MPlayer, rather than FFmpeg.

Comments?

Ronald

This sounds like some really positive news and various comments and questions followed this announcement.

Let's hope this organisation becomes a reality and really benefits open source multimedia. We're waiting for a formal announcement soon......


H264 Video Encoding on Amazon's EC2

|
Stream #0 recently started looking at Amazon's EC2 computing offering. We created our first public AMI, based on Debian Squeeze, including FFmpeg and x264 pre-installed. Now that we can easily start instances with the necessary basics installed, it is time to compare the relative merits of the different instance sizes that Amazon offers.

EC2 Instances come in a variety of sizes, with different CPU and RAM capacities. We tested the 64-bit offerings, including the recently announced High-Memory Quadruple Extra Large instance.

These 64-bit instances are listed on the EC2 website in the following way:

Large Instance 7.5 GB of memory, 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each), 850 GB of instance storage, 64-bit platform
Extra Large Instance 15 GB of memory, 8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform
High-CPU Extra Large Instance 7 GB of memory, 20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform
High-Memory Quadruple Extra Large Instance 68.4 GB of memory, 26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each), 1690 GB of instance storage, 64-bit platform

We'll take a closer look later at the in-depth specifications of each below.

Our test file was 5810 frames (a little over 4 minutes and 285MB) of the HD 1920x1080 MP4 AVI version of Big Buck Bunny. The FFmpeg transcode would convert this to H264 using the following 2-pass command:

>ffmpeg -y -i big_buck_bunny_1080p_surround.avi -pass 1 -vcodec libx264 -vpre fastfirstpass -s 1920x1080 -b 2000k -bt 2000k -threads 0 -f mov -an /dev/null && ffmpeg -deinterlace -y -i big_buck_bunny_1080p_surround.avi -pass 2 -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre hq -s 1920x1080 -b 2000k -bt 2000k -threads 0 -f mov big_buck_bunny_1080p_stereo_x264.mov

Setting Threads to zero should mean that FFmpeg automatically takes advantage of the entire number of CPU cores available on each EC2 instance.

FFmpeg revealed the following information about the transcode:

Input #0, avi, from 'big_buck_bunny_1080p_surround.avi':
Duration: 00:09:56.48, start: 0.000000, bitrate: 3968 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 24 tbr, 24 tbn, 24 tbc
Stream #0.1: Audio: ac3, 48000 Hz, 5.1, s16, 448 kb/s
[libx264 @ 0x6620f0]using SAR=1/1
[libx264 @ 0x6620f0]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
[libx264 @ 0x6620f0]profile High, level 4.0
Output #0, mov, to 'big_buck_bunny_1080p_stereo_x264.mov':
Stream #0.0: Video: libx264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=10-51, pass 2, 2000 kb/s, 24 tbn, 24 tbc
Stream #0.1: Audio: aac, 48000 Hz, 2 channels, s16, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1

Ignore the duration, as that's read from the file header, and we only uploaded part of the overall file.

Now to look at how each EC2 instance performed.

m1.large
(Large Instance 7.5 GB of memory, 4 EC2 Compute Units)

Firstly, querying the machine capacity (cat /proc/cpuinfo) returns the following information:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Xeon(R) CPU E5430 @ 2.66GHz
stepping : 6
cpu MHz : 2659.994
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 10
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr dca lahf_lm
bogomips : 5322.41
clflush size : 64
cache_alignment : 64
address sizes : 38 bits physical, 48 bits virtual
power management:

There's 2 of these cores available. RAM is confirmed as 7.5GB (free -g).

The FFmpeg transcode showed the following:

H264 1st Pass = 11fps - 18 fps, 5 minutes 30 seconds
H264 2nd Pass = 4-5fps, 18 minutes 38 seconds

Total Time: 24 minutes, 8 seconds

m1.xlarge
Extra Large Instance 15 GB of memory, 8 EC2 Compute Units

CPU Info:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Xeon(R) CPU E5430 @ 2.66GHz
stepping : 10
cpu MHz : 2666.760
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr dca lahf_lm
bogomips : 5336.15
clflush size : 64
cache_alignment : 64
address sizes : 38 bits physical, 48 bits virtual
power management:

There's 4 of these cores available. RAM is confirmed at 15GB.

The FFmpeg transcode showed the following:

H264 1st Pass = 11fps - 14 fps, 5 minutes 30 seconds
H264 2nd Pass = 6-7fps, 14 minutes 19 seconds

Total Time: 19 minutes, 49 seconds

c1.xlarge
High-CPU Extra Large Instance 7 GB of memory, 20 EC2 Compute Units
CPU Info:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 23
model name : Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
stepping : 10
cpu MHz : 2333.414
cache size : 6144 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr dca lahf_lm
bogomips : 4669.21
clflush size : 64
cache_alignment : 64
address sizes : 38 bits physical, 48 bits virtual
power management:

There's 8 of these cores available. RAM confirmed at 7GB.

The FFmpeg transcode showed the following:

H264 1st Pass = 24-29fps, 3 minutes 24 seconds
H264 2nd Pass = 11-13fps, 7 minutes 8 seconds

Total Time: 10 minutes, 32 seconds

m2.4xlarge
High-Memory Quadruple Extra Large Instance 68.4 GB of memory, 26 EC2 Compute Units

CPU Info:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 26
model name : Intel(R) Xeon(R) CPU X5550 @ 2.67GHz
stepping : 5
cpu MHz : 2666.760
cache size : 8192 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu tsc msr pae mce cx8 apic mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr dca popcnt lahf_lm
bogomips : 5338.09
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

There's 8 of these cores available. RAM confirmed at 68GB.

The FFmpeg transcode showed the following:

H264 1st Pass = 35-38fps, 2 minutes 47 seconds
H264 2nd Pass = 12-15fps, 6 minutes 30 seconds

Total Time: 9 minutes, 17 seconds

What can be revealed from these figures? As expected, the High-Memory Quadruple Extra Large Instance performed best, but not by much. Certainly all the additional RAM didn't make much of an impact, and the time saving is probably really down to the slightly increased CPU specifications. Obviously, over a larger file set this time saving would be more evident.

Let's look at which EC2 instance gives best value for money for this test. Amazon charges per CPU hour, shown below:

m1.large: $0.40/hour
m1.xlarge: $0.80/hour
c1.xlarge: $0.80/hour
m2.4xlarge: $2.40/hour

These are US Dollars and for a US based instance (European instances are slightly more expensive). Amazon has also revealed that there will be a price reduction in effect from November 1st 2009.

Looking at the time taken to transcode our test file, on each instance, reveals the following:

m1.large
Total Time: 24 minutes, 8 seconds
Total Cost: $0.16 ((($0.40/60)/60) x 1448 seconds)
Cost per GB: $0.57 ((1024MB/285MB) x $0.16)

m1.xlarge
Total Time: 19 minutes, 49 seconds
Total Cost: $0.26 ((($0.80/60)/60) x 1189 seconds)
Cost per GB: $0.93 ((1024MB/285MB) x $0.26)

c1.large
Total Time: 10 minutes, 32 seconds
Total Cost: $0.14 ((($0.80/60)/60) x 632 seconds)
Cost per GB: $0.50 ((1024MB/285MB) x $0.14)

m2.4xlarge
Total Time: 9 minutes, 17 seconds
Total Cost: $0.37 ((($2.40/60)/60) x 557 seconds)
Cost per GB: $1.33 ((1024MB/285MB) x $0.37)

Clearly the c1.large instance represents the best value for money, although I was surprised how close behind the m1.large costs were. The additional RAM, and slightly better CPU specifications for the m2.4xlarge instance do not outweigh the much more expensive per hour cost, at least when it comes to video transcoding.

A typical HD file used for broadcast or high end post production purposes is around 85GB for 60 minutes (DnxHD at 185Mbps). Obviously the time taken to transcode this file, to an H264 at 2Mbps, could vary from the actual source content we used, but from the figures above we can estimate that it would cost $42.50 and take approximately 53.62 hours!

Taking into account that these figures may vary for different input and output files, the above should represent a worst case scenario. For example, I would expect an SD MPEG2 50Mbps file to take proportionally much less effort to transcode than a DNxHD 185Mbps HD file. Only a further test will tell......

Is Amazon's EC2 offering worth considering for high end video file transcoding? Compared to the prices charged by Post-Production facilities it is certainly a lot cheaper, as long as you have time to wait for the end result. However, that's the beauty of cloud based computing power - if you're in a hurry just scale up! Keep in mind though, content still needs to be uploaded to EC2 before transcoding can begin, that's going to take additional time and add further cost. 
Stream #0 has now made available our first Amazon Web Services (AWS) AMI. This is based on Eric Hammond's 64-bit Squeeze AMI: ami-fcf61595.

The first Stream #0 AMI can be found by looking for the following AMI ID in the AWS Management Console: ami-b535d6dc

The following additions have been made over the base Squeeze build:

  • Added Debian Multimedia Repository
  • Updated and Upgraded to October 22nd 2009 latest packages
  • Build x264 from source. r1301
  • Build FFmpeg from source. r20350

FFmpeg has been configured as per the options noted in the How-To here

Ultimately we're planning to build a few different AMI variations. e.g. Lenny with FFmpeg 0.5 build and x264 from Debian Multimedia Repo as a slightly more stable version of the "Squeeze build everything from source" AMI approach.

The AMI has been made public and Stream0 would really appreciate feedback on this, our first time AMI build.

Everything you need to know about Amazon's Web Services:

Amazon Web Services
AWS Elastic Compute Cloud (EC2)
AWS Developer Guide
Alestic - listing Debian and Ubuntu AMIs
ec2debian Google Group

How-To Build FFmpeg on Debian Squeeze

|
It's been a long time now since I wrote my original How-To for building FFmpeg on Debian. A lot has changed since then, in both the Debian and FFmpeg world, so it's definitely time for an update.

This tutorial describes how to build x264 and FFmpeg from scratch, on a base Debian Squeeze system. Throughout this tutorial I will be assuming that you are operating as either root or su, or aware of how to use sudo (make sure you've added yourself to the /etc/sudoers list).

First, we need to update the sources list. I use pico as my text editor, as I was a long time Pine mail user way back when. Feel free to use vi or emacs if you prefer.

Go to the Debian Multimedia repository site and download the keyring package. Follow the instructions for unpackaging it about half-way down the front page. Now update your sources list:

>pico /etc/apt/sources.list

Add deb http://www.debian-multimedia.org squeeze main on a new line and save the file.

>aptitude update
>aptitude full-upgrade

Now you're using the latest sources and packages.

Next, install all the additional libraries we'll need:

>aptitude install install build-essential subversion git-core yasm libgpac-dev libdirac-dev libgsm1-dev libschroedinger-dev libspeex-dev libvorbis-dev libopenjpeg-dev libdc1394-dev libsdl1.2-dev zlib1g-dev texi2html libfaac-dev libfaad-dev libmp3lame-dev libtheora-dev libxvidcore4-dev libopencore-amrnb-dev libopencore-amrwb-dev

Once that has successfully completed, it's time to grab the latest x264 code:

>git clone git://git.videolan.org/x264.git
>cd x264
>./configure --enable-shared
>make
>make install

Hopefully all is still going well and you encountered no errors so far. Great, let's grab FFmpeg from Subversion:

>svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
>cd ffmpeg

Now to configure FFmpeg. There's so many options, it's sometimes hard to know which ones to choose. The list below is my personal preference, but do try ./configure --help to assist in choosing your own.

>./configure --enable-gpl --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-shared --enable-nonfree --enable-libvorbis --enable-libgsm --enable-libspeex --enable-libschroedinger --enable-libdirac --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libopenjpeg --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3

After a successful configuration, all the enabled decoders, encoders and muxers will be displayed. There are some configuration dependencies here. If you don't --enable-gpl things like postproc will fail at build time. Next....

>make
>make install

"Make" will probably take quite a long time.

Optionally you may like to build qt-faststart as well. If you don't know what this does, use Google, but in short it arranges atoms in QuickTime header files to allow for progressive download delivery.

>make tools/qt-faststart

If you try to use FFmpeg now, by simply typing "ffmpeg" you are likely to encounter an error regarding shared libraries (we did build FFmpeg with --enable-shared). To fix this we do the following:

>pico /etc/ls.so.conf

Add the line "/usr/local/lib" (without quotes) to this file and then save it. Read more about dynamically linked libraries here, specifically the fourth paragraph to explain what we just did.

>ldconfig

That's it! Finished. Pretty easy, right? Now you just need to learn how to use FFmpeg, but that's a topic for another day. Very briefly though, here's a command line for creating a 2-pass H264 file, at 750kbps and 480x360 resolution, in a mov container, with progressive download enabled.

>ffmpeg -y -i inputfile.mpg -pass 1 -vcodec libx264 -vpre fastfirstpass -s 480x360 -b 750k -bt 750k -threads 0 -f mov -an /dev/null && ffmpeg -deinterlace -y -i inputfile.mpg -pass 2 -acodec libfaac -ab 128k -ac 2 -vcodec libx264 -vpre hq -s 480x360 -b 750k -bt 750k -threads 0 -f mov outputfile.mov

>/tools/qt-faststart outputfile.mov outputfilefast.mov

FFmpeg Watermark.c Alpha Channel Patch

|
Finally, something actually useful on this blog......

If you need to apply a watermark, or Digital Onscreen Graphic (DOG), to a file during the transcode process, the only way to currently achieve this with FFmpeg is to use the vhook watermark.c filter. Unfortunately, vhooks no longer work with the latest SVN snapshots of FFmpeg, as everyone is supposed to be writing new filters for the AVFilter framework.

Unfortunately, again, there's not always time to write brand new filters in C from scratch. Sometimes, a quicker solution is required. At the major UK media content distribution company that I work for, we needed to transcode approximately 5,000 VC-1 5Mbps files to 2-pass H.264 at 1.5Mbps and 500kbps, within 6 weeks. We decided to find all the spare PCs we could get out hands on, install Debian Lenny and FFmpeg, then start transcoding. However, we also needed to apply a DOG to each and every file. How to do this with FFmpeg..... use the watermark.c vhook, which fortunately does still work with the 0.5 release of FFmpeg. Great news. Well, almost.

To achieve a really nice looking DOG, we wanted to use a PNG file with Alpha Channels. The existing watermark.c code did not support this. Therefore, we've written a patch.

This patch means watermark.c now obeys the alpha channel in a PNG file. The -m option is the mode, this must be 2 for alpha blending. The watermark image is applied to the input video and then scaled with the input video to the output video's dimensions. So best to make an image the same dimensions as the input video, otherwise you'll get horrible scaling effects.


Usage:

ffmpeg ... -vhook '/usr/local/lib/vhook/watermark.so -m 2 path/to/image.png' ...


(replace /usr/local/lib/vhook with wherever your watermark.so is.)


Patch is available here -  watermark.patch

(Maybe see links below for files on Github instead)


Example screen grab: View image


We've also posted back to the FFmpeg Devel mailing list.


Actual credit for this patch goes to my colleague Tim MacFarlane - http://refractalize.blogspot.com/


Tim has also now added the files to Github:


Just the patch here.

The whole of watermark.c with patch applied here.

BBC R&DTV - Creative Commons Tech TV

|
In an interesting, and to be applauded, move from the BBC, they are now releasing a technology based television programme under a Creative Commons non-commercial attribution licence. R&DTV's first episode is now available for free download in a number of file formats. There is a full 30 minute version available, a shorter 5 minute highlight version, as well as a complete Asset Bundle, which includes rushes that may not have made it into the final programme versions.

The BBC's RAD blog has a launch announcement about this, followed up by another post 24 hours later outlining some small fixes.

The programme is PAL 720x576. The aspect appears to be 14:9 anamorphic. The little person inside me who wants the greatest and the best all the time, wonders why the filming wasn't done in HD, even HDV would do.

I thought the "formats" described on the R&DTV website were a bit vague. What does QuickTime format and Matroska format really mean? Sure, I know about QuickTime and Matroska containers, but this doesn't say anything about the video and audio essence contained therein. The best way to find out about this is to download each video and let FFmpeg take a look.

QuickTime Format (461.3MB):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'RDTV_ep1_5mins.mov':
Duration: 00:05:59.08, start: 0.000000, bitrate: 10777 kb/s
Stream #0.0(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream #0.1(eng): Video: h264, yuv420p, 720x576, 25 tbr, 25 tbn, 50 tbc

That's H.264 video with PCM audio. Strange they didn't use AAC audio in a QuickTime file. Looking at that 10Mbps bitrate though, I'm guessing perhaps the BBC is expecting people to use this version for editing. But then why use H.264, rather than something that's I-Frame only like IMX50? There's also an Uncompressed version and another QuickTime version, which we'll come to later.
 
Matroska Format (28.4MB):

Input #0, matroska, from 'RDTV_ep1_5mins.mkv':
Duration: 00:05:59.04, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: mpeg4, yuv420p, 720x576 [PAR 1:1 DAR 5:4], 25 tbr, 1k tbn, 25 tbc
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16

Generic mpeg4 video this time (Xvid perhaps) and here's our AAC audio!

MP4 Format (65.4MB):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'RDTV_ep1_5mins.mp4':
Duration: 00:05:59.10, start: 0.000000, bitrate: 1526 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 720x576 [PAR 1:1 DAR 5:4], 25 tbr, 48k tbn, 50 tbc
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16

H.264 video again and AAC audio again. When opening this file with Totem to view, the Comments section says "HandBrake 0.9.3 2008121800". Nice to know the BBC is using Open Source software for at least some of their video transcoding.

AVI Format (63MB):

Input #0, avi, from 'RDTV_ep1_5mins.avi':
Duration: 00:05:59.04, start: 0.000000, bitrate: 1470 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 720x576 [PAR 1:1 DAR 5:4], 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 160 kb/s

Generic mpeg4 video again, but this time with mp3 audio.

FLV Format (37.4MB)

Input #0, flv, from 'RDTV_ep1_5mins.flv':
Duration: 00:05:59.07, start: 0.000000, bitrate: 844 kb/s
Stream #0.0: Video: vp6f, yuv420p, 1024x576, 716 kb/s, 25 tbr, 1k tbn, 1k tbc
Stream #0.1: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s

VP6 for the video codec and mp3 for the audio. No surprises there then. The bitrate is quite low though for VP6 content, quality will suffer.

Ogg Format:

Input #0, ogg, from 'RDTV_ep1_5mins.ogg':
Duration: 00:05:59.08, start: 0.000000, bitrate: 683 kb/s
Stream #0.0: Video: theora, yuv420p, 720x576, PAR 1:1 DAR 5:4, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: vorbis, 48000 Hz, 5.1, s16, 516 kb/s

Theora for the video and vorbis for the audio, again no surprises there. 5.1 audio is a nice touch though. However, again, the bitrate is very low. Why would the BBC do this? The MP4 version, with H.264 video at a higher bitrate, is going to look far superior.

QuickTime 2 Format (155MB):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'RDTV_ep1_5mins_2.mov':
Duration: 00:05:59.08, start: 0.000000, bitrate: 3627 kb/s
Stream #0.0(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream #0.1(eng): Video: h264, yuv420p, 720x576, 25 tbr, 25 tbn, 50 tbc

H.264 video and PCM audio. This second QuickTime file is found only on the FTP site and not linked to directly from the main page. The bitrate is much lower than the previous QuickTime file.

QuickTime Uncompressed Format (7GB):

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'RDTV_ep1_5mins_uncompressed.mov':
Duration: 00:05:59.08, start: 0.000000, bitrate: 167428 kb/s
Stream #0.0(eng): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream #0.1(eng): Video: rawvideo, uyvy422, 720x576, 25 tbr, 25 tbn, 25 tbc

There we go, raw video in the 4:2:2 colour space at 165Mbps, with PCM audio again. I wonder whether the content was filmed at anywhere near this resolution. Given that the programme is only SD, I'm guessing that the highest quality recording would have been done direct to Digital Betacam, which is only the equivalent of 90Mbps, unless of course the whole thing was done tapeless, which I must admit to doubting.

One last puzzlement is why a Dirac version wasn't supplied, given that this is the BBC's own R&D developed codec.
 

Interview with FFmpeg Developers

|
Two posts in two days after such a long silence, who'd have thought it...... And again it's about FFmpeg.

This time Phoronix has posted an interesting interview summary with Diego Biurrun, Baptiste Coudurier, and Robert Swain, three of the many, but very key, developers working on the FFmpeg project. The interview covers some interesting topics about the future of FFmpeg, the difficulties of maintaining such a large project, managing developer motivation for writing codecs and the limited corporate sponsorship the project has so far received.

I've known Baptiste for a year or so, having met at the National Association of Broadcasters (NAB) convention in Las Vegas in April 2008. I'd like to personally thank him for the work he has done on implementing DNxHD in FFmpeg.

Anyway, read the interview and learn something about behind the scenes at FFmpeg.

Also worth a read, which I just found today, is the Phoronix tests on NVIDIAs VDPAU drivers on a cheap chipset and graphics card.

FFmpeg Makes an Official Release!

|
It's been a long while since I've posted on this blog, but finally today something has spurned me into action. 

The FFmpeg team have finally made a release - version 0.5 - with a silly long name. Previously, users were always told to download and compile the latest SVN version of FFmpeg, if they expected any support from the mailing lists.

Now it would seem that there is a stable release, only a few years since the last one, that can be used by software developers and packagers everywhere. I still expect that many mailing list issues will be dealt with by the instruction to download from the SVN or Git repository and compile. I also expect that bug fixes and enhancements will make it into SVN quite quickly, but that also the next release might be some time away.

Release notes are available on the FFmpeg changelog (long!) and there's a lively, as always, Slashdot discussion around this momentous event.

Recently, and it's hard to say exactly which SVN snapshot this occured in, the FFMpeg project changed the location of a number of its header files. This has caused soem havoc with other applications that use FFmpeg for video decoding or encoding.

Amongst other things, Open Movie Editor complained that certain libraries were not installed, which they plainly were. This could be seen from running a simple "ffmpeg -i" command to see what which libraries FFmpeg had been configured again.

Trying to re-compile Open Movie Editor from source struck some problems, in that OME was looking for FFmpeg headers in the wrong place. To overcome this issue, so that OME would compile and then install correctly, I made the following changes.

The first crash will be with regards to avformat.h in the file nle_main.cxx

nle_main.cxx and the other two files you need to make some small edits to can be found in the "src" directory created when OME is unpacked.

There are three files you'll need to edit in the text editor of your choice:

nle_main.cxx
VideoFileFfmpeg.H
AudioFileFfmepg.H

Open each of those files and near the beginning (around line 35) will be references that look something like this:

#include <ffmpeg/avformat.h>

You'll need to find where avformat.h, avcodec.h and swscale.h are residing on your machine.

You can do this by using the following command:

>sudo find / avformat.h

On my machine, a build of Debian Lenny, these files can all be found in /usr/local/include

I edited the files so the code looks like this (example from VideoFileFfmpeg.H):

#include </usr/local/include/libavcodec/avcodec.h>
#include </usr/local/include/libavformat/avformat.h>
#ifdef SWSCALE
    #include </usr/local/include/libswscale/swscale.h>

Once you've saved those files, OME should now be able to find the FFmpeg header files and build correctly.

Hopefully a new version of Open Movie Editor will soon be available where these issues have been rectified in the source.
Having recently installed Xubuntu Hardy Heron on a laptop, I also needed to install FFmpeg. This post is really just a couple of notes for myself, updating my earlier How-To post regarding installation of FFmpeg on Ubuntu Gutsy.

New apt-get install line:

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 libswscale-dev checkinstall build-essential subversion

Here I've added the swscale development libraries. Swscale is used for scaling videos.

If you are ever stuck behind a firewall or proxy, especially one that you have no control over and which does not understand certain SVN commands, there is a nightly Subversion snapshot available for download from the FFmpeg website. This alleviates the need to checkout the source with SVN.

New configure line:

./configure --enable-gpl --enable-libvorbis --enable-libtheora --enable-liba52 --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-libxvid --enable-pthreads --enable-libx264 --enable-shared --enable-swscale --enable-avfilter --enable-postproc --enable-avfilter-lavf

Here I've removed --enable-pp as it is no longer recognised. And I've added --enable-swscale, --enable-avfilter, --enable-avfilter-lavf and --enable-postproc

Avfilter is the new FFmpeg library that replaces the deprecated vhook functionality.

One last note to self is to investigate the possibilities of AVIsynth scripting and FFmpeg.


Real World Open Source Video Editing

|
A short while ago I wrote a review about Open Movie Editor. Essentially this review was written after a couple of hours testing various video clips and assessing the functionality within OME. Now, I can write about what OME is like on a real editing assignment.

Recently I was given a DVD full of PAL DV material and asked to create a compilation from the individual clips. A fun little project that should only take a day or two. Open Movie Editor was the obvious tool for the job.

The good news I can report is that even after 10 to 12 hours of constant video editing, OME is still a very stable piece of software. I only managed to induce two crashes - once when trying to undo multiple edits in a row and once when vigorously moving clips around on the timeline. Other than that, Open Movie Editor was easily up to the task.

I'm not an advanced video editor, happy within my comfort zone using something like Adobe Premiere, but also not using all the intricate features. However, Open Movie Editor does still lack a few basic features, that would have greatly increased my productivity. Changing playback speed of a clip is not possible within OME. I needed to change the framerate of target clips using FFmpeg and mjpeg tools to achieve this effect. While fade transitions are easy enough, I'm sure they could have been even quicker if such a function was built into OME. Precise frame editing, for splitting clips for example, would also make life easier.

There are some really nice features in Open Movie Editor though. Audio automations are a breeze, the media browser window provides easy access to your video library and the list of render options is quite vast - dependent on FFMpeg, Libquicktime and other shared video libraries.

So what did I produce in my 12 hours of work? A fun 4 minute clip, which is still a little rough around the edges, but generally a good laugh. Here's a link for your viewing pleasure:

http://kapitalmototv.co.uk/play-183-0.html

Edited in Open Movie Editor, with some clip transformations using FFmpeg and mjpeg tools. Follow this with final transcoding to x264, again with FFmpeg for more finite control, and you have an Open Source Editing project.

The Kapital Moto TV site uses open source products where possible. The server runs on Debian Etch, the site is served with Apache, built largely with PHP and data is stored in a MySQL database. Content is a mix of QuickTime generated H.264 and FFmpeg generate x264 video files. The Flash player is not open source, but is free as in beer.

Unfortunately my Linux based non-linear editing tool of choice, Open Movie Editor, doesn't currently support directly altering video playback speed. For example, if you wanted a portion of your new compilation to run at 200% of original recorded speed, it can't be done within OME. This exact functionality was something I needed for an existing editing project.

After some thought and investigation, such changes can be achieved through using a combination of FFmpeg and yuvfps, which is part of mjpeg tools, to alter the framerate of the desired footage. If your original file is PAL based, with a framerate of 25fps, changing the framerate to 50fps will result in the video running twice as fast, for half as long.

I didn't initially have mjpegtools installed, but on my Debian based system this was easy enough with
sudo apt-get install mjpegtools
Next, the input video needs to be converted to yuv4mpegpipe format, passed through yuvfps and output to a new avi file. Here's the command line I used to create a clip at 50fps:

ffmpeg -i input.dv -f yuv4mpegpipe - | yuvfps -s 50:1
-r 50:1  | ffmpeg -f yuv4mpegpipe -i - -b 28800k -y output.avi

Change the 50:1 ratios to whatever framerate you require. e.g. 100:1 for 100fps. Be sure to set the output file bitrate to a relevant quality level. Omitting this flag will result in a poor quality AVI output file by default.

The resulting AVI file was easily played back with Totem, and handled on the timeline admirably by OME.

Thanks to Victor Paesa on the FFmpeg mailing list for pointing me in the right direction.

Some other options to investigate include the new Libavfilter for FFmpeg and converting the original footage to a raw data file, which will lost the audio.

Extracting all frames from a video file is easily achieved with FFmpeg.

Here's a simple command line that will create 25 PNG images from every second of footage in the input DV file. The images will be saved in the current directory.

ffmpeg -i input.dv -r 25 -f image2 images%05d.png

The newly created files will all start with the word "images" and be numbered consecutively, including five pre-appended zeros. e.g. images000001.png.

From a video that was 104 seconds long, for a random example, this command would create 2600 PNG files! Quite messy in the current directory, so instead use this command to save the files in a sub-directory called extracted_images:

ffmpeg -i input.dv -r 25 -f image2 extracted_images/images%05d.png

Moving on, let's say you just wanted 25 frames from the first 1 second, then this line will work:

ffmpeg -i input.dv -r 25 -t 00:00:01 -f image2 images%05d.png

The -t flag in FFmpeg specifies the length of time to transcode. This can either be in whole seconds or hh:mm:ss format.

Making things a little more complex we can create images from all frames, beginning at the tenth second, and continuing for 5 seconds, with this line:

ffmpeg -i input.dv -r 25 -ss 00:00:10 -t 00:00:05 -f image2 images%05d.png

The -ss flag is used to denote start position, again in whole seconds or hh:mm:ss format.

Maybe extracting an image from every single frame in a video, resulting in a large number of output files, is not what you need. Here's how to create a single indicative poster frame, of the video clip, from the first second of footage:

ffmpeg -i input.dv -r 1  -t 00:00:01 -f image2 images%05d.png

Notice that the -r flag is now set to 1.

If you want the poster frame from a different part of the clip, then specify which second to take it from using the -ss tag, in conjunction with the line above.

Lastly, if you wanted to create a thumbnail story board, showing action throughout the entire length of the video clip, you'll need to specify the output image dimensions. Use the following line:

ffmpeg -i input.dv -r 1 -f image2 -s 120x96 images%05d.png

My original file was 720x576, so the image dimensions are a whole division of this.

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 720x576.
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.


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

|
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

|
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:

http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

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

http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html

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 artifacts.

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 720x404 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 736x442 -croptop 34 -cropbottom 4 -cropleft 8 -cropright 8 -deinterlace -pass 2 2573-9_h264.mov

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 736x442 -croptop 34 -cropbottom 4 -cropleft 8 -cropright 8 -deinterlace -pass 2 2537-9_x2642passnew.mov

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.

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 848_Termi.mov
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 '848_Termi.mov':
Duration: 00:00:51.7, start: 0.000000, bitrate: 862 kb/s
Stream #0.0(eng): Video: h264, yuv420p, 480x360 [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.......

#!/usr/bin/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";
system($ffmpeg_input_details);
 
open(INPUTFILE,"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 scriptname.pl input_file.extension

Good luck extending this small script for your own uses.

How-To: Install FFMPEG on Ubuntu Gutsy

|

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://svn.mplayerhq.hu/ffmpeg/trunk 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

make

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:

How-To: Install FFmpeg on Debian Etch

|

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 http://www.debian-multimedia.org 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:

http://www.asic-linux.com.mx/~izto/checkinstall/download.php

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 types.

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://svn.mplayerhq.hu/ffmpeg/trunk 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://svn.mplayerhq.hu/ffmpeg/trunk 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 --enable-shared

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:

make

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:

checkinstall

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:

http://ffmpeg.mplayerhq.hu/ffmpeg-doc.html

Have fun!

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

Find recent content on the main index or look in the archives to find all content.

Pages