Create movies in Java

  • Thread starter Ross Clement (Email address invalid - do not use)
  • Start date
R

Ross Clement (Email address invalid - do not use)

Hi. I would like to be able to create movie files from inside Java. I
would like to draw the movie frame by frame using standard Java
graphics and image classes, then write it out to an external file. I
would then use external tools such as ffmpeg to compress/reformat/add
audio to the movie, so the format by which it would be written from
Java is not that important.

I presume this is possible, but can't find any sample code or
tutorials. I can find huge numbers of tutorials about how to play back
movie files in Java, some on transcoding etc., but nothing on
authoring.

Any hints/pointers?

Thanks in anticipation,

Ross-c
 
B

Bruce Lee

"Ross Clement (Email address invalid - do not use)" <[email protected]>
wrote in message
Hi. I would like to be able to create movie files from inside Java. I
would like to draw the movie frame by frame using standard Java
graphics and image classes, then write it out to an external file. I
would then use external tools such as ffmpeg to compress/reformat/add
audio to the movie, so the format by which it would be written from
Java is not that important.

I presume this is possible, but can't find any sample code or
tutorials. I can find huge numbers of tutorials about how to play back
movie files in Java, some on transcoding etc., but nothing on
authoring.

Any hints/pointers?

Thanks in anticipation,

Ross-c

google "java jmf"
 
A

Andrew Thompson

Bruce said:
"Ross Clement (Email address invalid - do not use)" <[email protected]>
wrote in message
....
google "java jmf"

There is a sample app. that comes with the JMF called..
'JpegImagesToMovie' to convert a series of .jpg files to
Quicktime .mov format.

It has come in quite handy here, allowing me to create time-lapse
animations from any series of pictures. [ I then (am currently)
use ImTOO Avi/Mpeg Converter to change the .mov to .mpg format,
though it sounds as if you have that side covered. ]

For simple examples of dealing with images, check the
code samples available on Marco Shmidt's site, here..
<http://schmidt.devlib.org/java/image-file-code-examples.html>

HTH
 
R

Ross Clement (Email address invalid - do not use)

Thanks for the feedback. I've downloaded the source to
JpegImagesToMovie.java and it *should* be easy for me to adapt it for
my needs. As the movies I will be creating are very large (1/4 hour to
1 hour) I think that it won't be feasible to dump an image sequence and
convert, so I'll be hacking the code to store directly as quicktime.

Cheers,

Ross-c
 
A

Andrew Thompson

Ross said:
Thanks for the feedback. I've downloaded the source to
JpegImagesToMovie.java and it *should* be easy for me to adapt it for
my needs. As the movies I will be creating are very large (1/4 hour to
1 hour) I think that it won't be feasible to dump an image sequence and
convert, so I'll be hacking the code to store directly as quicktime.

You might be right, that is much longer than the 61-62 second
anims. I've done, but OTOH they are at 2304x1728 px and end up
around a 1/4 Gig in size!. I'd recommend testing it first.
[ There are also command line args. you can use to increase
the memory available to a Java process. ]

...ohh, but I did hack the JITM source myself to accept a directory,
and simply add all .jpg files in name order - I was not about to
specify 300-600 image names on the command line! ;-)
 
O

opalpa

Here are a couple of things I learned doing this deed -- making
BufferedImage instances and then sequencing them into a Quicktime
movie:

# It's not all that easy. One thing that will be frustrating is that
the Processor is asychronous. That is you cannot loop through your
images and pass each image to the processor. You'll have to use the
asynch calls and call backs. From the perspective of making movies
from BufferedImage instances this seems like an idiocy. The
explanation is that JMF is intended for playback. With that in mind
things like asynchronicity are standard in video packages. If you're
not comfortable with wait() and notify() methods that are part of
Object you'll feel some frustration, I anticipate.

# I have had all kinds of exceptions when trying to simulatenously read
multiple movies with JMF. I guess they use some file statics. Anyway
the JMF is a little away from a robust system.

# The movies are big!


Cool stuff is possible. Here is a program I made: given a google query
go out to web and query google. For all links on first page of results
get the content of each of the webpages. After getting the content of
each of the pages find all image links. For image links that appear to
be content (instead of spacers, buttons, etc) combine them ihnto the
movie. It's kind of fun to pick something "juggling midgets", "warner
brothers cartoons", "big tits" and get a Quicktime movie.

I also made some stuff where I render images, like a countdown, and
generate a Quicktime mov that I can put into video productions.

