We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
MovieMaker and audio (Read 912 times)
MovieMaker and audio
Feb 8th, 2008, 12:29pm
 
Hi guys

I'm making a little app that composites a bunch of images together as a quicktime move using the MovieMaker class. Is there a way of adding an audio track?

It needs to be done programmatically ie not boot up Premiere or Final Cut and add it.


thanks
Gareth
Re: MovieMaker and audio
Reply #1 - Aug 11th, 2008, 9:41pm
 
I'm reviving this thread since it's difficult to figure this out in Quicktime for Java (QTJ). The book "Quicktime for Java: a developer's notebook" (Chris Adamson) helped a lot. Here's the program (nasty, huh?):

Code:

package com.audeto.utils;

import quicktime.*;
import quicktime.app.view.QTFactory;
import quicktime.io.*;
import quicktime.std.image.*;
import quicktime.std.movies.media.*;
import quicktime.std.movies.*;
import quicktime.std.*;
import quicktime.qd.*;
import quicktime.util.QTPointer;
import quicktime.util.QTHandle;

import java.io.*;

public class AudioAdder {


public static void main(String args[]) {



if (args.length != 3) {




System.out





.println("Usage: java AudioAdder [movie_filename] [audio_filename] [out_filename]");



} else {




try {




QTSession.open();





System.out.println("QuickTime version: "






+ QTSession.getMajorVersion() + "."






+ QTSession.getMinorVersion());





// create the movie




QTFile qtfile = new QTFile(new File(args[0]));




DataRef urlMovie = new DataRef("file://" + qtfile.getPath());




Movie movie = Movie.fromDataRef(urlMovie,






StdQTConstants.newMovieActive);





// create the audio movie




QTFile audioFile = new QTFile(new File(args[1]));




DataRef urlAudio = new DataRef("file://" + audioFile.getPath());




Movie audioMovie = Movie.fromDataRef(urlAudio,






StdQTConstants.newMovieActive);





// retrieve the audio track from the audio movie




Track audioTrack = audioMovie.getIndTrackType(1,






StdQTConstants.audioMediaCharacteristic,






StdQTConstants.movieTrackCharacteristic);





if (audioTrack == null) {





System.out.println("Didn't find audio track");





return;




}





// create a new track within the movie




// max volume is 1




Track newTrack = movie.newTrack(0.0f, 0.0f, 1);





// create a new media within the new track




SoundMedia newMedia = new SoundMedia(newTrack, audioTrack






.getMedia().getTimeScale(), new DataRef(new QTHandle()));





newTrack.insertMedia(0, 0, audioTrack.getDuration(), 1);





newMedia.beginEdits();





// add the existing audio track to the newTrack




audioTrack.insertSegment(newTrack, 0, audioTrack.getDuration(),






0);





newMedia.endEdits();





// create the movie




QTFile outfile = new QTFile(new File(args[2]));








movie






.flatten(








StdQTConstants.flattenAddMovieToDataFork |








StdQTConstants.flattenForceMovieResourceBeforeMovieData,








outfile, StdQTConstants.kMoviePlayer,








IOConstants.smSystemScript,








StdQTConstants.createMovieFileDeleteCurFile,








StdQTConstants.movieInDataForkResID, null);




} catch (Exception e) {




e.printStackTrace();




QTSession.close();




System.exit(0);



}




QTSession.close();




// end else


}



System.out.println("complete.");



// end method

}
}




Re: MovieMaker and audio
Reply #2 - Aug 11th, 2008, 10:11pm
 
ooh that looks a bit hard.

I completely forgot about posting the question. If it helps anybody we used MPlayer from the command line to add audio to a video file.

Sorry for the late posting of our solution.

Page Index Toggle Pages: 1