📜 ⬆️ ⬇️

Add .amr support in Ubuntu Karmic

Nokia phones dictated in amr format.
We connect the phone with a wire to the glamorous Ubuntu Karmic, transfuse dictated by long painstaking mental work ...
And here we are waiting for an unexpected bummer. The codec for these files is not only not installed, but is not found with the help of the built-in (quite often, by the way, “making the mistake”) codecs search utility for gstreamer.
Moreover, there was no quick way in the spirit of “putting such and such a package, and it went on all by itself” in the network. There are libopencore-amrnb0 and libopencore-amrwb0 packages in the repository, but no other packages rely on them — that is, no player can use these libraries by default.

So, Ubuntu is also Linux. Therefore, all this mess will rule hands.

  1. Do it once. Amr support actually happens in ffmpeg. But the guys from Ubuntu for some (apparently copyrighted) reasons did not include it when building the package.
    We will reassemble the package more correctly, because in our country licensing violations have not stopped anyone yet, right?
    Download the source:
    $ cd / usr / src
    $ apt-get source ffmpeg
    $ cd ffmpeg-0.5 + svn20090706 /

    In the debian/confflags amr is mentioned in the context of a library that I did not find in the standard repositories:
    confflags + = $ (call cond_enable_nf, / usr / include / amrnb / sp_dec.h, libamr-nb)
    confflags + = $ (call cond_enable_nf, / usr / include / amrwb / dec.h, libamr-wb)

    Here, the cond_enable_nf macro cond_enable_nf the necessary flags for configure, based on the presence of headers for each non-free library. Having studied configure -h , we see in the list of possible flags:
    --enable-libamr-nb enable libamr-nb floating point audio codec [no]
    --enable-libamr-wb enable libamr-wb floating point audio codec [no]
    --enable-libopencore-amrnb enable AMR-NB de / encoding via libopencore-amrnb [no]
    --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]

    that is, libraries from opencore can be connected to ffmpeg.
  2. Install libraries for assembly.
    Everything is trivial here - we pull out the * -dev packages required for compilation, and the libraries for amr (there are two of them, it was too lazy to understand what was needed - maybe the second one will also come in handy in the future):
    $ sudo apt-get build-dep ffmpeg
    $ sudo apt-get install libopencore-amrnb libopencore-amrnb-dev libopencore-amrwb libopencore-amrwb-dev
  3. Correcting the package build algorithm for ffmpeg
    Add a check for the availability of amr libraries from opencore to the debian / confflags file:
    confflags + = $ (call cond_enable_nf, / usr / include / amrnb / sp_dec.h, libamr-nb)
    confflags + = $ (call cond_enable_nf, / usr / include / amrwb / dec.h, libamr-wb)
    confflags + = $ (call cond_enable_nf, / usr / include / opencore-amrnb / interf_dec.h, libopencore-amrnb)
    confflags + = $ (call cond_enable_nf, / usr / include / opencore-amrwb / dec_if.h, libopencore-amrwb)

    Now everything must come together.
  4. We collect the updated ffmpeg.
    $ dpkg-buildpackage -rfakeroot -uc -b

    We build only binary packages ( -b ) using fakeroot ( -rfakeroot ), and do not sign changes ( -uc ).
    The output in / usr / src will be a whole bunch of recompiled packages.
  5. Install everything that happened.
    $ sudo dpkg -i /usr/src/*.deb

    (If you have any other packages there that you don’t need to install, then I’m not to blame.)
  6. We check if everything is well supported, if there is amr support in ffmpeg.
    $ ffmpeg -version | grep amr

    If the received long sausage has a piece --enable-libopencore-amrnb --enable-nonfree --enable-libopencore-amrwb --enable-nonfree , then everything went well.
  7. We play files.
    Now our files are normally played with ffplay . Players that use ffmpeg via gstreamer0.10-ffmpeg (for example, Exaile) continue to not find codecs. What to do about it, I have not figured it out yet, and as a temporary measure, it was decided to simply overtake all the .amr files into .ogg .
  8. We write a script recoder.
    Somewhere in the right place (I like /usr/local/bin ) create the file amr2ogg, give it the rights rwxr-xr-x and the owner root: root, and inside we write:
    #! / bin / sh
    ffmpeg -i "$ 1" "` echo "$ 1" | sed s / amr $ / ogg / `"

Next, we expose to open the * .amr files using our script, and everything is ready - an ogg is created with a double click next to the source file with the same name that can be played on anything.



With this post, I would like to remind many that Ubuntu is still much closer to Gentoo than to MS Windows, and leaves a lot of room for fine-tuning and rebuilding the code to the person who wants it.

')

Source: https://habr.com/ru/post/80420/


All Articles