Capturing frames from a video file for further processing? - java

I am a beginner in java, recently i have studied about JMF (Java Media Framework) from this link, I have learned that how to play a video file in java programs using JMF, Now what I need to do is, I have to capture frames from given video files and then process it using some image processing algorithm and then I have to send these from to that player for displaying. Can anyone please suggest me that how to do that.
I have already read this link

If you're not required to use JMF, it is probably worthwhile to consider other options at this point. Unfortunately, Xuggle/Xuggler is apparently on hiatus - but if the state of its last release will work for you, they have a Frame Capture Demo that should be a good starting point.
If you are sticking with JMF, perhaps Accessing Individual Decoded Video Frames
will point you in the right direction with its info on using a pass-through codec. Note that you'll need to search for a copy of FrameAccess.java if you want the demo code for this option (the link seems to be broken on that page).

Related

Are there an examples of how to use the java api io.humble to encode audio?

I was able to follow the examples of how to encode video with io.humble easily enough. But, the only example of including audio that I can find simply encodes audio at the beginning of the video. I can't figure out how to encode samples at arbitrary locations. Using setTimestamp doesn't do anything.
Here is the example I found:
https://www.javatips.net/api/myLib-master/myLib.AGPLv3/myLib.humble.test/src/test/java/com/ttProject/humble/test/BeepSoundTest.java
If I modify the beepSamples() method to increase the "sampleNum" value, I can create a longer tone. But calling the method multiple times or setting samples.setTimestamp() to other values or calling setTimestamp() on the packets, all do nothing.
No matter what I do, the audio always shows up at the beginning of the video.
Ultimately, I want to be able to load arbitrary mp3 files of various audioclips and then merge them into the audio stream of the video at specific timestamps. But I can't even get this example to encode at different points in the video stream.
The author of this tool unfortunately is not interested in maintaining it or providing examples. Luckily, I found JavaCV which is an alternative that turned out to be really easy to use.
So to anyone else having this problem, I recommend switching to JavaCV. Other options are also JCodec and Xuggler, but Xuggler is deprecated (same author as io.humble) and JCodec apparently is slow and produces much larger files.
If you need support with these kind of projects. I maintain a fork of Xuggler (https://github.com/olivierayache/xuggle-xuggler)..I can provide help on these topics.

Java Desktop Capture

I want to continuously capture the entire desktop inside of a java application. As I'm capturing, I'd like to chunk the stream of data into small video files (mp4, WebM) for storage. From my research, it would seem that the Robot Java class and the FFmpeg tool are my best options. However, Robot seems to best-fit the use case of obtaining images, not videos. FFmpeg seems like it may support this, but I've struggled to find definitive documentation. I'm looking to emulate what can be done through Chrome's getUserMedia and desktopCapture APIs along with the MediaStreamRecorder JavaScript library. Does anyone have a suggestion for a similar and elegant solution in Java?

java audio frequency filter

I'm developing a simple audio player in java. The only advanced feature I need is a frequency filter. It's not necessarily a full-featured equalizer function, with different gains for specific frequency ranges: a low pass filter which cuts frequencies higher than a specified value would be enough.
I studied jlGui which has an equalizer, but it only works with MP3 data, while the files I will be playing are OGG.
Browsing through various answers I found that an ffmpeg wrapper like Xuggler or Jave could be a solution. But I didn't find any tutorial, not even a starting point on how to handle frequency filtering with ffmpeg.
Also JMF is described as a valid choice for implementing such a function, but I found nothing specific enough.
http://www.cs.ubc.ca/~kvdoel/jass/doc/index.html
This is the JavaDoc for the JASS project by UBC Vancouver. It's free for non-commercial use. You should be able to implement most kinds of filters with it. Check the URL few levels up for actual source download.
I'm ending up using this solution (for windows applications) : Equalizer APO
It makes use of the Audio Processing Object technology available on Windows Vista and later. My application just needs to edit a configuration text file and the APO does the rest.
Obviously, it is platform dependent, and I must install an external application for my filter to work, but it is acceptable in my case, and it is very easy to implement.
I found an old project called JEQ
It is based on javax.sound and uses IIR to create a 10/15/25/31-band equalizer. It works on PCM data (not just MP3 like others) so I hope I can make it work with OGG. My only concerns are about output quality, which wasn't very good in some of my tests. I'll have to investigate

How can I convert image sequence to quicktime movie?

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.

100% Java encoder for AVI animation

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

Categories