MP3 Encoding in Java - java

I need an OpenSource API in Java, which can encode *.wav and *.au formats to MP3 and vice-versa.
I have evaluated Java Sound API and LameOnJ, but they do not meet my requirements and are not stable, respectively. Please suggest one that is free and platform independent.

There may not be an adequate answer for you, yet, as the MP3 format requires the authors of decoder/encoders to obtain a license from the Fraunhofer Institute.
I think the the LAME library is distributed from a country that does not respect these IP issues, but it took a considerably amount of legal hackery to get this far.
For any other libraries - for example one written in Java, the authors need to get a similar license. Where cost is an issue - e.g. in an Open Source project, then this is enough of a disincentive to starting.
For more details see this wikipedia article.
If LAME4J is not stable enough for you, then I'm afraid your options are probably:
wait for Sun to license the format for the core JRE. This, I believe they have done recently, but I don't know of any release dates (perhaps to do with JavaFX)
implement your own in Java, and pay the license. I wouldn't fancy this one, either.
write your own Java wrapper to LAME, via JNA, or SWIG
contribute to Lame4J.
pick another format. OGG and FLAC are quite good, and relatively well supported.

Is has been some time, but Oracle/Sun has released MP3 support for JMF. This can be downloaded from the following url:
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html
Adding it to the classpath will enable playback via the AudioSystem api.

The LAME4J uses the free but time-limited license and the unlimited license will cost you some money.
I've found the Lamejb library on the SourceForge, which requires only the lame binaries and works well without any additional licensing.

Use the Process API to invoke SoX
SoX comes with source or as precompiled binaries for Windows and Mac.

If you are searching a pure java version of lame, check out these sources:
http://jsidplay2.cvs.sourceforge.net/viewvc/jsidplay2/jump3r/

The Jave2 project is Java library that wraps FFMPEG and provides most of its functionality* through a rather useful Java API.
Pros:
Useful Java API that is powerful and rather simple.
FFMPEG binary is bundled in, so you don't have to manage an FFMPEG installation on your system.
Cons:
Does not support streaming data: you have to work through temporary files: every conversion starts by storing all the content in some files on the system, getting FFMPEG to create new files for you, then reading them. This is not a deficiency in FFMPEG, more of a problem in Java where it is very hard to stream data to external processes**.
*) specifically around format conversion - the filter functionality is mostly not represented.
**) In Java, launching a process and connecting to its standard output and input is possible but not comfortable, and using named pipes (the BKM for piping AV to/from FFMPEG) is almost impossible, and even if you do manage to do that, Jave2 doesn't play well with that. I have a set of tools to workaround these problems, based on JNA, if anyone is intersted - I can share.

Related

Working With/Processing Audio in Java

Anyone know of any good tutorials or reference guides for working with Audio in Java? I'm not looking for anything too specific at this point; just would like to get my feet wet working with audio. Thanks in advance!
First of all: Multimedia/audio support in Java is not great.
But—if you're set on Java, I suggest taking a look at the Java Sound Trail. It explains most of the basic APIs. Then check out Java Sound Resources to get a better idea of how things work. Even though it's not brand-new anymore, it is very useful and explains a lot about the low level details.
Beyond the raw sound API, Sun came up with JMF, the Java Media Framework. It has been unsupported for years, so I would stay clear of it. You might want to use it for inspiration, but I can't recommend using it for more.
You will also discover that the built-in Java support for audio formats like mp3 or ogg is rather limited. To be able to play such files, you will need third party libraries, like jogg, jflac, mp3spi, or SampledSP. While the first three are pure Java solutions, the last one is basically a thin Java wrapper for a number of native libraries. Especially for FFmpeg there are a many different libraries like that, as FFmpeg supports most available audio formats.
The only way to play an mp3 file from Java without any additional libraries, is to cheat and use the JavaFX class MediaPlayer. You can find more info about how to do that on Stackoverflow.
Good luck!

What Java APIs should I look into for interacting with my microphone?

I would like to build a recording software, for my own purposes, I would like it to be deployable on multiple systems (Windows and Unix) I am also building an application first time. So any help you would be able to provide on that topic as well it would be appreciated.
Please and thank you.
GC
I haven't seen any API for dealing with Microphones explicitly, but the Java Sound API should be able to see it as an input. Specifically, the javax.sound.sampled classes.
Oracle has a (not-so-quick) Java Sound Programmer Guide which includes Chapters on Accessing Audio System Resources and Capturing Audio.
You might look at BASS if you only need to support OS/X and/or Windows. I haven't used it or JavaSound recently enough to speak to which is better at the moment, but BASS was good enough to merit a looksee.

Charting tools for reporting

What are the available charting tools in the market for comparison.
It should support both Java and .NET.
It can be open source as well as cost.Please mention the licence type.
Mention it needs any other external softwares like Flash player or other external plugins
Any tutorial/sample links for each if possible/available.
It need not be supporting real time but charts should be pleasing to eyes.
we are using http://www.amcharts.com (among others) which is quite nice and cheap (flash based)
I've used FusionCharts (commercial) in the past. It is flash based and uses XML to structure the underlying data, so it is fairly easy to integrate with any language. There are additional basic APIs available for use with various languages (JSP and ASP.NET included). Their gallery is at http://www.fusioncharts.com/Gallery/Default.asp
Have a look at this list of Open Source Charting & Reporting Tools in Java. The most used reporting tool in the Java world is probably JasperReports and it is what I use at work.
I have used JFreeChart and found it to be very useful. There are a large number of chart types and structures. Additionally, you have control over the output format, which should allow you to embed in most applications. We currently use it in a back end process that uses a .Net client front end.
License is GNU LGPL.
If you're happy to call a remote web service, take a look at Google Charts
You could have a look at JFreeChart. I have seen it being used extensively in some pretty (thick) rich client frontends.
It is licensed under GNU LGPL.
The one thing that I would mention about this library is that documentation might be a little scarce and might be a steep learning curve if you're new to it. They do recommend buying their own developer guide. Having said that, if you're up for it, you could try reading their source code and debug what's going on under the covers.

