Tag Archives: ffmpeg

Visual servoing platform compilation on Ubuntu 12.04

Visual servoing platform(ViSP) is quite powerful software package which implements bunch of visual servoing algorithms.

http://www.irisa.fr/lagadic/visp/visp.html

I tried to build this one against my Ubuntu 64bit 12.04 machine with pretty well-documented building instruction.

http://www.irisa.fr/lagadic/visp/documentation/visp-2.7.0-started-unix.pdf

In my case however, it doesn’t be compiled out-of-box!

It says

<code>libavcodec/vaapi.c:97: undefined reference to `vaCreateBuffer'</code>

this error which is related ffmpeg. ViSP makes use of ffmpeg for video file processing.

FFMPEG was installed on my machine as a source (not binary from repo!) with default setting. After googling, I found this FFMPEG needs to build with option –disable-vaapi.

Therefore, the building error was resolved by setting up

./configure --disable-vaapi
make -j4
sudo make install

on your FFMPEG root directory.

After rebuilding FFMPEG, we should be able to compile ViSP w/o error.

HOWTO: Install and use the latest FFmpeg and x264

HOWTO: Install and use the latest FFmpeg and x264

FFmpeg is a versatile tool to encode and decode a multitude of video and audio formats. x264 encodes high-quality H.264 video.

Note: The “ffmpeg” (derived from the libav fork) and x264 packages are available in the Ubuntu repository. You may want to check to see if these packages will fulfill your needs. Following this guide will always provide the most recent FFmpeg and x264 available, but will “replace” the older repository versions and dependent packages may not work with newer FFmpeg and x264 (of course this is reversible).

Choose your Ubuntu
0.The instructions on the page are for Ubuntu Oneiric Ocelot 11.10Ubuntu Natty Narwhal 11.04 andUbuntu Maverick Meerkat 10.10. Separate instructions are also available for older, supported releases:

Install the Dependencies
1. Uninstall x264, libx264-dev, and ffmpeg if they are already installed. Open a terminal and run the following (you can usually paste into a terminal with shift+ctrl+v). Copy and paste the whole code box for each step.

Code:
sudo apt-get remove ffmpeg x264 libx264-dev

2. Get all of the packages you will need to install FFmpeg and x264 (you may need to enable the Universe and Multiverse repositories):

Code:
sudo apt-get update
sudo apt-get install build-essential checkinstall git libfaac-dev libjack-jackd2-dev \
  libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev \
  libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev texi2html yasm zlib1g-dev

Install x264
3. Get the current source files, compile, and install x264. (See using snapshots if you are having connection issues with the Git server.)

Code:
cd
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
    awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default

Install libvpx (optional)
4. This is used to encode VP8 video. If you follow this step, add –enable-libvpx to the FFmpeg ./configure line in step 5.

Code:
sudo apt-get remove libvpx-dev
cd
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
sudo checkinstall --pkgname=libvpx --pkgversion="1:$(date +%Y%m%d%H%M)-git" --backup=no \
    --deldoc=yes --fstrans=no --default

Install FFmpeg
5. Get the most current source files, compile, and install FFmpeg.

Code:
cd
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb \
    --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 \
    --enable-nonfree --enable-version3 --enable-x11grab
make
sudo checkinstall --pkgname=ffmpeg --pkgversion="5:$(date +%Y%m%d%H%M)-git" --backup=no \
  --deldoc=yes --fstrans=no --default
hash x264 ffmpeg ffplay ffprobe

Install qt-faststart (optional)
6. This is a useful tool if you’re showing your H.264 MP4 videos on the web. It relocates some data in the video to allow playback to begin before the file is completely downloaded. Usage: qt-faststart input.mp4 output.mp4.

Code:
cd ~/ffmpeg
make tools/qt-faststart
sudo checkinstall --pkgname=qt-faststart --pkgversion="$(date +%Y%m%d%H%M)-git" --backup=no \
    --deldoc=yes --fstrans=no --default install -Dm755 tools/qt-faststart \
    /usr/local/bin/qt-faststart

Adding lavf support to x264 (optional)
7. This allows x264 to accept just about any input that FFmpeg can handle and is useful if you want to use x264 directly. See amore detailed explanation by forum member qyot27.

Code:
cd ~/x264
make distclean
./configure --enable-static
make
sudo checkinstall --pkgname=x264 --pkgversion="3:$(./version.sh | \
    awk -F'[" ]' '/POINT/{print $4"+git"$5}')" --backup=no --deldoc=yes \
    --fstrans=no --default

That’s it for installation. You can keep the x264libvpx, and ffmpeg directories in your home directory if you plan on updating later. See Updating FFmpeg and x264 below for more details.

Using FFmpeg and x264
The easiest method for high quality video encoding is by using the libx264 presets. See x264 –fullhelp for more info on these options.

One-pass CRF (Constant Rate Factor) using the slow preset. One-pass CRF is good for general encoding and is what I use most often. Adjust -crf to change the quality. Lower numbers mean higher quality and a larger output file size. A sane range is 18 to 28.

Code:
ffmpeg -i input -acodec libfaac -aq 100 -vcodec libx264 -preset slow -crf 22 output.mp4

One-pass CRF (Constant Rate Factor) using the medium preset, animation tuning, baseline profile, and level 3.0:

Code:
ffmpeg -i input -acodec libfaac -aq 100 -vcodec libx264 -preset medium -tune animation \
    -profile baseline -level 3.0 -crf 20 output.mp4

Two-Pass encode using the fast preset. Two-pass encoding is usually used when you want a specific output file size.

Code:
ffmpeg -i input -pass 1 -vcodec libx264 -preset fast -b 512k -f mp4 -an -y /dev/null \
    &amp;&amp; ffmpeg -i input -pass 2 -vcodec libx264 -preset fast -b 512k -acodec libfaac \
    -ab 128k -ac 2 output.mp4

Lossless H.264 can be used like most other lossless formats such as archiving, fast encoding (a screencast for example), or as an intermediate file. Use ultrafast if you need to encode quickly and don’t care about file size, or veryslow if you need the smallest file you can get and don’t care about encoding speed. Creates huge files.

Code:
ffmpeg -i input -vcodec libx264 -preset ultrafast -crf 0 -acodec copy output.mkv

Updating FFmpeg and x264
Development of FFmpeg and x264 is active and an occasional update can give you new features and bug fixes. First, remove some packages and then update the dependencies:

Code:
sudo apt-get remove ffmpeg x264 libx264-dev libvpx-dev
sudo apt-get update
sudo apt-get install build-essential git checkinstall yasm texi2html \
  libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev \
  libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev \
  libvorbis-dev libx11-dev libxfixes-dev zlib1g-dev

Update x264:

Code:
cd ~/x264
make distclean
git pull

Now compile x264 as shown earlier in the guide starting with the x264 ./configure line. Update libvpx:

Code:
cd ~/libvpx
make clean
git pull

Now compile libvpx as shown earlier in the guide starting with the libvpx ./configure line. Update FFmpeg:

Code:
cd ~/ffmpeg
make distclean
git pull

Finish the installation starting with the FFmpeg ./configure line.

Reverting Changes Made by This Guide
To remove FFmpeg/x264 and other packages added for this guide:

Code:
sudo apt-get autoremove x264 ffmpeg qt-faststart build-essential git checkinstall \
  yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libsdl1.2-dev libtheora-dev \
  libva-dev libvdpau-dev libvorbis-dev libvpx libx11-dev libxfixes-dev zlib1g-dev

Lastly, delete the x264libvpx, and ffmpeg directories in your home folder.

 

How To: Fix “No accelerated colorspace conversion found from yuv420p to bgr24.” | OpenCV-2.2.0 & Ubuntu 10.10

[swscaler @ 0xbf2130]No accelerated colorspace conversion found from yuv420p to bgr24.

This problem is basically an issue converting YUV to RGB using ffmpeg, in order for it to work ffmpeg needs to be recompiled with x264. To get around it use the following to recompile ffmpeg and OpenCV 2.1/2.2:

  1. Follow steps 1-to-4 of FakeOutdoorsman’s guide on ubuntuforums.org – here
  2. OpenCV 2.1/2.2 Install Guide by Sebastian Montabone – here

 

Related posts:

  1. HowTo: Install OpenCV in Ubuntu Karmic (9.10)
  2. Problems Installing OpenCV in Ubuntu Karmic (9.10)
  3. How To: Install Pyrobot in Ubuntu