Wednesday, March 26, 2014

Install ffms 2.19.02 and avxsynth onto Ubuntu 12.04

avxsynth is a linux friendly port of avisynth (the sadly dead video editor that you could script). While I know there are other options available, we have a goodly amount of avisynth scripts already that we would like to work with while we transition to a more permanent, better solution. In order to run avxsynth, it says we need FFMS2.

I used the following pages to put this together:

Compilation and Installation

Preperation

First, follow the instructions at http://interknighterrant.blogspot.com/2014/03/replace-libav-with-ffmpeg-in-lm16.html to compile ffmpeg.

mkdir ~/Downloads/avxsynth

cd ~/Downloads/avxsynth

Installation: FFMS2

git clone git://github.com/FFMS/ffms2.git

cd ./ffms2

./configure --enable-shared --with-pic

make

sudo checkinstall --pkgname=ffms2 --pkgversion="2.19.02-git" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installation: avxsynth

git clone git://github.com/avxsynth/avxsynth.git

cd avxsynth

autoreconf -fiv

./configure --enable-silent-rules --with-pic

make

sudo checkinstall --pkgname=avxsynth --pkgversion="4.0.01" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Final Adjustments

Update libraries listings, just in case.

sudo ldconfig

Testing

cd ~/Videos

sudo cp "/usr/share/example-content/Ubuntu_Free_Culture_Showcase/How fast.ogg" ~/Videos/test.ogg

sudo chown YOURUSERNAME:YOURUSERNAME test.ogg

ffmsindex -t -1 test.ogg
Writing index... done... 100% 

FFMS2 success! Now to try avxsynth

rm test.ogg.ffindex

printf "a=FFAudioSource(\"test.ogg\")\nv=FFVideoSource(\"test.ogg\")\nAudioDub(v,a)\nConvertToYV12()" >> test.avs

ffplay test.avs
ffplay version 2.2.git Copyright (c) 2003-2014 the FFmpeg developers
  built on Mar 26 2014 19:46:03 with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-version3 --enable-postproc --enable-avresample --enable-pic --enable-avisynth
  libavutil      52. 69.100 / 52. 69.100
  libavcodec     55. 54.100 / 55. 54.100
  libavformat    55. 35.101 / 55. 35.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[ogg @ 0xb1520180] Broken file, keyframe not correctly marked.0/0   
[ogg @ 0xb159db60] Broken file, keyframe not correctly marked.0/0   
    Last message repeated 2 times
[avisynth @ 0xb1501980] FFAudioSource: Seeking is severely broken
Input #0, avisynth, from 'test.avs':
  Duration: 00:00:29.28, start: 0.000000, bitrate: 0 kb/s
    Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1280x720, 18.89 fps, 18.89 tbr, 18.89 tbn, 18.89 tbc
    Stream #0:1: Audio: pcm_f32le, 44100 Hz, 2 channels, flt, 2822 kb/s
    nan A-V:    nan fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0

After a pretty short period of time (it will re-index), it plays fine! avxsynth success! Oddly enough, it won't stop playing after the movie has reached the end... but minor flaw in an otherwise successful process.

Un-install

To remove ffms and avxsynth:

sudo apt-get --purge remove ffms2 avxsynth

End Thoughts

The documentation for avxsynth is lacking in general. The most information that can be found is in that thread I linked to at Doom9's Forum. It has basic functionality of avisynth, a few plugins that have been ported, and a couple of additions. Stability wise, it seems like it has worked pretty stable (once you get it set up correctly). I like that I don't need to pipe the avs script in to ffmpeg or x264 anymore, it just works within the programs.

Monday, March 24, 2014

Replace libav with ffmpeg in LM16 / Ubuntu 13.10 (and Ubuntu 12.04 as well)

I prefer ffmpeg.  I think their compilation instructions are good, but wish to completely replace libav on my system and use ffmpeg exclusively (not just limited to a single user).  This isn't a post about why I make that choice, just a how I made it happen.

I have used the following pages in putting this how-to together:

I would love suggestions if there are ways to improve this process.

Compiling and Installation

Preparation

sudo apt-get update

sudo apt-get -y install checkinstall autoconf automake build-essential libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev yasm

mkdir ~/Downloads/ffmpeg

cd ~/Downloads/ffmpeg

wget http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 && tar xjvf last_x264.tar.bz2

wget -O fdk-aac.zip https://github.com/mstorsjo/fdk-aac/zipball/master && unzip fdk-aac.zip

wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz && tar xzvf lame-3.99.5.tar.gz

wget http://downloads.xiph.org/releases/opus/opus-1.1.tar.gz && tar xzvf opus-1.1.tar.gz

wget http://webm.googlecode.com/files/libvpx-v1.3.0.tar.bz2 && tar xjvf libvpx-v1.3.0.tar.bz2

wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && tar xjvf ffmpeg-snapshot.tar.bz2

sudo apt-get --purge remove libav-tools

Ubuntu 12.04 ONLY, Installation: yasm 1.2

On Ubuntu 12.04 you need to compile the latest yasm, as the one in the repository is too old to work properly for the rest of the software compilations.

wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz && tar xzvf yasm-1.2.0.tar.gz

cd ./yasm-1.2.0

sudo apt-get remove yasm

./configure

make

sudo checkinstall --pkgname=yasm --pkgversion="2:1.2.0" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libx264

cd ./x264-snapshot*

./configure --enable-static

make

sudo checkinstall --pkgname=libx264 --pkgversion="20140323-2245" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libfdk-aac

cd mstorsjo-fdk-aac*

autoreconf -fiv

./configure --disable-shared

make

sudo checkinstall --pkgname=libfdk-aac --pkgversion="1.3" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libopus

cd opus-1.1

./configure --disable-shared

make

sudo checkinstall --pkgname=libopus --pkgversion="1.1" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: libvpx

cd libvpx-v1.3.0

./configure --disable-examples

make

sudo checkinstall --pkgname=libvpx --pkgversion="1.3" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Installing: ffmpeg

cd ffmpeg

./configure --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-version3 --enable-postproc --enable-avresample --enable-pic --enable-avisynth

make

sudo checkinstall --pkgname=ffmpeg --pkgversion="7:2.1" --backup=no --deldoc=yes --fstrans=no --default

cd ../

Final Adjustments

There is one thing left to do. We need to tell Linux that there are some library files located in /usr/local/lib

  1. sudo gedit /etc/ld.so.conf
  2. Add the text "/usr/local/lib" on a new line at the bottom of the document.
  3. Save changes and close gedit
  4. sudo ldconfig -v

Testing

ffmpeg -version
ffmpeg version 2.2.git
built on Mar 24 2014 15:22:19 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-version3 --enable-postproc
libavutil      52. 69.100 / 52. 69.100
libavcodec     55. 54.100 / 55. 54.100
libavformat    55. 35.100 / 55. 35.100
libavdevice    55. 11.100 / 55. 11.100
libavfilter     4.  3.100 /  4.  3.100
libswscale      2.  5.102 /  2.  5.102
libswresample   0. 18.100 /  0. 18.100
libpostproc    52.  3.100 / 52.  3.100

Success!

Un-install

To Un-install any changes made from this how-to, simply remove the packages like this:

sudo apt-get --purge remove libx264 libfdk-aac libopus libvpx ffmpeg

You may at that point re-install libav-tools if you choose to, like this:

sudo apt-get install libav-tools

End Thoughts

My larger goal is to get avxsynth to install and function. With stability. The options "--enable-avresample --enable-pic --enable-avisynth" is for ffms2 and avxsynth to work properly.

I will be posting a how to when I have got that installation ironed out correctly.