Search code examples
c++macosquicktime

Copy QuickTime audio to another QuickTime movie


I'm trying to copy a section of audio from one QuickTime movie to another one but without success; the audio doesn't seem to be copied.

C++ basic code:

// Copy from another QT movie, *src, to this one
soundTrack = NewMovieTrack(myMovie, 0, 0, kFullVolume);
soundMedia = NewTrackMedia(soundTrack, SoundMediaType,
                           GetMediaTimeScale(src->soundMedia), NULL, 0);

BeginMediaEdits(soundMedia);
InsertTrackSegment(src->soundTrack, soundTrack, 0,
                   GetMediaDuration(src->soundMedia), 0);
EndMediaEdits(soundMedia);

I don't want to transcode the sound, just copy the encoded sound frames across. I realise this basic code will copy all of the sound frames in the movie.

I am doing some other editing with the video file so I don't want to go through QTKit if I can possibly help it.


Solution

  • The code is good, I can get sound using it. I made some mistake in another part and ended up selecting the wrong source sequence for the sound. Sorry about that.