小编der*_*iuk的帖子

此代码通过AVAssetWriter和AVAssetWriterInputs写入视频+音频不起作用.为什么?

我一直在尝试使用AVAssetWriter和AVAssetWriterInputs编写视频+音频.

我在这个论坛上看了很多人说他们能够做到这一点,但这对我不起作用.如果我只是写视频,那么代码就能很好地完成它的工作.当我添加音频时,输出文件已损坏且无法再现.

这是我的代码的一部分:

设置AVCaptureVideoDataOutput和AVCaptureAudioDataOutput:

NSError *error = nil;

// Setup the video input
AVCaptureDevice *videoDevice = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo];
// Create a device input with the device and add it to the session.
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:videoDevice error:&error];
// Setup the video output
_videoOutput = [[AVCaptureVideoDataOutput alloc] init];
_videoOutput.alwaysDiscardsLateVideoFrames = NO;
_videoOutput.videoSettings =
[NSDictionary dictionaryWithObject:
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey];     

// Setup the audio input
AVCaptureDevice *audioDevice     = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeAudio];
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error ];     
// Setup the …
Run Code Online (Sandbox Code Playgroud)

iphone audio video avassetwriter

63
推荐指数
2
解决办法
4万
查看次数

AudioFileWriteBytes(AudioToolbox)失败,错误代码为-38 kAudioFileNotOpenError

我正在研究记录用户音频的应用程序,使用数据写入文件AudioToolbox并处理这些数据.在分析中,我看到AudioToolbox录制中发生了很多错误.其中几乎一半是-38 kAudioFileNotOpenErrorAudioFileWriteBytes()通话中返回的错误.

现在似乎没有任何理由发生这种情况:用户开始录制,一切顺利,然后连续10-80次记录错误.在分析中,没有用户操作,例如转到后台或暂停录制(我们有此功能).

我在线研究了信息,但没有找到有关错误的更多信息.

我发布了所有录制代码(带有剥离的未使用或分析代码),因为除了-38 kAudioFileNotOpenError我有一堆其他错误,这可能意味着我可能以AudioToolbox错误的方式使用.以下是最重要的错误:

  1. AudioFileWriteBytes()返回-38 kAudioFileNotOpenError错误:( [1]代码中) - 约50%的错误
  2. AudioUnitRender()返回-10863 kAudioUnitErr_CannotDoInCurrentContext错误([2]代码中) - ~5%
  3. AudioFileWriteBytes()返回1868981823 kAudioFileDoesNotAllow64BitDataSizeError错误:( [1]代码中) - ~4%
  4. AudioUnitRender()返回-1错误([2]代码中) - ~3%

任何帮助,评论或建议将非常有帮助!

这是代码(它也可以在GitHub上找到:https://github.com/derpoliuk/SO-AudioToolbox-error-quesion):

class Recorder {

    static let shared = Recorder()
    private static let sampleRate: Float64 = 16000

    var processAudioData: ((Data) -> ())?

    fileprivate var remoteIOUnit: …
Run Code Online (Sandbox Code Playgroud)

audio cocoa-touch audiotoolbox ios swift

10
推荐指数
1
解决办法
229
查看次数

Xcode - 如何通过命令行更改文件的目标成员资格?

有没有办法通过命令行更改 Xcode 项目中文件的目标成员身份?

这是我尝试通过 Xcode 的 UI 执行的操作:

目标会员

xcode cocoa cocoa-touch objective-c xcode-command-line-tools

5
推荐指数
1
解决办法
3098
查看次数