What library to use for a java based media player? - java

I'm working on developing a media player like application in Java (it's a swing based application) and I want it to be able to run on smoothly using as many different file formats as possible. I want to be able to take in a bunch of music files, then retrieve their tag information (artist/album/songname/etc), and then later play them. I've done a bit of poking around but it's hard to find a library which will support .m4a, .mp3. and maybe even .flac files. Does anyone know of a library which will do what I want? Thanks!

JMF is, to put it in the nicest possible way, rather out of date, unmaintained, difficult to distribute and in my experience has quite a few annoying bugs that crop up where you least expect them. And if you can get FMJ to work at all, good luck - they pride on it being an up to date, drop in replacement but my experience begs to differ on both those points.
Personally I wouldn't even consider it - just use separate libraries for each format or bunch of formats you want to support. JLayer would be a good one to start with as it can do a fair few, JFlac will do your flac files on top of that.

There's JMF - see http://en.wikipedia.org/wiki/Java_Media_Framework, which also lists some alternatives. I've had rather mixed success with JMF; it worked well for some static MPEG files but didn't seem compatible with the streaming sources we were using at the time (a couple of years ago).

An alternative to jFLAC for FLAC files is to use the official libFLAC, invoked via the Java native interface. See this blog post, under the headline “FLAC decoding with Java native interface” for an explanation of how it's done, with links to working code.

Related

Best Image Scaling Library