Java for a video based application: Good choice?

I am in the concept phase of an application that is going to have a lot of Audio/Video input and output. I want to do it in Java; but somehow am not fully convinced yet. What do you think? How bad could it be? And any advices?
Why I am thinking Java:
It's the language I'm most comfortable with.
Easier cross platform migration would be a bonus.
Cannot afford commercial platforms (like .NET) or not good enough in other free alternatives (like Python)
I'm also slightly inclined towards C++/Qt; but that would take more time for me as I'm not great in that and I am a bit worried about maintainability.
If you're interested, check out Xuggler. It exposes all the power of FFmpeg, but as a Java API that runs on Windows, Mac and Linux. The advantage is you get all the power of FFmpeg but from Java. The disadvantage is it requires the FFmpeg native DLLs/shared-libraries to be installed.
Easier cross platform migration would be a bonus.
Audio and video means you will be dealing with dedicated native libraries and JNI-wrappers for each supported platform; in this case, the cross-platform argument for Java does not really apply.
I believe that when you want to write an audio/video application, the programming language you will use is the second most important thing. The most important thing is the audio/video framework your application will use since this is what defines your capabilities.
I am aware of two popular generic video frameworks that can be used to accesd most multimedia types: Directshow and ffmpeg. Directshow is tied with windows, so only ffmpeg is left.
Ffmpeg has versions in both windows and unix and, although it is written in C, it can be used from a lot of languages.
There is even a number of java wrappers for ffmpeg (for instance, take a look at xuggle)!
C++ would be the first choice because of performance concerns often present in Audio/Video processing as well as the range of available libraries for video/audio.
You do make a good point about being familiar with Java. If you are pressed for time, this is even more important. However if you can spare some time for learning, C++ would be well worth it.
Regarding .NET: The .NET SDK with everything you need is freely downloadable. Get hold of a free IDE such as SharpDevelop and you are up and running. It's Visual Studio that costs money, you don't need Visual Studio to do .NET development.
Rusty.in,
How about trying to do JavaFX Media API. Recently, the version of the JavaFX is 1.2.0 with GUI Application as well. It supports the Swing. The grammar is based on the script style; however, you can deploy the existing Swing components into the JavaFX.
I hope it helps.
Tiger
Rusty, what did you wind up doing? I too have a video app I'd like to do, but really would prefer Java/JavaFX over C++. The thing about the using Flash and/or the current JavaFX video support is that Flash video playback is not frame-accurate. I really need to be able to stop/start/step on individual frames like you can with QuickTime.
Has anyone tried doing playback with Xuggler and Java/JavaFX?

Video Thumbnails in Java

I want to generate a thumbnail preview of videos in Java. I'm mostly JMF and video manipulation alienated.
Is there an easy way to do it?
What about codecs? Will I have to deal with it?
Any video type is suported? (including Quicktime)
Well, since you're not stuck with JMF, have you considered Xuggler? Xuggler is a Java API that uses FFmpeg under the covers to do all video decoding and encoding. It's free and LGPL licensed.
In fact, we have a tutorial that shows How to Make Thumbnails of an Existing File
There seems to be a few examples out there that are far better than what I was going to send you.
See http://krishnabhargav.blogspot.com/2008/02/processing-videos-in-java.html.
I'd agree with Stu, however. If you can find a way to get what you want using some command-line tools (and run them using Commons-Exec), you might have a better overall solution than depending on what is essentially the Sanskrit of Java extensions.
Are you sure that JMF is right for you? Unfortunately, it is not in particularly good shape. Unless you are already committed to JMF, you very well may want to investigate alternatives. Wikipedia has a decent overview at en.wikipedia.org/wiki/Java_Media_Framework
Many JMF developers have complained that it supports few codecs and formats in modern use. Its all-Java version, for example, cannot play MPEG-2, MPEG-4, Windows Media, RealMedia, most QuickTime movies, Flash content newer than Flash 2, and needs a plug-in to play the ubiquitous MP3 format. While the performance packs offer the ability to use the native platform's media library, they're only offered for Linux, Solaris and Windows. Furthermore, Windows-based JMF developers can unwittingly think JMF provides support for more formats than it does, and be surprised when their application is unable to play those formats on other platforms.
Another knock against JMF is Sun's seeming abandonment of it. The API has not been touched since 1999, and the last news item on JMF's home page was posted in November 2004.
While JMF is built for extensibility, there are few such third-party extensions.
Furthermore, editing functionality in JMF is effectively non-existent, which makes a wide range of potential applications impractical.
My own server-side app shells out to FFmpeg to do the encoding. I'm 98.42% sure FFmpeg does snapshots, too. (It is an all singing, all dancing beast of a program. The command line options alone could fill a book.)
Check it out: ffmpeg.mplayerhq.hu
There is a relatively newer option called JThumbnailer that you find here: https://github.com/makbn/JThumbnail
JThumbnail is a Java library for creating Thumbnails of common types
of file including .doc, .docx, .pdf , .mp4 and etc. full list

Categories