Pymedia on debian lenny

Pymedia is a Python module for wav, mp3, ogg, avi, divx, dvd, cdda etc files manipulations.
It allows you to parse, demutiplex, multiplex, decode and encode all supported formats.
It can be compiled for Windows, Linux and cygwin.
we will focus on how to install pymedia on a debian lenny

First install all the dependencies:
$ wget
$ wget
$ sudo apt-get install python-dev libogg-dev libvorbis-dev libfaad-dev libasound2-dev python-pygame
$ sudo dpkg -i libmp3lame0_3.98.2-0.4_i386.deb libmp3lame-dev_3.98.2-0.4_i386.deb

Extract a download of pymedia- and open a terminal in the extracted folder,
Edit the audio/acodec/acodec.c file and on line 31 insert the following :


So you should have:

#include <libavcodec/avcodec.h>
#include “libavcodec/dsputil.h”
#include “version.h”

So we can build pymedia:
$ python build

This should display:
Using UNIX configuration…
OGG : found
VORBIS : found
FAAD : found
MP3LAME : found
ALSA : found
Continue building pymedia ? [Y,n]:
If everything is found press Y

Finally install pymedia:

$ sudo python install


Author: Ali MEZGANI

My name is MEZGANI Ali. I was born back in 1978 in Rabat Morocco. My interests are Debian Linux , programming , science and music.

12 thoughts on “Pymedia on debian lenny”

  1. Hi, I’ve done exactly what you said (but I have, lenny on amd64, so installed other debs for mp3lame), but still I have error:

    g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions build/temp.linux-x86_64-2.5/sound/sound.o build/temp.linux-x86_64-2.5/sound/resample.o build/temp.linux-x86_64-2.5/sound/fft.o -logg -lvorbis -lfaad -lmp3lame -lvorbisenc -lasound -o build/lib.linux-x86_64-2.5/pymedia/audio/
    /usr/bin/ld: build/temp.linux-x86_64-2.5/sound/sound.o: relocation R_X86_64_32 against `a local symbol’ can not be used when making a shared object; recompile with -fPIC
    build/temp.linux-x86_64-2.5/sound/sound.o: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    error: command ‘g++’ failed with exit status 1

    Any ideas?

  2. Ok, I turned -fPIC, so now I have another error, which is possibly connected to my 64bit architecture:

    cc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DBUILD_NUM=1872 -DPATH_DEV_DSP=”/dev/dsp” -DPATH_DEV_MIXER=”/dev/mixer” -D_FILE_OFFSET_BITS=64 -DACCEL_DETECT=1 -DHAVE_MMX=1 -DHAVE_LINUX_DVD_STRUCT=1 -DDVD_STRUCT_IN_LINUX_CDROM_H=1 -DCONFIG_VORBIS -DCONFIG_VORBIS -DCONFIG_FAAD -DCONFIG_MP3LAME -DCONFIG_VORBIS -DCONFIG_ALSA -DHAVE_AV_CONFIG_H -DUDF_CACHE=1 -INone -INone -INone -I/usr/include/lame -INone -INone -I/home/kgorlo/pymedia- -Iaudio/ -I/usr/include/python2.5 -c audio/libavcodec/faad.c -o build/temp.linux-x86_64-2.5/audio/libavcodec/faad.o
    In file included from /usr/include/neaacdec.h:38,
    from /usr/include/faad.h:35,
    from audio/libavcodec/faad.c:31:
    /usr/include/stdint.h:56: error: conflicting types for ‘uint64_t’
    audio/inttypes.h:57: error: previous declaration of ‘uint64_t’ was here

    1. Hello,

      Sorry for my late reply. Well in pymedia install i used a debian on i386 arch, gcc version 4.3.3 (Debian 4.3.3-5), and python 2.5.4.
      Please can you tell me what is the version of your gcc ?

    2. For anyone else who runs into this problem, I was able to compile by adding:


      at the very beginning of ./audio/inttypes.h. The inttypes.h file has conditional definitions to handle if stdint.h is present, but no files in pymedia ever include it; adding the include seemed to clear it up.

  3. I could not build it:

    python build
    Using UNIX configuration…

    OGG : found
    VORBIS : found
    FAAD : found
    MP3LAME : found
    VORBISENC : found
    ALSA : found
    Continue building pymedia ? [Y,n]:
    running build
    running build_py
    running build_ext
    building ‘’ extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -DBUILD_NUM=1870 -DPATH_DEV_DSP=”/dev/dsp” -DPATH_DEV_MIXER=”/dev/mixer” -D_FILE_OFFSET_BITS=64 -DACCEL_DETECT=1 -DHAVE_MMX=1 -DHAVE_LINUX_DVD_STRUCT=1 -DDVD_STRUCT_IN_LINUX_CDROM_H=1 -DCONFIG_VORBIS -DCONFIG_VORBIS -DCONFIG_FAAD -DCONFIG_MP3LAME -DCONFIG_VORBIS -DCONFIG_ALSA -DHAVE_AV_CONFIG_H -DUDF_CACHE=1 -INone -INone -INone -I/usr/include/lame -INone -INone -I/home/data1/protected/Downloads/pymedia- -Iaudio/ -I/usr/include/python2.5 -c audio/acodec/acodec.c -o build/temp.linux-i686-2.5/audio/acodec/acodec.o
    In file included from audio/acodec/acodec.c:31:
    audio/libavcodec/dsputil.h:484: error: static declaration of ‘lrintf’ follows non-static declaration
    audio/acodec/acodec.c:250: warning: initialization from incompatible pointer type
    audio/acodec/acodec.c: In function ‘ACodec_Encode’:
    audio/acodec/acodec.c:669: warning: pointer targets in passing argument 2 of ‘avcodec_encode_audio’ differ in signedness
    error: command ‘gcc’ failed with exit status 1

    Can someone help me?

    1. I’ve bypassed the first error, and I think that the cause was that, the function int lrintf(float x) raise an exception, in the fact so you may define the directive HAVE_LRINTF in one of these files audio/libavcodec/{dsputil.h, common.h, avcodec.h} by adding this line: #define HAVE_LRINTF

      Hope that help,

  4. Hi! Thanks for the tip on the #include.
    Compilation/installation went without problems, but when i try their microphone recording example, i get this error:

    ALSA lib pcm_hw.c:1240:(_snd_pcm_hw_open) Invalid value for card

    Encountered such error?

    TIA for any reply.

  5. Hi,

    I tried to compile pymedia- in ubuntu 9.10 and got the following error:

    audio/libavcodec/dsputil.h:484: error: static declaration of ‘lrintf’ follows non-static declaration

    So I commented out the code in pymedia- :

    //#ifndef HAVE_LRINTF

    /* XXX: add ISOC specific test to avoid specific BSD testing. */

    /* better than nothing implementation. */

    /* btw, rintf() is existing on fbsd too — alex */

    //static inline long int lrintf(float x)


    //#ifdef CONFIG_WIN32

    // /* XXX: incorrect, but make it compile */

    // return (int)(x);


    // return (int)(rint(x));




    Then i recompiled and was successful. I don’t think i remove any critical code.

    Hope this is useful.


  6. Hi there

    i had the same problem than ebe0 had. But adding #define HAVE_LRINTF at the beginning of the file works, and is better than commenting code IMHO 🙂

  7. This is somewhat old but just thought this might be helpful for googling.
    This advice still worked on Ubuntu Lucid with pymedia

    – Add #define HAVE_LRINTF to audio/acodec/acodec.c on line 31
    – Add #define HAVE_LRINTF to audio/libavcodec/dsputil.h


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s