0

I have the following code that reads a video file from the camera roll which works perfectly fine

Scene *scene = [_sceneArray objectAtIndex:0];
NSString *path = scene.src_url;
NSURL *full_url = [[NSURL alloc] initFileURLWithPath:path];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:full_url options:nil];
AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];

However, when i try to extract just the audio of a given video file using the following code, the application force closes (with array out of bound exception)

audioTrack = [[asset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
David Ansermot
  • 6,052
  • 8
  • 47
  • 82
Yrol
  • 159
  • 4
  • 17
  • So.... what does the debugger or `NSLog` tell you about the contents of that array you're looking into? How about some error checking? Array lengths checks? – cacau Oct 06 '14 at 11:42
  • The array is empty and it throws "*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array", the sound clip does contain in the "audioTrack". – Yrol Oct 07 '14 at 04:34
  • Maybe the sound is not contained in the file – gabbler Oct 07 '14 at 06:34
  • @CarouselMin, there is sound in the video file, I can confirm that. – Yrol Oct 07 '14 at 06:57

0 Answers0