0

have been working on the AVMutableComposition to mix audio file with video,

For the part of insert the audio at video time 0, am using this

AVMutableCompositionTrack *a_compositionVideoTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[a_compositionVideoTrack insertTimeRange:video_timeRange ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];

My challenge now is to let the user pick the video time range he want the audio in !! have no idea how this works with the CMTimeMake and if there is any smoothy picker already done

Thanks for helping !!

1 Answers1

1
CMTimeMake(value,timescale)

value - as usual, amount of quantums (for example, seconds) timescale - length of this quantum in seconds

CMTimeMake(1,30) // one interval of 30 sec
CMTimeMake(30,1) // 30 intervals of 1 sec

In fact it is the same absolute time, But it has different granularity, which is important when you deal with audio and video file processing.

  • Thanks, this was helpful, now am facing another problem – Hasan Samir Hashem Nov 17 '16 at 14:16
  • After mixing the MP3 file with my video using this method, the original video sound got muted !! i need actually to play the video sound with my mp3? What do you think? – Hasan Samir Hashem Nov 17 '16 at 14:17
  • Mixing audio and video requires much more code. You need to extract video track from one file, and extract audio track from the same file. Then you should create new composition with one video and two audiotracks, put time range for ALL three tracks. – Vladimir Vodolazkiy Nov 17 '16 at 14:23