iPhone에서 avassetwriter를 사용하여 오디오를 비디오에 기록하는 데 문제가 있습니다. 나는 카메라의 비디오를 아무런 문제없이 카메라에 녹화 할 수 있지만 오디오를 추가하려고 할 때 아무것도 얻지 못한다. 또한 사진 앨범 앱의 비디오에 표시된 시간이 너무 길어서 4 초짜리 비디오가 15시 54 분 01 초 또는 그와 비슷한 것으로 표시하고 비디오가 더 짧아도 숫자가 증가한 후에 만들어진 모든 비디오를 표시합니다. 나는 여기에서 다른 질문에서 보인 ive를 따르려고 노력했지만 행운은 없다. Heres는 내가AVAssetWriter가 오디오를 녹음하지 않습니다.
captureSession = [[AVCaptureSession alloc] init];
//set up audio input
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio];
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error ];
audioOutput = [[AVCaptureAudioDataOutput alloc] init];
if([captureSession canAddOutput:audioOutput])
{
[captureSession addOutput:audioOutput];
}
[audioOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
을 heres 내 오디오 입력 설정하고있어 어떻게 여기에 다음
videoWriter = [[AVAssetWriter alloc] initWithURL:[NSURL fileURLWithPath:MOVIE_PATH] fileType:AVFileTypeQuickTimeMovie error:&error];
AudioChannelLayout acl;
bzero(&acl, sizeof(acl));
acl.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
NSDictionary* audioOutputSettings = audioOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
[ NSNumber numberWithInt: 1 ], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSData dataWithBytes: &acl length: sizeof(acl) ], AVChannelLayoutKey,
[ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey,
nil];
와는 CMSampleBufferRef를 사용하여 오디오 샘플 버퍼를 작성 메신저 전송되는 방법 메신저 설정까지 AVAssetWriter을
audioOutput 콜백에 의해
- (void) captureAudio:(CMSampleBufferRef)sampleBuffer
{
if([audioWriterInput isReadyForMoreMediaData]){
[audioWriterInput appendSampleBuffer:sampleBuffer];
}
}
정말 고맙겠습니다. 어떤 도움이든지, 나는 하루 종일 붙어 있었어.
답변을 찾았습니까? –