January 2005
Intermediate to advanced
256 pages
6h 34m
English
Often, it makes sense to perform edits on all tracks of a movie. But for serious editing applications, sometimes you need to work at the track level, to add and remove tracks, or to work on just one track in isolation from the others. This task will provide a taste of that by adding a second audio track to a movie.
The AddAudioTrackQTEditor builds on
FlattenableQTEditor by adding another Add Audio
Track... menu item, calling the doAddAudioTrack( )
method:
public void doAddAudioTrack( ) throws QTException { // ask for an audio file QTFile audioFile = QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes); OpenMovieFile omf = OpenMovieFile.asRead (audioFile); Movie audioMovie = Movie.fromFile (omf); // find the audio track, if any Track audioTrack = audioMovie.getIndTrackType (1, StdQTConstants.audioMediaCharacteristic, StdQTConstants.movieTrackCharacteristic); if (audioTrack = = null) { JOptionPane.showMessageDialog (this, "Didn't find audio track", "Error", JOptionPane.ERROR_MESSAGE); return; } // now make new audio track and insert segment // from the loaded track Track newTrack = movie.newTrack (0.0f, // width 0.0f, // height audioTrack.getVolume( )); // ick, need a dataref for our "new" media // http://developer.apple.com/qa/qtmtb/qtmtb58.html SoundMedia newMedia = new SoundMedia (newTrack, audioTrack.getMedia( ).getTimeScale( ), new DataRef (new QTHandle( ))); newTrack.getMedia( ).beginEdits( ); audioTrack.insertSegment (newTrack, 0, audioTrack.getDuration( ...Read now
Unlock full access