Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 22nd, 2007, 1:29 AM   #1
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
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
rwm is offline   Reply With Quote
Old Nov 22nd, 2007, 9:18 AM   #2
null_ptr0
11 years old
 
Join Date: Nov 2007
Posts: 79
Rep Power: 1 null_ptr0 is on a distinguished road
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.
null_ptr0 is offline   Reply With Quote
Old Nov 23rd, 2007, 1:09 AM   #3
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
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!
rwm is offline   Reply With Quote
Old Nov 25th, 2007, 7:13 PM   #4
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Re: convert image sequence to quicktime movie

Have you considered using JMF?
Harakim is offline   Reply With Quote
Old Nov 26th, 2007, 1:15 AM   #5
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
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!
rwm is offline   Reply With Quote
Old Nov 27th, 2007, 2:08 PM   #6
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
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.
Harakim is offline   Reply With Quote
Old Nov 27th, 2007, 3:43 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 27th, 2007, 5:07 PM   #8
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Re: convert image sequence to quicktime movie

Quote:
Originally Posted by DaWei View Post
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.
Harakim is offline   Reply With Quote
Old Nov 27th, 2007, 6:21 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 28th, 2007, 1:05 AM   #10
rwm
Professional Programmer
 
Join Date: Jan 2007
Location: Cape Town
Posts: 291
Rep Power: 2 rwm is on a distinguished road
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!
rwm is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image float, wrap text, oh boy! DaveQB HTML / XHTML / CSS 1 May 20th, 2006 12:34 AM
Image Viewer (Urgent Bèta testing) SoniX Visual Basic .NET 8 Sep 21st, 2005 5:25 PM
raw image conversion jasoncrab C++ 1 Aug 25th, 2005 10:11 PM
Rent a movie. Broax Coder's Corner Lounge 13 Jul 24th, 2005 1:44 PM
Checking source codes of image, audio and video files on_auc C++ 3 Feb 21st, 2005 8:36 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:46 PM.

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