Get frame from video in Java - java

I need to extract a single frame from a video file to use as a thumbnail. I would like to be able to generate thumbnails from most common video formats and would also like to be cross platform, so a pure Java solution is preferential.
It would be also useful to be able to get additional information about the video such as frame rate and total length so I can get a frame from a specific place in the file.
I have looked at Xuggler but it appears to be depreciated.

Assuming you want to do this server side, then it may be easiest to leverage ffmpeg as it is commonly used for this type of video manipulation and it also has a large user community.
As ffmpeg is C based, using it with Java requires some sort of wrapper or JNI approach so it is not strictly speaking pure Java, but it is common to use it this way in Java programs. An example wrapper library, which seems to be regularly maintained, is:
https://github.com/bramp/ffmpeg-cli-wrapper

Related

How to create a new camera source in Java?

I am trying to create a new camera source or driver in java. There is a similar question based on python. What am trying to do is that I want a new camera source shown in windows so that all apps can connect to it. And the output will be many images showing in a loop instead of live camera. Can I achieve this with java? If yes How? In stackoverflow there are many questions based on c++. But not about Java. I am trying to achieve this in Java. I think for this I need to use something like directX.
I know how to create the loop of images. But How to create a camera source?
May be you could divide your problem in two parts:
Using a tool for creating virtual webcam video source rather than trying to create a driver from scratch. As discussed in many questions, for example this, you can use the following tool to create a virtual Direct Show source:
DirectShow Video Source Filter for JPEG and M-JPEG IP Cameras
Using another tool like ffmpeg to generate a real time mpegts udp stream from your images (as shown in this question). That stream is the one that the virtual camera source will read from.
You could even use Java to create the stream on point 2, using some library like this (not tested by me).

Process video streams with Xuggler API

I'm trying to build showcase video streaming from a server to a client, but I need to process the stream before sending. I like to do all in java, and client be an Android device.
I just heard about a library called Xuggler which is Java-based and looks promising. Does it provide any functionalities to access the video streams and do some image processing on them before transmission?
Please introduce any other Java-based media streaming / processing libraries if you know of.
For Java video processing, despite being long deprecated, Xuggler has been the best solution that I've found, someone else might know of an alternative.
Since it's not supported anymore you have to do a few things to get started. First find a Xuggler-5.4.jar, Also you need the Java 7 Jdk to run it, it will not work with Java 8, then you need the sl4j-api and sl4j-simple Jars.
It has a complicated but well documented api, but the main gist is you use the MediaToolAdapter interface, create an IMedia Reader and Writer, add something implementing the interface to the reader as a listener, and in the implemented methods for audio and video you can process the data in each frame and pass it to the writer.
This example is a good place to start:
https://github.com/artclarke/xuggle-xuggler/blob/master/src/com/xuggle/mediatool/demos/ModifyAudioAndVideo.java

using FFmpeg for android without any C/C++ or make knowledge

I would like to use FFmpeg library on my android app.
I have no C/C++/Make knowledge and all the threads I've been reading about it talk about stuff I completely don't understand.
Is there any pre-compiled library which I can add to my project, then add a simple 'import' statement on my java class and then call it?
Thanks
Is there any particular reason why you need exactly FFmpeg? I guess it could be possible to get prebuilt binaries, but since it is a C library, you would also need a JNI wrapper code - I don't think anyone would generate that for the whole library since it's quite large, so even with a prebuilt library you still need to have some JNI knowledge to wire through the communication between Java and FFmpeg in C. Just for the purpose of demonstration - here is an example.
Apart from that if there is not a special reason to use FFmpeg, why can't you stick with MediaCodec that is a part of the Android API? It wraps the native StageFright library and could provide hardware support on devices where it is available, while FFmpeg would be a CPU only solution. Of course, if some unpopular codecs or muxers that are not available in MediaCodec are needed, then FFmpeg is the way.
You can use Xuggler for encoding and decoding audio and video. Their wesite says "Xuggler extensively uses FFmpeg to compress and uncompress media".
You could use precompiled libs from the JavaCPP Presets along with FFmpegFrameRecorder from JavaCV to compress images as well as audio samples, as shown in the RecordActivity sample, for example.

