How to convert BufferedImage to AVI? - java

This question is an extension to my previous question:
Problems associated with my screenshot-taking software
Now with the problems solved, I want to convert the .png images to .avi file. Now the format of images and video doesn't really matter since the images are written to the disk using javax.swing.ImageIO so I can change the save format. So they are BufferedImage before being made as .png
Most questions here on similar topics were asked to use some 3rd party software and all. I want to do it using just Java.
Where do I begin?
Can you help me understand this?

If you don't mind using 3rd party libraries you might want to take look at Xuggler. It's a wrapper for ffmpeg that helped me some time ago.
Update: This demo might contain all you need: https://github.com/xuggle/xuggle-xuggler/blob/master/src/com/xuggle/mediatool/demos/CaptureScreenToFile.java

Related

java or javascript way to convert images file to favicon.ico

I am trying create a java function to convert image files such as "jpg, jpeg, gif, png" into favicon.ico. Does anyone know any library can do that? I want pure java or javascript way. Not the way using imageMagick with jni
Take a look at image4J which will allow you to create ICO images through Java
As simply as...
List<BufferedImage> listOfImages = ...;
ICOEncoder.write(listOfImages , new File("favicon.ico"));
You may also want to check out Reading/Loading an Image as well...
Disclaimer: I not aiming to Answer the question in the most efficient way, but i found an interesting possibility how to solve this problem in an unconventional manner.
with some googling i found this existing site http://mrcoles.com/favicon-creator/ (first result, for the searchterms "javascript create ico").
It has javascript code to create an ICO file, coping this code and adding some canvas html5 magic like found here, you could build the whole thing in Javascript and having lots of fun.
Just a crazy Javascript approach, from the do-it-yourself (copy-past-it-yourself) shelf. :)))

Using GStreamer for creating AVI files

So, I was recommended GStreamer to create video files. I was going over their tutorial for creating a video file.
The problems I encountered are:
How do I create an AVI file rather than a YUV something.
What is the source being used there?
I want to give a set of BufferedImages or anything else that will show what was going on the screen. I have previously used JPEGtoMovie provided bu the Java guys and for that I had to first save all the images to the disk as JPEG, sort them into their correct order from lexicographical order and a whole lot more.
I was planning to avoid that and that is why I was thinking of Vector<BufferedImage> or BlockingArrayQueue<BufferedImage>
Which all plug-ins do I need from GStreamer to create the AVI output?
Sorry I have been asking too many questions today. I have never worked with a media framework before and I am very dumb
The command gst-inspect will list all included elements (components).
you can produce an avi file from the pipeline: videotestsrc ! encoder ! avimux ! filesink where encoder stands for the encoding element you'd like to use
an alternative would be to use: videotestsrc ! encodebin ! filesink; here you just build a profile and encodebin will figure our what encoder and what muxer to use to create the format specified in the profile
I did not understood the part around the BufferImages. You can feed images manually to gstreamer (e.g. using [appsrc ! decodebin] instead of [videotestsrc]), but thats a last resort. There are also elements such as multifilesrc that read a sequece of images. Maybe you can give more details what you want to do (where do the source frame come from).

How to read/write custom PNG metadata in Android?

I have to associate a couple of text parameters (a UUID and a couple of strings representing integers) to a PNG image in a way they can follow the image when the PNG file is passed from an Android device to another through the Net. This is the typical situation in which I would use a couple of custom auxiliary chuncks (similar to EXIF fields ) to store my data inside the PNG image itself.
Maybe it is just me but the only info I was able to find about reading and writing PNG custom metadata from Java code on Android was this SO post:
Writing image metadata in Java, preferably PNG
that even offers some code (quite verbose, as usual with Java).
Those same SO post refers also to PNGJ: http://code.google.com/p/pngj/
To be honest, I would be happy to not use yet another library in this project.
Does anybody know of others ways to write and read text metadata in a PNG file in Android? Maybe a less verbose way... Maybe a way that does not require a separated library....
Any other source of information? Any tutorial? Any example?
I'm open to use a different (but equivalent) image file format, if needed (JPEG, whatever).
A solution working also on iOS and Windows 8 Phone would be a plus but it is not actually required.
I had to do something similar lately, so I had to study the subject.
Android offers you no option of manipulating png metadata. You will have to use an external library (PNGJ seems like a good option).
In my case, since I am making changes to the Android frameworks, I didn't use an external lib, but made changes to skia (the Android graphics library instead).
If you need more info on that I can give you, but I think it's irrelevant in your case.

Video Transcoding/Conversion using Java

I would like to convert a video from one format to another. Initially, I want to convert MP4 to AVI or any other more suitable video format.
Came across the ffmpeg library. Is is the best solution?
Came across Xubber and Jave for the same? Any experiences?
I tried jffmpeg that is a direct java wrapper on ffmpeg, but didn't found much documentation over that so moved on.
I tried to use Xubber and succeded also but it requires lot of pre-configurartions like you have to install .exe file prior and set XUBBER_HOME vars etc.
I have found nice and easy to implement solution ie JAVE http://www.sauronsoftware.it/projects/jave/index.php
Try this one.

Reading RAW images from Java

Canon/Nikon/other cameras save raw output of their sensor in some of their proprietary formats (.CR2, whatever). Is there any Java library designed to read them and convert into manageable BufferedImages?
I don't reqlly care here about fully customizable conversion similar to ufraw or imagemagick, rather something simple that "just works" for rendering simple previews of such images.
I've been where you are, and I feel for you. Your best bet is to use an Adobe or dcraw-based program to create thumbnails automatically. Temporary DNG files using Adobe's converter may be easier to use.
IF you insist on doing it in Java, you're about to run into a mountain of pain. RAW formats change often, have all sorts of crazy nuances and are intentionally hard to work with. Camera makers want you to use THEIR RAW conversion software, to show the camera's abilities at its best and screw Adobe. The guy behind dcraw found that some are camera manufacturers even use encryption now!
The existing Java libraries are poor -- JRawIO has improved since I last looked at it, but it supports only a fraction of the formats that dcraw does. In addition to the listed libraries, the imagero library may provide the ability to display a thumbnail for your image.
From personal experience, don't even think about writing your own RAW file reader.
I tried to do this with a very simple RAW format once (just a solid array of sensor data, 12 bits per pixel). The dcraw source translates badly to Java. You haven't seen such a nightmare of bit-fiddling ever. Took me days to debug problems with byte alignment and endian-ness.
jrawio is a plugin for Java Image I/O. With it you can read the raster data, the thumbnails and the metadata from the raw image file.
nef and cr2 already contains preview images in jpeg. just find the right offset and the right length to extract it...
Laurent Clevy # lclevy.free.fr/raw
Laurent
Unless you want to write you own file parser/loader (sounds fun imho ;) ), perhaps JMagick will help you. I haven't tried it and it might not work given your target platform since JMagick uses JNI.
UPDATE: dcraw looks like a good resource/reference

Categories

Resources