(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
O

opalpa

Here are a couple of things I learned doing this deed -- making
BufferedImage instances and then sequencing them into a Quicktime
movie:

# It's not all that easy. One thing that will be frustrating is that
the Processor is asychronous. That is you cannot loop through your
images and pass each image to the processor. You'll have to use the
asynch calls and call backs. From the perspective of making movies
from BufferedImage instances this seems like an idiocy. The
explanation is that JMF is intended for playback. With that in mind
things like asynchronicity are standard in video packages. If you're
not comfortable with wait() and notify() methods that are part of
Object you'll feel some frustration, I anticipate.

# I have had all kinds of exceptions when trying to simulatenously read
multiple movies with JMF. I guess they use some file statics. Anyway
the JMF is a little away from a robust system.

# The movies are big!


Cool stuff is possible. Here is a program I made: given a google query
go out to web and query google. For all links on first page of results
get the content of each of the webpages. After getting the content of
each of the pages find all image links. For image links that appear to
be content (instead of spacers, buttons, etc) combine them ihnto the
movie. It's kind of fun to pick something "juggling midgets", "warner
brothers cartoons", "big tits" and get a Quicktime movie.

I also made some stuff where I render images, like a countdown, and
generate a Quicktime mov that I can put into video productions.

(e-mail address removed)
http://www.geocities.com/opalpaweb/
 
R

Roedy Green

Here are a couple of things I learned doing this deed -- making
BufferedImage instances and then sequencing them into a Quicktime
movie:

Here is one problem you may run into that I had with a streaming
protocol for JPG images. When the compressor does each image, it
compresses it in isolation from the other images. It is happy to get
the colours just a tad off. However, it gets them a tad off on each
frame in a slightly different way. If you look at a series, you don't
gave consistent colours. This is acceptable for a security camera,
but may not be for advertising.

To solve that you would have to start from something with accurate
colours, maybe giant TIFFs. and somehow compress them in a consistent
way frame to frame. MP3 encoders likely know how to handle this.
 
R

Ross Clement (Email address invalid - do not use)

Thanks to everyone who replied on this thread.

I have hacked a modified version of the JpegImagesToMovie code into my
program. Provided that I encode (using Sun's JPEGImageEncoder class) by
images (BufferedImage) as JPEGs before returning them as output from my
PullBufferStream.read( ) method, then I get a good QuickTime movie as
output that I can play using mplayer and reformat using ffmpeg.

However, I tried to avoid converting my images to JPEGs first by using
RGBFormat. After some trial and error hacking, I made the code write a
quicktime file. However when I tried to play it back, the programs
didn't like the movie and refused to do anything with it.

My application is a very primitive "electronic whiteboard" type
program. I basically record a stream of mouse movements (actually pens
on a touch-screen enabled plasma screen) and can play them back. I
wanted to be able to dump the result as a movie for mixing with the
sound I record of me talking while writing. So visual quality isn't a
massive problem provided that people can read what I am writing.
However, I can see the "jpegginess" of the image even in the original
not very compressed movie. I'm going to try setting the JPEG quality
higher than the default (whatever that was) and see if that helps.

But, if possible, I would like to remove the conversion to JPEG
intermediate step. Can anyone recommend an alternative format I could
use, or point me to any references on how I can get the RGB format to
work?

Cheers,

Ross-c
 
R

Ross Clement (Email address invalid - do not use)

PS: Setting the quality of the JPEGEncoder object to 1.0 improved
things considerably. But I would still like to know how to avoid
encoding to a JPEG.

Cheers,

Ross-c
 
O

Oliver Wong

Roedy Green said:
Here is one problem you may run into that I had with a streaming
protocol for JPG images. When the compressor does each image, it
compresses it in isolation from the other images. It is happy to get
the colours just a tad off. However, it gets them a tad off on each
frame in a slightly different way. If you look at a series, you don't
gave consistent colours. This is acceptable for a security camera,
but may not be for advertising.

To solve that you would have to start from something with accurate
colours, maybe giant TIFFs. and somehow compress them in a consistent
way frame to frame. MP3 encoders likely know how to handle this.

As long as your image format is lossless, you shouldn't have any
problems with compression artefacts. PNG, BMP, etc. would work just as well
as TIFF.

You should probably leave the compressing to the codecs, rather than
"doing it yourself". In fact, if you try to do your own compression, and
then pass it to a codec, you may make the codec's job harder, particularly
if your compression is lossy. The codec won't be able to tell what are
artefacts introduced via lossy compression, and what is significant detail
to reproduce in the video stream.

- Oliver
 
Joined
Mar 8, 2009
Messages
1
Reaction score
0
AVIOutputStream

I found a Java class that is supposed to encode AVI files without JMF in an application called "CubeTwister". I have not tested it yet but it might be worth checking out. The source code looks OK as well.

Just search for CubeTwister and you find it (tried to add a link but I am not allowed due to the 50 post threshold).

Check out the AVIOutputStream class.
 
Joined
Feb 8, 2012
Messages
1
Reaction score
0
Hi, I know this thread is really old but since it came up near the top in a Google search on JMF I'm going to add a bit of new knowledge to it that would have helped me out about a week ago.

There's a great library package called Xuggle that does exactly what this guy wanted to do, create a video out of static images. It's much easier to use than JMF and actually current and supported.

http://www.xuggle.com/xuggler/

Here's a tutorial on how to create a video from screenshots of your desktop:
http://wiki.xuggle.com/MediaTool_Introduction#How_To_Take_Snapshots_Of_Your_Desktop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top