I am trying to convert a mp3 file into WAVE format in my Android application. This operation should take little time, as the application is social, and it is not acceptable for the user to wait for too long.
So here is where I am :
I have already tried to use JLayer (proposed in a similar question Convert mp3 to wav on Android), but the conversion is too slow: it takes about 40 seconds for a 2 minutes mp3 file.
Concerning the library LAME (as in Lame4Android), I also tried it (with Android NDK) but the result is still too slow (15s to 10s).
I came across another library: JUCE, but it is too vast, and including the entire library in the project in order to do that simple conversion seems a bit... excessive. And I am also afraid it will slow the application.
So what I am currently looking for is a C/C++ library to use in order to do that.
Do you know any fast libraries?
Thank you.
Not sure if the license will work for you (GPLv2), but have you considered libmad?
As I understand it, there's not a NDK build available for download, but here is a page describing how to make one yourself...
Another option is libmpg123, which is LGPLv2.1. The same blog has an article describing how to use it in Android.
Related
I was able to follow the examples of how to encode video with io.humble easily enough. But, the only example of including audio that I can find simply encodes audio at the beginning of the video. I can't figure out how to encode samples at arbitrary locations. Using setTimestamp doesn't do anything.
Here is the example I found:
https://www.javatips.net/api/myLib-master/myLib.AGPLv3/myLib.humble.test/src/test/java/com/ttProject/humble/test/BeepSoundTest.java
If I modify the beepSamples() method to increase the "sampleNum" value, I can create a longer tone. But calling the method multiple times or setting samples.setTimestamp() to other values or calling setTimestamp() on the packets, all do nothing.
No matter what I do, the audio always shows up at the beginning of the video.
Ultimately, I want to be able to load arbitrary mp3 files of various audioclips and then merge them into the audio stream of the video at specific timestamps. But I can't even get this example to encode at different points in the video stream.
The author of this tool unfortunately is not interested in maintaining it or providing examples. Luckily, I found JavaCV which is an alternative that turned out to be really easy to use.
So to anyone else having this problem, I recommend switching to JavaCV. Other options are also JCodec and Xuggler, but Xuggler is deprecated (same author as io.humble) and JCodec apparently is slow and produces much larger files.
If you need support with these kind of projects. I maintain a fork of Xuggler (https://github.com/olivierayache/xuggle-xuggler)..I can provide help on these topics.
I need to be able trim wav audio files for an application I'm building.. but I have several problems.
I tried using FFmpeg-android, but if you target the latest SDK, and in the future, android no longer allows using "FFmpeg.execute". I also tried with the newer mobile-FFmpeg, but the developer stopped maintaining it a few months ago... I also would like to avoid heavy frameworks to also work with video, since I only need to work with audio. I can't find answers anywhere, what am I supposed to do?
You can use AudioTrack to write PCM.
I don't know how one translates input files into PCM data. But once it is in that form, you can edit it to suit your needs and then use AudioTrack to play back the result.
Maybe the MediaExtractor.readSampleData method can be used to read the audio data into an array where you can get to it and do your trimming. I've not done enough with Android to know if this is a viable plan or not.
I'm developing a simple audio player in java. The only advanced feature I need is a frequency filter. It's not necessarily a full-featured equalizer function, with different gains for specific frequency ranges: a low pass filter which cuts frequencies higher than a specified value would be enough.
I studied jlGui which has an equalizer, but it only works with MP3 data, while the files I will be playing are OGG.
Browsing through various answers I found that an ffmpeg wrapper like Xuggler or Jave could be a solution. But I didn't find any tutorial, not even a starting point on how to handle frequency filtering with ffmpeg.
Also JMF is described as a valid choice for implementing such a function, but I found nothing specific enough.
http://www.cs.ubc.ca/~kvdoel/jass/doc/index.html
This is the JavaDoc for the JASS project by UBC Vancouver. It's free for non-commercial use. You should be able to implement most kinds of filters with it. Check the URL few levels up for actual source download.
I'm ending up using this solution (for windows applications) : Equalizer APO
It makes use of the Audio Processing Object technology available on Windows Vista and later. My application just needs to edit a configuration text file and the APO does the rest.
Obviously, it is platform dependent, and I must install an external application for my filter to work, but it is acceptable in my case, and it is very easy to implement.
I found an old project called JEQ
It is based on javax.sound and uses IIR to create a 10/15/25/31-band equalizer. It works on PCM data (not just MP3 like others) so I hope I can make it work with OGG. My only concerns are about output quality, which wasn't very good in some of my tests. I'll have to investigate
Does anyone know of a library for either python, c(++), or java , or even an external app, that I can use to check for a specific audio distortion in an mp3? My problem is this:
I have a very robust Django app that automatically does podcasting for a radio station for all the different shows, but about once a week the computer that does the actual recording records corrupted audio, that has a specific interence pattern, it's a chopping sound almost like a helicopter where the audio drops several times a second. I'm not hoping to fix those audio files(as I've tried manually with good editing software and it's just a lost cause) but rather detect weither or not that type of corruption is present so I can switch to the back-up version of the recording automatically. external tools should ideally run on linux, but windows is acceptable as long as it is headless(no forced gui).
Thanks.
I think all you will need to do is do an fft on the mp3 and you should see a really low frequency spike which corresponds to the big drops. I'm no dsp guru though so not sure that this will work, but its easy to try.
You can use the numpy library for python for this. Link
just read in the mp3 file into an array and then do an fft, for a test I would recommend just plotting it first (using maptlotlib for example), with both versions, corrupt and good and see if you can easily detect the corrupt version. Then hopefully you can write a simple algorithm to detect corrupted files from there fft's.
For reading in the mp3 into a data buffer you can use PyMedia http://pymedia.org/
I haven't used PyMedia so i'm not sure on reading the mp3 into a buffer (it shouldn't be too complicated I imagine), but after that plotting the fft is as simple as:
from numpy import *
from numpy.fft import *
import pylab
# place code to read the mp3 file into buf[] here.
buf_fft = fft(buf, 1024)
pylab.plot(fftfreq(1024, 0.1), abs(buf_fft))
pylab.show()
Try BASS Library and see if it has what you are looking for.
I am looking for a 100% Java solution for encoding software generated images into an AVI stream together with an uncompressed audio track.
At the moment I am using JMF, but its size and installation problems make it a bad solution for my purpose.
While it does not support audio, I created an MJPEG AVI Java class some years ago. You basically just tell it the resolution of your output video, along with the frame rate, then you just keep adding images to it. When you are done, you tell it to finish and it'll close out the AVI. It is based off of the Microsoft documentation on AVI, RIFF, and BITMAP file formats.
Other than not supporting audio, the only real problem is it implements the version of the AVI format limited to 2GB per file. While the class will write out a much larger file, I am uncertain that any players or video editors would be able to read it.
The way I've used this code in the past, is to generate an MJPEG AVI for processing in a video editor (adding audio, etc. in the editor). It helped me with automating some tedious slide show generation. Not sure if this code will help you, as is, but it might help if you are trying to roll your own solution. MJPEGGenerator.java is available if you are interested!
You can use JMF, see this nice example.
There is a nice blog entry here:
http://www.randelshofer.ch/blog/2008/08/writing-avi-videos-in-pure-java/
By Werner Randelshofer