Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   convert image sequence to quicktime movie (http://www.programmingforums.org/showthread.php?t=14555)

rwm Nov 22nd, 2007 1:29 AM

convert image sequence to quicktime movie
 
Hi,

I'm using the Quicktime for Java API, and I'm having trouble with an application I'm working on.

Basically, I need to take an image sequence, and convert that sequence to a quicktime movie. I need to do that from the command line, not sure if that's possible?

I've written all the code that manages the application, gets a list of ordered files to use for the sequence, pretty much 95% is done, but I just can't convert the sequence to quicktime!!!

I can do this:

:

private ArrayList<QTFile> files;

...

QTSession.open();
QTFile outFile = new QTFile(outFileTmp);
files.get(0).convertToMovieFile(outFile,0,0);
QTSession.close();


Which works fine for creating a *.mov that just has a single image...

The Quicktime for Java documentation is very hard to decipher! Most of the code is deprecated!!!

Hope someone can help! Any responses would be greatly appreciated!

Thanks!

Rich

null_ptr0 Nov 22nd, 2007 9:18 AM

Re: convert image sequence to quicktime movie
 
http://lists.apple.com/archives/Quic.../msg00056.html
This is the same question, and it seems to also have an answer.

rwm Nov 23rd, 2007 1:09 AM

Re: convert image sequence to quicktime movie
 
Hey man!

Thanks, that was helpful! Made some progress, but i've still got a problem getting this to work!

:

        //create movie file from sequence.
        QTSession.open();
       
        ImageInfo ii = ImageUtils.create(tmpFiles[0]);
        BufferedImage bi = (BufferedImage)ii.image;
        System.out.println("Image: (" + bi.getWidth() + "," + bi.getHeight() + ")");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
        JPEGEncodeParam jpegParams = encoder.getDefaultJPEGEncodeParam(bi);
        jpegParams.setQuality(1.0f,false);
        encoder.encode(bi);
        byte[] dataBytes = bos.toByteArray();
       
        //test
        QTHandle qtHandle = new QTHandle(dataBytes);
        Movie movie = Movie.fromHandle(qtHandle);
        movie.convertToFile(new QTFile("c:\\tmp\\qthandle_test.mov"),0,0,0);
       
        QTSession.close();


Compiles with a few warnings (the com.... packages), but when I run this is the output:

:

quicktime.std.StdQTException[QTJava:7.3.0g],-2002=badPublicMovieAtom,QT.vers:7308000
        at quicktime.std.StdQTException.checkError(StdQTException.java:38)
        at quicktime.std.movies.Movie.fromHandle(Movie.java:252)
        at quicktime.std.movies.Movie.fromHandle(Movie.java:222)
        at daily.ComposeDaily.<init>(ComposeDaily.java:89)
        at Daily.main(Daily.java:79)


Hope you can help! Thanks!

Harakim Nov 25th, 2007 7:13 PM

Re: convert image sequence to quicktime movie
 
Have you considered using JMF?

rwm Nov 26th, 2007 1:15 AM

Re: convert image sequence to quicktime movie
 
Hey Harakim,

Thanks for the reply!

Well, I found a sample application that used JMF, i'll take another look at it!

I've made quite a bit of progress with the quicktime app, I can open the movie file, but nothing is displayed...

:

        Image image = ...

        BufferedImage bi = (BufferedImage)image;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(bos);
        JPEGEncodeParam jpegParams = encoder.getDefaultJPEGEncodeParam(bi);
        jpegParams.setQuality(1.0f,false);
        encoder.encode(bi);
        byte[] dataBytes = bos.toByteArray();
       
        QTFile movFile = new QTFile(new java.io.File("c:\\tmp\\A_NEW_FILE.mov"));
        Movie movie = Movie.createMovieFile(movFile,StdQTConstants.kMoviePlayer,
                                            StdQTConstants.createMovieFileDeleteCurFile |
                                            StdQTConstants.createMovieFileDontCreateResFile);
        int timeScale = 1;
        Track videoTrack = movie.addTrack(width,height,0);
        VideoMedia videoMedia = new VideoMedia(videoTrack,timeScale);
        videoMedia.beginEdits();
       
        ImageDescription imgDesc = new ImageDescription(QDConstants.k32ARGBPixelFormat);
        imgDesc.setWidth(width);
        imgDesc.setHeight(height);
       
        QTHandle imageHandle = new QTHandle(dataBytes.length,true);
        imageHandle.lock();
       
        videoMedia.addSample(imageHandle,0,dataBytes.length,1,imgDesc,1,0);
       
        videoMedia.endEdits();
       
        videoTrack.insertMedia(0,0,videoMedia.getDuration(),1);
        OpenMovieFile omf = OpenMovieFile.asWrite(movFile);
        movie.addResource(omf,StdQTConstants.movieInDataForkResID,movFile.getName());
       
        QTSession.close();


Not sure why, but I suspect that it's the way I'm creating the image?

Hope someone can help! Will look at the JMF now!

Thanks!

Harakim Nov 27th, 2007 2:08 PM

Re: convert image sequence to quicktime movie
 
I don't have time to look at this now, unfortunately. How time sensitive is this? I can probably rig up some code that does this in JMF if that's ok.

DaWei Nov 27th, 2007 3:43 PM

Re: convert image sequence to quicktime movie
 
We're sorry that you have the defiite answer, but don't have time to explain. Life sucks, and so do fakers.

Harakim Nov 27th, 2007 5:07 PM

Re: convert image sequence to quicktime movie
 
Quote:

Originally Posted by DaWei (Post 137657)
We're sorry that you have the defiite answer, but don't have time to explain. Life sucks, and so do fakers.

What are you willing to bet on that? I wasn't about to start writing 200 lines of JMF code if he needs to use the QT library.

DaWei Nov 27th, 2007 6:21 PM

Re: convert image sequence to quicktime movie
 
I don't have an answer for the OP. Do you? If so, give it. If you don't have time, why are you effing around here? Get back to work.

rwm Nov 28th, 2007 1:05 AM

Re: convert image sequence to quicktime movie
 
Hey guys!

Chill! No, it's still a problem. It's also fairly urgent as well!

I downloaded the JMF sample, "JpegImagesToMov" - compiled, seemed fine. Then I ran it with this command:

:

-w 640 -h 480 -f 24 -o c:\tmp\OUTPUT.mov c:\tmp\cube_seq\cube_test.001.jpg

I got this error:

:

init:
deps-jar:
compile:
run:
- create processor for the image datasource ...
Setting the track format to: JPEG
- create DataSink for: c:\tmp\OUTPUT.mov
Cannot create the DataSink: javax.media.NoDataSinkException: Cannot find a DataSink for: com.sun.media.multiplexer.BasicMux$BasicMuxDataSource@186d4c1
Failed to create a DataSink for the given output MediaLocator: c:\tmp\OUTPUT.mov
BUILD SUCCESSFUL (total time: 0 seconds)


I'm quite happy to solve this problem on my own! Thanks for the kind offer though, but I can't accept it!

I think my main problem is that I'm new to Java, and I don't understand about converting an image to a byte array...

Hope you will be able to help!

Thanks!


All times are GMT -5. The time now is 12:54 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC