Is audio recording in the OGG format possible?
Yes. However, first, you need to decide what codec to use. ogg is a container format like avi or mkv or mp4 - just knowing the container doesn't tell you everything about the format. If you want vorbis, there are some pure java encoding libraries (eg vorbis-java) out there (not sure how polished they are!) or you can use JNI to bind one of the many C libraries. If you want some other codec, perhaps better suited to voice (speex? something else?) please specify.
Related
I have a .spx file (an Ogg file with Speex-encoded audio). I would like to use Java to pull the Speex-encoded bytes out of the Ogg container.
The problem is, it seems all of the Java libraries I can find (JSpeex, JOrbis) are written with the assumption that I would also like to decode the audio into raw pcm, which I do not.
Is there a generic Ogg format reader library out there for Java? On the other hand, is it possible to use parts of JSpeex or JOrbis to do what I want?
I could not find an Ogg library in Java after some shallow searching.
But if you are willing to implement Ogg parsing from scratch, the words straight from the horse's mouth are readily available:
Ogg bitstream overview
Ogg logical bitstream and framing spec
(Top page: https://www.xiph.org/vorbis/doc/)
I have not worked with Ogg file with Speex-encoded audio but once I have worked on a use case where I wanted to extract opus packets from ogg opus file, without being decoded to pcm audio. You can find that solution in this answer
https://stackoverflow.com/a/65320789/10110652
This piece of code also works for ogg file with vorbis encoding, so may be this might help with speex encoding as well. Do let me know if this works for you.
Happy Coding!!!❤
I want to record audio and save to my server as mp3 files, i googled and find like this
But it is not free and open source
How can i record audio as mp3 in java and php ?
In terms of Java, you could record with standard Java sound and then use something like lameonj to do the mp3 encoding - all free tools!
This question is the same as yours and the person was able to come up with a solution (which he posted as an answer).
A little additional information. It is possible to record sound in an applet. See this page for information on Java Sound and applets. You'll need to sign your applet, which isn't hard to do. The answer to question 5 doesn't mention this but you can create your own (untrusted) certificate with which to do the signing. This question here on SO has some information on self-signing code.
I solved my problem, I used lame library to encode mp3, If you want to pure code to encode mp3, you can use this
Its using java based lame library
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 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/
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