I can capture video and audio separately, but the createMergingDataSource method of the javax.media.Manager class in FMJ just throws an UnsupportedOperationException. Is there another way to capture audio and video and encode them in AVI (or any other format).
In short, the answer is yes - but only by resorting to native code. Fortunately though, native code and associated jars are freely available for Mac, Windows and Linux which is all most people need.
One such option might be lti-civil: http://lti-civil.org/
VLCJ might also do the trick: http://code.google.com/p/vlcj/
Related
I need a function that I can call, that plays a sound. It needs to have a parameter where I can give it the name of the file I'm trying to play. I've tried searching on the internet, but it's all mostly based around the sun library. And that gives me a warning. Thanks in advance.
You can use Java media framework to play media. As for the method :)
that you have to customize as per your need.
Or if you just want beep sounds, you can use bell character or create beep using awt toolkit
//Bell character
System.out.println("\007");
//Toolkit
java.awt.Toolkit.getDefaultToolkit().beep();
The Java Tutorials, for some reason, doesn't have a simple example of playing a sound in the fire-and-forget manner that you are asking about. But there are other tutorials online that do so.
The search term that will be of most help is "Clip" from the library javax.sound.sampled. This is a core library, so there is no need to import anything. The Clip class loads audio files in RAM, and allows you to play them back from RAM on demand. It is mostly used for short sounds. You should be able to find some code examples if you include "java clip" in a search.
Also in that library is SourceDataLine. This is often used for sounds that are too large to hold in memory. The class plays back data that you provide to its write() method. Thus it is common to pair the class with an AudioInputStream that was set up to read data from a file location. Again, there should be code examples if you search on the class name.
I made use of SourceDataLine to write a small audio library which can be found on GitHub, called AudioCue. The syntax is simpler than with Clip, assuming your source file is a wav file with 16-bit encoding, 44100 fps, stereo, low-endian (also known as "CD Quality"). To make use of it, there are six classes to load. You can just cut and paste. It is kind of a "super Clip" in that it allows extra capabilities like real time volume, panning and variable speed playback, as well as concurrent playback. There is a simple "fire-and-forget" example posted in the README.MD
The library is free to use. (BSD-type license.)
I have been searching on this. I Need to build an independent utility that should:
Convert image sequence to .mov format
Take input from user and display it inside the mov.
I plan to do this using Java since this is a cross platform language.
How to do it?
See JpegImagesToMovie.java it requires the x-plat version of the JMF (or more importantly jmf.jar).
For a more modern alternative, look to JFFMPEG (JMF with more formats & encodings).
I have earlier used XUGGLER for making videos from image frames. It is easy to use XUGGLER with the help of the comprehensive tutorials available here. You can also add audio to the video generated from the image frames.
Xuggler supports a large number of video codecs and video container formats so you will have the option of creating the video in different formats, leave alone .mov. Hope this helps. I can post my own code for this utility if required.
I'm looking to create webpage for record streaming audio from source (like online radio).
At first I thought of doing something like recording from speakers, but solutions like flash, java and javascript refer to recording from microphone and not directly from speakers.
Other alternative is to try capturing the streaming and save to local file, but I couldn't find any way of doing so from a webpage.
Solutions like this refer to iPad platfrom, and not suitable for standard webpage.
Any help will be much appreciated, as any development environment (python, ruby, php..).
The sound coming through the system is generally (1) available through one of the TargetDataLines of the Java Sound (sampled) API. Hook into that TargetDataLine & write the bytes directly to disk.
(Assuming you have the right to do so, of course.)
See the Capturing Audio lesson in the Java Tutorial for details. See my answer to JavaSound mixer with both Port(s) and DataLine(s)? for source to easily explore the available data lines. It is probably the "Primary Sound Capture Driver" that you need for this.
Java code must be trusted (or running with no security manager) to eavesdrop on the sound lines.
On some systems Java Sound does not seem to be able to detect all the lines. For those systems, there is little short of a hardware based audio loop-back (e.g. a cable connecting the speaker output back to the microphone) that will fix the problem.
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
I am looking for an media conversion library that can convert and compress various media i.e both audio and video files to various formats.
FFMPEG-PHP is a popular choice for extracting information. It doesn't re-encode files, though. http://ffmpeg-php.sourceforge.net/
But if you have an instance of FFMPEG installed on the machine, you can call FFMPEG via the exec function in php.
Eg: exec(’ffmpeg -i ‘.$SourcePath.’ ‘.$Destination);
I think your best bet is ffmpeg-php (can be used for both audio and video conversions). Imagemagick has a few basic video conversion options as well.
A second option would be to use mencoder from the MPlayer project (again, you'll have to call this as a command line tool). The main difference between ffmpeg and MPlayer is that the former comes with open source codecs while the latter comes with a host of codecs from all kinds of sources plus it uses ffmpeg.
So ffmpeg is a little more simple to use, MPlayer can convert between many more formats but the command line gets pretty complex.