I am using Java to write a media application.
Given a file, how can I know is it a audio file or video file?
By the way, I use vlcj library.
In Java 7 you will be able to use java.nio.file.probeContentType to do this.
In the meantime, there are a number of other options for doing this kind of thing.
Related
In some situations (automated testing) I need to screencast my display(s) to video file(s), but currently i can only save a series of PNG files using Robot and ImageIO classes, I know there are other third party programs to convert this set of image files into a video file but I want to make it in my code without a need to third party applications, so how to convert from a series of PNG files into a video file in any format ? Thanks in advance.
I would just get FFmpeg and use that to convert your images to video. You can make syscalls in Java if what you mean by "third party application" is "I don't want to do it manually" as FFmpeg supports command-line.
For example, maybe something like
String[] cmds = {"path/to/ffmpeg", args ... }
Runtime.getRuntime().exec(cmds);
There are many tutorials available on how to use ffmpeg to convert a sequence of images to a video file.
We have a java web application where users can upload all kinds of files including any kind of video files. Now we want to allow them to stream these video files they own. So I need to make sure that they are the owner and then stream video. Also possibly stream a preview.
Do I need to convert these video files before streaming and where should I look to get started?
The best video playback/encoding library I have ever seen is ffmpeg. It plays everything you throw at it. (It is used by MPlayer.) It is written in C but I found some Java wrappers.
FFMPEG-Java: A Java wrapper around ffmpeg using JNA.
jffmpeg: This one integrates to JMF.
Some video files contain multiple audio tracks. Multiple languages for example. Is there a library which gets information about these audio tracks? Names of the audio tracks would be sufficient.
It should support common formats (mkv, avi,...)
I believe the best monolithic media file library available is that for VLC player. I seem to remember there was a Java wrapper, but it's probably not maintained (like all Java wrappers more than a few weeks old heheh).
I have found a solution to my problem. From Java I call the following command:
ffmpeg -i myvideo.mkv
Then I read the commands output and filter the lines which start with Stream #.
This works on all my files with multiple audio tracks.
Is there any freely available library (other than java media framework) that I can use to extract the bit rate (eg. 128 kbps, VBR) and the audio quality (eg 44.1KHz, Stereo) from a MP3 file?
I would like a standalone library that I can incorporate into my application jar, to be deployed on older Macs too that have only Java 1.5 available and I can't get them upgraded or add any big Java library to.
Just to clarify: I will not play, transcode or do anything of the sort with the audio stream itself, I am interested in the metadata only.
I confess I do not know much about MP3 files, but you can see from the format specification that all the informations needed are in the 32 bits long header of the file.
You could open the MP3 with a FileInputStream, read the first 4 bytes of the file and, using some simple binary masks, retrieve the informations you need. IMHO using a specialized library for that is a bit of an overkill.
Take a look at JAudioTagger, plain simple and easy to use, the data you are looking for is into MP3AudioHeader class, with methods like getBitRate()
You can use the LAMEOnJ library:
http://openinnowhere.sourceforge.net/lameonj/
This java library is light but you must have the LAMELib installed on target computer.
I'm not a java programmer, but i'm pretty sure you could read the mp3 file into a byte array then see http://www.mp3-tech.org/programmer/frame_header.html for frame info.
This format specification shows you what's contained the MPEG (mp3) header. You can write code to retrieve this header.
i want to create audio file using text. in this case i tried AudioOutputStream and AudioSystem.write() methods this way audio file created but problem in running. so if any idea that helps for converting text to audio file please write below.
thank you.
Piyush
If you want to make some kind of "text to speech" you'll need a library, which will handle this. Otherwise you will have a lot of work. Try this project:
http://freetts.sourceforge.net/docs/index.php
You think creating audio from text is as simple as writing text data to an audio stream ? ...
LOL
To convert text to audio, you have to rely upon rather complicated tools, like text-to-speech engines.
Hopefully, java is known for the forrest of many trees. Concerning text-to-speech, you can rely upon this excellent question and its anwsers.