video Image processing , how can i?

So Here is the situation.
I have a video that contain some objects that moves (contract to be more accurate),
I'm trying to write a code to calculate these movements in matter of
Frequency of movements (how many contractions per minute)
How far does the contraction goes in mm.
How can this be done ?? :D!
I use Matlab now to to blot amplitude difference between each frame but its not giving very nice results so far.. (very buggy)
Any tips ? language i should use best, or is there already something exist that can compare different images and plot difference ?
Thanks
You should try Processing using one of these libraries.
Keywords to search for: Blob detection, Computer Vision
The best library for tracking moving objects is OpenCV, which can be used from within Processing, too. Tracking faces for example works like a charm there, but for more abstract shapes you should try another library like BlobDetection!
OpenCV is a great library if you plan to write into C/C++ (or wrapped into JavaCV if you prefer Java). Matlab is a great tool too, especially if you are working on a proof of concept you may want to work with something more friendly and "lighthearted" than C.
If you plan to measure positions or distances I suggest you to use some calibration toolbox to consider intrinsic/extrinsic parameters and eventually camera defects, it will give you more precise results. It is builtin into OpenCV, or take a look here if you plan to use Matlab.
so i'm not expert on this but if you want write something in php you probably would use gd library or imagemagick library also imagemagick utility on linux contains some comparing tool according this http://www.imagemagick.org/script/compare.php

Getting an image from a game model

So I'm not 100% sure if it's possible, but what I'd like to do is take a model that someone has created for a game, say in Blender or something similar, in various formats, and from that create an image to show on a website.
Are there any Java libraries around that could help me with that? Java3D maybe? Or even something in Flash? Ideally you'd be able to rotate the model in some embedded flash app, but I'd settle for a plain old image.
It depends on how far you want to go. Most models are going to be in a standard format- or can easily be converted to be - and most 3D Apis are able to load these formats in.
It would be a little unusual to do this on a server - you may even need to have OpenGL installed on it - but it should be quite easy to load a model in to a 3D environment and take a snapshot or a series of snapshots quite easily. Possibly even use these to create a short video clip of a complete turn around the model. If you're using Java take a look at some of the things people are working on over at http://www.javagaming.org/ - I don't know that Java3D is in use much still but there are other good 3D java environments around. JMonkeyEngine looked most interesting last time I was exploring that area.
Alternatively you probably can set up a way of loading the model into a clientside environment - I don't know if Flash can do 3D stuff now, but Shockwave certainly can ( although it's horrible to work with ) and I believe the Silverlight stuff likewise. Of course unless you are pregenerating your animations you are likely to be passing the model to your display logic on the client and a savvy user could intercept that, but the risk is probably reasonably low and from your question it's not clear whether that would be a problem to you.
Take a look into this post:
http://techblog.floorplanner.com/2010/01/25/introducing-asblender/
"Enter ASBlender, a library I slapped together in a few days to read Blender’s .blend file format and parse it to AS3."
lucky you! ;)
EDIT: added link for the project:
http://github.com/timknip/asblender
EDIT2: With the asblender library you can parse directly the .blend file (this is the working file, not a exported file format). Once you have the file inside the flash application you can use Papervision (I believe you do the same with other 3d libraries) to render the model, this way you can do a single image of the model or you can let user to see the model rotating. Beware that any of this libraries won't give the same render quality that a 3D application like blender is capable of. The good thing about this library is the capability of reading all the info in the scene, so you can match cameras and lights to be as close as possible to the original .blend file.
Alternatively there are also other parsers like Ase, Collada , DAE, KMZ, Max3DS, MD2, Sketchup, SketchupCollada... all of this inside papervision library.

Categories

Resources