Results tagged “x264” from Stream #0
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
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.
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.
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
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.
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)
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:
- Installing FFmpeg on Debian Etch - a far more detailed summary of a very similar process
- FFmpeg User Documentation - where to go next to learn to use FFmpeg
- MPEG4 and H.264 - all about these at the Video Forums.
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
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
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:
So, what have we done here......
- gpl - allow use of GPL code, the resulting libav* and ffmpeg will be under GPL
- pp - enable GPLed postprocessing support
- libvorbis - enable Vorbis encoding via libvorbis (http://www.vorbis.com/)
- liba52 - enable GPLed liba52 support (http://liba52.sourceforge.net/)
- libdc1394 - enable IIDC-1394 grabbing using libdc1394 and libraw1394 (http://sourceforge.net/projects/libdc1394/)
- libgsm - enable GSM support via libgsm (http://packages.debian.org/testing/sound/libgsm-tools)
- libmp3lame - enable MP3 encoding via libmp3lame (http://lame.sourceforge.net/download.php)
- libfaad - enable FAAD support via libfaad (http://www.audiocoding.com/faad2.html)
- libfaac - enable FAAC support via libfaac (http://www.audiocoding.com/faac.html)
- pthreads - use pthreads (http://en.wikipedia.org/wiki/POSIX_Threads)
- libx264 - enable H.264 encoding via x264 (http://www.videolan.org/developers/x264.html)
- libxvid - enable Xvid encoding via xvidcore, native MPEG-4/Xvid encoder exists (http://www.xvid.org/)
The essence of his information, and many more options, can be found by typing
(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)
After a couple of tips on the FFmpeg user mailing list, I re-ran this test with some command optimisations. Specifically:
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.