Create movies in Java

Discussion in 'Java' started by Ross Clement (Email address invalid - do not use), Jan 1, 2006.

  1. 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
    Ross Clement (Email address invalid - do not use), Jan 1, 2006
    #1
    1. Advertising

  2. Ross Clement (Email address invalid - do not use)

    Bruce Lee Guest

    "Ross Clement (Email address invalid - do not use)" <>
    wrote in message
    news:...
    > 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"
    Bruce Lee, Jan 1, 2006
    #2
    1. Advertising

  3. Bruce Lee wrote:

    > "Ross Clement (Email address invalid - do not use)" <>
    > wrote in message
    > news:...
    >
    >>Hi. I would like to be able to create movie files from inside Java.

    ....
    > 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

    --
    Andrew Thompson
    physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
    Andrew Thompson, Jan 4, 2006
    #3
  4. 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
    Ross Clement (Email address invalid - do not use), Jan 4, 2006
    #4
  5. Ross Clement (Email address invalid - do not use) wrote:

    > 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! ;-)

    --
    Andrew Thompson
    physci, javasaver, 1point1c, lensescapes - athompson.info/andrew
    Andrew Thompson, Jan 4, 2006
    #5
  6. Ross Clement (Email address invalid - do not use)

    Guest

    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.


    http://www.geocities.com/opalpaweb/
    , Jan 4, 2006
    #6
  7. Ross Clement (Email address invalid - do not use)

    Guest

    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.


    http://www.geocities.com/opalpaweb/
    , Jan 4, 2006
    #7
  8. Ross Clement (Email address invalid - do not use)

    Roedy Green Guest

    On 4 Jan 2006 07:22:08 -0800, "" <>
    wrote, quoted or indirectly quoted someone who said :

    >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.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
    Roedy Green, Jan 4, 2006
    #8
  9. 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
    Ross Clement (Email address invalid - do not use), Jan 4, 2006
    #9
  10. 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
    Ross Clement (Email address invalid - do not use), Jan 4, 2006
    #10
  11. Ross Clement (Email address invalid - do not use)

    Guest

    Skip jpeg by specifing RGBFormat, convert BufferedImage to Buffer with
    javax.media.util.ImageToBuffer.createBuffer, set descriptor to
    ContentDescriptor.RAW.

    Cheers,

    http://www.geocities.com/opalpaweb/
    , Jan 5, 2006
    #11
  12. Ross Clement (Email address invalid - do not use)

    Oliver Wong Guest

    "Roedy Green" <> wrote in
    message news:...
    > On 4 Jan 2006 07:22:08 -0800, "" <>
    > wrote, quoted or indirectly quoted someone who said :
    >
    >>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.


    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
    Oliver Wong, Jan 10, 2006
    #12
  13. Ross Clement (Email address invalid - do not use)

    pernyblom

    Joined:
    Mar 8, 2009
    Messages:
    1
    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.
    pernyblom, Mar 8, 2009
    #13
  14. Ross Clement (Email address invalid - do not use)

    digithree

    Joined:
    Feb 8, 2012
    Messages:
    1
    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
    digithree, Feb 8, 2012
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will
    Replies:
    0
    Views:
    1,893
  2. movies

    , May 12, 2005, in forum: Java
    Replies:
    1
    Views:
    433
    ted holden
    May 12, 2005
  3. EightNineThree
    Replies:
    3
    Views:
    410
    Whitecrest
    Aug 24, 2003
  4. yk
    Replies:
    7
    Views:
    553
  5. nick
    Replies:
    5
    Views:
    4,478
    kayodeok
    Jan 11, 2004
Loading...

Share This Page