19 March 2012

Converting MP4 to MP3

Problem

On Ubuntu 11.10, this error gets printed when using ffmpeg:

Encoder (codec id 86017) not found for output stream #0.0
It means that the codecs in charge of converting into mp3 are missing.

Solution

A quick and dirty solution:

sudo apt-get install libavcodec-extra-53
Note that the number at the end (53) may change over time. Compiling ffmpeg by hand from the source and installing the eventually missing codecs may be cleaner.

To check that mp3 codecs are now present:

ffmpeg -codecs | grep mp3
This returns:
  EA    libmp3lame      libmp3lame MP3 (MPEG audio layer 3)
 D A    mp3             MP3 (MPEG audio layer 3)
 D A    mp3adu          ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3adufloat     ADU (Application Data Unit) MP3 (MPEG audio layer 3)
 D A    mp3float        MP3 (MPEG audio layer 3)
 D A    mp3on4          MP3onMP4
 D A    mp3on4float     MP3onMP4

Converting

To convert one mp4 to mp3, use:

ffmpeg -i a.mp4 -f mp3 -ab 320000 -vn a.mp3
-i to specify the input, -f the output format, -ab for the bitrate, -vn for no video.

Below, a script that converts all the mp4 in the current folder into mp3 of the same name.

#!/bin/sh
for f in *.mp4
do
    name=`echo "$f" | sed -e "s/.mp4$//g"`
    ffmpeg -i "$f" -f mp3 -ab 320000 -vn "$name.mp3"
done

Links

14 March 2012

Rcmdr on Ubuntu

On Windows, R comes with its own GUI, but on Ubuntu, GUIs such as Rcmdr have to be installed manually.

Software sources

Add a local CRAN mirror to Ubuntu, e.g. http://cran.stat.ucla.edu/, which corresponds to USA-California 2. Remember the mirror you add, because it will be the only one that will be allowed by Ubuntu to fetch software packages. Anyway, add /bin/linux/ubuntu/oneiric at the end of the URL (change oneiric for your ubuntu version). This should give the screenshot below:

Then execute:

sudo apt-get update
sudo apt-get install r-base r-base-dev

Installing Rcmdr in R

sudo R

Then in the R command line:

install.packages("Rcmdr")

Then, finish the installation of Rcmdr by installing the missing dependencies:

library(Rcmdr)

A popup appears, select "CRAN mirror" (not "local folder"), click OK, and the console should start printing lines like below:

Loading required package: tcltk
Loading required package: car
Loading required package: MASS
Loading required package: nnet
Loading required package: survival
Loading required package: splines
also installing the dependency 'matrixcalc'

trying URL 'http://cran.stat.ucla.edu/src/contrib/matrixcalc_1.0-1.tar.gz'
Content type 'application/x-tar' length 8436 bytes
opened URL

...

The downloaded packages are in
 '/tmp/Rtmp6X20rs/downloaded_packages'

And the Rcmdr window should appear. To run Rcmdr in the future, type library(Rcmdr) in the R command prompt. Ctrl-A then Ctrl-R to run everything.

Encountered errors

'Rcmdr' is not available: An error like package 'Rcmdr' is not available (for r version 2.13.1) pops up if R was installed from the Ubuntu repository. The current version (as of March 2012) is 2.14.2. sudo apt-get update, then sudo apt-get install r-base r-base-dev should fix this. If you have the same error with not available (for r version 2.14.1), it may be that no CRAN mirror was added in the software sources to download Rcmdr from.

GPG error: The software center notifies you about new R updates from whichever mirror you picked. When sudo apt-get update, you get the following error:

W: GPG error: http://cran.stat.ucla.edu oneiric/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

This article provides the solution:

gpg --keyserver keyserver.ubuntu.com --recv 51716619E084DAB9
gpg --export --armor 51716619E084DAB9 | sudo apt-key add -

Sources