Adding .amr Support to Ubuntu Karmic
Nokia phones voice recorders in amr format .
We connect the phone with a wire to the glamorous Ubuntu Karmic, overfill it dictated by long painstaking mental work ...
And then an unexpected bummer awaits us. The codec for these files is not only not installed, but also cannot be found using the built-in (quite often, by the way, “making a mess”) codec search utility for gstreamer.
Moreover, there was no quick way in the spirit of “installing such and such a package, and then it all by itself” was not found on 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 disgrace will be ruled by hands.
Next, we expose to open * .amr files using our script, and you 're done - by double-clicking next to the source file, ogg is created with the same name that you can play on anything.
In this post, I would like to remind many that Ubuntu is still much closer to Gentoo than to MS Windows, and leaves a huge scope for debugging and rebuilding the code to anyone who wants it.
We connect the phone with a wire to the glamorous Ubuntu Karmic, overfill it dictated by long painstaking mental work ...
And then an unexpected bummer awaits us. The codec for these files is not only not installed, but also cannot be found using the built-in (quite often, by the way, “making a mess”) codec search utility for gstreamer.
Moreover, there was no quick way in the spirit of “installing such and such a package, and then it all by itself” was not found on 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 disgrace will be ruled by hands.
- Do it once. Amr support actually happens in ffmpeg. But the guys from Ubuntu for some (apparently copyright) reasons did not include it when building the package.
We will rebuild the package more correctly, because in our homeland licensing violations have not stopped anyone, right?
Download source:$ cd / usr / src
$ apt-get source ffmpeg
$ cd ffmpeg-0.5 + svn20090706 /
In thedebian/confflagsamr file, it is mentioned in the context of some library that I did not find in 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 macrocond_enable_nfputs the necessary flags for configure based on the availability of headers for each non-free library. Having studiedconfigure -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 still be connected to ffmpeg. - Install the libraries for the assembly.
Everything is trivial here - we pull out the * -dev packages required for compilation and the libraries for amr (there were two of them, it was too lazy to understand which one was needed - maybe the second one will come in handy in the future too):$ sudo apt-get build-dep ffmpeg
$ sudo apt-get install libopencore-amrnb libopencore-amrnb-dev libopencore-amrwb libopencore-amrwb-dev - We will correct the package assembly algorithm for ffmpeg.
Add a check for the presence 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 has to come together. - We collect the updated ffmpeg.
$ dpkg-buildpackage -rfakeroot -uc -b
We build only binary packages (-b) using fakeroot (-rfakeroot), and do not sign the changes (-uc).
On output to / usr / src, you get a whole bunch of recompiled packages. - Install everything that happened.
$ sudo dpkg -i /usr/src/*.deb
(If you still have some packages there that do not need to be installed, then I'm not to blame.) - We check to see if everything supports everything well, if there is amr support in ffmpeg.
$ ffmpeg -version | grep amr
If there is a piece in the resulting long sausage--enable-libopencore-amrnb --enable-nonfree --enable-libopencore-amrwb --enable-nonfree, then everything went well. - Play files.
Now our files are normally played withffplay. Players who use ffmpeg throughgstreamer0.10-ffmpeg(for example, Exaile) continue to not find codecs. I have not figured out what to do with this, and as a temporary measure, it was decided to simply distill all the files.amrinto.ogg. - We write a script transcoder.
Somewhere in a suitable place (I like it/usr/local/bin) we create an amr2ogg file, give it the rightsrwxr-xr-xand owner of root: root, and inside we write:#! / bin / sh
ffmpeg -i "$ 1" "` echo "$ 1" | sed s / amr $ / ogg / `"
Next, we expose to open * .amr files using our script, and you 're done - by double-clicking next to the source file, ogg is created with the same name that you can play on anything.
In this post, I would like to remind many that Ubuntu is still much closer to Gentoo than to MS Windows, and leaves a huge scope for debugging and rebuilding the code to anyone who wants it.