I have searched and found a few image scaling libraries for Java. But not sure which one to go with. I need to generate thumbnails from the image uploaded by server.
It would be great if you can tell which one's good and bad.
The list I have is:
JMagick
im4java
Thumbnailator
java-image-scaling
JAI
For my simple needs, Thumbnailator was perfect. Small lib; fluent, clean, well-documented API.
In my case, it was just "net.coobird" % "thumbnailator" % "0.4.8" dependency and:
//..
Thumbnails.of(originalFile)
.size(300, 300)
.toFile(thumbnailFile)
//..
and done. Basically it’s a friendly wrapper on top of the Java 2D APIs. Useful for specific (thumbnailin') needs; no learning curve.
Unless you really need to do some heavy-lifting with images, I'd be wary of depending on an external binary (ImageMagick and wrappers like JMagick), which would add complexity and moving parts into the setup. Especially if your stack is something like mine: Scala/Java app running on Heroku. There’s stuff like heroku-buildpack-imagemagick-cedar-14, yes, but a simple dependency bundled with the app is infinitely cleaner.
Java API to generate thumbnails is not good enough if you need high quality thumbnails.
To generate high quality thumbnails use a framework like the ones you have listed. I have tried ImgScalr (https://github.com/thebuzzmedia/imgscalr) and Thumbnailator.
With my microbenchmark tests (cannot really be used for general purpose conclusions) Thumbnailator is faster - though not by a lot, and easier - especially when generating thumbnails with transparency.
I also trying out JMagick but running into issues just compiling the code and setting it up. Also a little worried about running into issues later with a framework whose basic code is written in a language I don't understand at all - C.
You might also find useful the discussion here: How can I resize an image using Java?
In my private projects, I don't use any specific library, the functionality provided for Java gives decent results for me. If you just want to do image scaling, then a complete image processing library would be too heavyweighted.
I use the code snippets given in http://www.mkyong.com/java/how-to-resize-an-image-in-java/ which works quite well.

how to display the total time of the video before it starts running

I´m using java and ffmpeg.
I need to get the real time of a video, but i can´t do this. I read that this program does it but i still can not implement. If anyone knows of another way?
Are you using any specific library to do this, or wrapping ffmpeg yourself manually?
The best approach would be to use one of the wrappers out there already such as Xuggler. VLCj would be another alternative to do this. Both require native libraries underneath, but give you Java APIs to work with making the task much simpler.

Creating a Digital Audio Workstation

I am trying to write my own DAW, mostly just to learn about the mathematics of how signals are processed to get effects, but also for fun. (A rather large undertaking, but I have the time at the moment). I would like for it to work something like Propellerhead's Record as in the rack especially.
I'm running on a Mac, so I'm thinking of using Audio Units for the different parts, then Core Audio for the scaffolding parts. So, the whole thing would be written in C or Obj-C.
However, I haven't used either Audio Units or Core-Audio before, and the internet hasn't been any help for learning.
Does anyone know where I could learn about these?
Or would Java (The only other language I'd feel comfortable using) be better, or is there something I've completely missed while trying to find the "easy" way to do this?
Thanks,
Jon
if you want to write a DAW:
at minimum, get your feet wet with an existing project. if i were to personally choose a project, i'd contribute to Ardour.
the signal processing in a DAW is relatively simple. you'll have to work with mixers, files, and graphics. if you're already comfortable writing apps, then you probably won't learn much (beyond the basics). of course, you could find an existing project and extend it with features which relate to what you want to learn; you could write plugs or visualizations for it.
if prefer to work with signal processing:
AU or VST plugins will be a good intro - there are many existing projects which you may reference. eventually, you'll get tired of waiting for a host to load to test your program.
language:
objc is not usable for realtime audio rendering.
java is very unusual for this application. there are actually wrappers for AUs and CoreAudio... but can't name one commercial Java AU for OS X.
most audio shops (that I know of) are using C++ - not C. (Hardware is different). this really seems like an odd omission from your list - most DAWs and plugins use C++, and that is the language you'd find the most examples in. if you're already comfortable with C and Java, I'd recommend coming to terms with C++ because that's the standard language in the industry when targeting desktops.
Look at the cross platform C++ library JUCE, it is open source with the option to license the code (price isn't bad).
Plenty of professional DAW and VST developers use it, I'm one of em.
https://www.juce.com/
Warning, this library is a lot of fun to play with. It renewed my interest in C++, which was no small feat.
you are right-on in assuming that core-audio and audiounits could form the basis for a system (that may not need to be a fully-fledged DAW but may have some combination of multi-track audio recording, editing, playback, etc...) much easier than worrying about cross-platform concerns, massive all-encompassing frameworks like Juce, or ASIO and other os-bypassing hacks. i think you will find that audio programming is a specialized discipline and most folks here on stackoverflow are ill prepared to offer useful advice.
Java is rather unsuitable, as is C#, as are interpreted languages FOR AUDIO, in particular for multichannel audio, DSP, etc. due to time contraints and the need to work on a rather low-level for many critical loops.
you will find the documents you need on developer.apple.com (you'll have to make a login) and you can find shell-examples for your interest directly inside of xcode examples...
good luck

Using Python or Java, what would be the best way to create charts?

I've been searching and found jFreeChart, Python Google Chart and matplotlib. Searching here I also found CairoPlot. I've heard I might be able to use OpenOffice to do it too. Is the API easy to use? Or would it be simpler to stick to one of those libraries?
I have more experience with Java, but I've read most of Dive Into Python 3 and done some mockup programs in Python for simple things. I'm probably gonna have to spend more time doing it in Python, though I'm willing to do it as long as it isn't anything mindblowing. I want to automate some tests to put into a thesis, so I'm more worried about the end product.
So far I'm thinking of using matplotlib simply because it's the only one that's had any recent updates, which leads me to assume there might be more documentation due to continued support. I've used jFreeChart in the past too for some testing, and it was ok. But I was hoping to find something better, or to have more documentation/examples to use. Last time I didn't customize the graphics appearance as I wanted - say, change the background in a line plot - due to the lack of examples/documentation.
I recommend you to use matplotlib, it has high quality backends and a lot of graphical representations, you'll have the whole control over your plots and Python is a very handy and easy language to automatize tests, very practical for what you're willing to do. Matplotlib has also a large community that can help you and a lot of documentation/examples; just remember that matplotlib was not ported to Python 3.x yet, I don't know if this is important for you.
What I absolutely don't recommend is CairoPlot, it is not maintained anymore and is a toy project.
Google's Visualization API is fantastic - and much cleaner if you're working in a web environment, since you just output some text JS with your HTML, don't have to call back and render an image.
JFree also has Eastwood which is a reimplementation of Google Charts API, if you don't want to send your data to Google, or need SSL, though I don't think it's quite current, it's a good subset.

Photo resizer using Java

I'm planning to make a simple Photo Resizer since I usually find myself having to resize huge images being sent to me. I know that there are a lot of online services and tools out there that already do this but I was thinking that it would be a good time to improve my Java and build something useful at the same time.
The problem is that I don't know where to start. I've looked around and mostly saw similar projects made in C# and C++.
Any tips on how to start this?
I did this some years ago to generate thumbnails. IIRC, you can use the ImageIO classes to read the image in as one format, and then write it back out as a different format/resolution.
edit: Oh, and here's Sun's tutorial on working with images. http://java.sun.com/docs/books/tutorial/2d/images/index.html

Categories