我想从youtube中提取音频。我从 adaptive_mmts 参数中的youtube观看页面获得audio URL。
我正在使用NSURLConnection
NSURLRequest * audioRequest = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]];
audioConnection = [[NSURLConnection alloc] initWithRequest: audioRequest delegate: self];
但问题是下载的文件在iOS8上播放,与原始文件相比具有两倍的持续时间,但在iOS7上无法播放。对于播放音频我正在使用此代码
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"audio_1" ofType:@"m4a"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:filePath]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playBackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
moviePlayer.view.frame = CGRectMake(10, 100, 300, 200);
[self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
我使用终端
获取音频文件的信息> File: filepath File type ID: mp4f Num Tracks: 1
> ---- Data format: 2 ch, 44100 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
> Channel layout: Stereo (L R) estimated duration: 180.464036 sec audio
> bytes: 0 audio packets: 7774 bit rate: 0 bits per second packet size
> upper bound: 0 maximum packet size: 0 audio data file offset: 3544 not
> optimized audio 7958464 valid frames + 2112 priming + 0 remainder =
> 7960576 format list: [ 0] format: 2 ch, 44100 Hz, 'aac '
> (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0
> bytes/frame Channel layout: Stereo (L R)
显示比特率和音频咬合为零。我被困在这里。任何帮助将不胜感激。