トーキングトムのようなアプリを開発しています。iPhoneの画面をタッチすると、音付きの犬のアニメーションが生成されます。そのために、iPhoneの画面のビデオ録画以外はすべて実装しました。ここに基づいてiPhoneの画面のビデオ録画を実装しました..記録しました動画ファイルに音声を含めるにはどうすればよいですか?サンプル コードはありますか?
cocos2Dでアプリを開発するならこちらのサンプルコードが役に立ちます!
トーキングトムのようなアプリを開発しています。iPhoneの画面をタッチすると、音付きの犬のアニメーションが生成されます。そのために、iPhoneの画面のビデオ録画以外はすべて実装しました。ここに基づいてiPhoneの画面のビデオ録画を実装しました..記録しました動画ファイルに音声を含めるにはどうすればよいですか?サンプル コードはありますか?
cocos2Dでアプリを開発するならこちらのサンプルコードが役に立ちます!
AVFoundation フレームワークで AVAudioRecorder を使用します。AVFoundation フレームワークをインポートし、AVAudioRecorderDelegate に準拠 AVAudioRecorder インスタンスと NSURL インスタンスを作成 **サンプル コード
録音:
[audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; // assign it to recording session
[audioSession setActive:YES error:nil]; // activate it!
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue: [NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey]; // assign this special hardware component as the function to record
[recordSetting setValue:[NSNumber numberWithFloat:44100.0]
forKey:AVSampleRateKey]; //44100 is the sample rate
[recordSetting setValue:[NSNumber numberWithInt: 2]
forKey:AVNumberOfChannelsKey]; // same thing
tmpFile = [NSURL fileURLWithPath:
[NSTemporaryDirectory() stringByAppendingPathComponent:
[NSString stringWithFormat: @"%.0f.%@",
[NSDate timeIntervalSinceReferenceDate] * 1000.0,
@"caf"]]]; // how we identify the audio written to the file to play later
recorder = [[AVAudioRecorder alloc] initWithURL:tmpFile settings:recordSetting
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
遊ぶ:
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];
[audioSession setActive:YES error:nil];
AVAudioPlayer * player =
[[AVAudioPlayer alloc] initWithContentsOfURL:tmpFile error:nil]; // takes recording data from tmpFile where we wrote the recording in
[player prepareToPlay];
[player play];
それはほんの一部のサンプルコードです....あなたを助けるために、それ以外の場合はドキュメントを読んでください口をアニメートする方法やピッチを変更したい場合はわかりませんが、これは録音の始まりです