gpt4 book ai didi

objective-c - AudioFileOpen无法以读/写权限打开

转载 作者:行者123 更新时间:2023-12-03 00:19:42 26 4
gpt4 key购买 nike

我正在尝试以编程方式优化使用AudioFileOptimize()而非iTunes或afconvert的软件创建的AAC文件(.m4a)。

但是,当我尝试执行具有读/写权限的AudioFileOpen时,它给我一个错误。即使我手动将POSIX权限设置为0666(每个人均为r / w),我也只能以读取权限打开。

我正在使用AudioFileOpenUrl描述的here方法并返回“prm?” (kAudioFilePermissionsError)。

这是引发错误的代码:

#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import "CAXException.h"



int main(int argc, const char * argv[])
{

int result = 0;

try {

//optimize the output file:
AudioFileID outfile;

NSURL *outputFileURL = [NSURL fileURLWithPath:@"/DIR/PATH TO.m4a"];

OSStatus err = AudioFileOpenURL((__bridge CFURLRef)outputFileURL, kAudioFileReadWritePermission, 0, &outfile);
XThrowIfError(err, "AudioFileOpenURL");

err = AudioFileOptimize(outfile); //Optimize the file
XThrowIfError(err, "AudioFileOptimize");

err = AudioFileClose(outfile);
XThrowIfError(err, "AudioFileClose");

} catch (CAXException e) {
char str[32];
printf ("CAXException thrown from CoreAudioConverter.mm. : %s, %s\n", e.FormatError(str), e.mOperation);
result = 1;
} catch (...) {
result = 1;
}

return result;
}

输出:
CAXException thrown from CoreAudioConverter.mm. : 'prm?', AudioFileOpenURL

如果有人可以帮助,那就太好了!

旁注,是否有人以编程方式将流式提示添加到AAC文件中完成任何工作?

谢谢!

最佳答案

AudioFile Services将不允许对某些文件的写访问:

There is however a limitation when working with MPEG-4 file types which include; .mp4 (kAudioFileMPEG4Type), .m4a (kAudioFileM4AType), .3g2 (kAudioFile3GP2Type) and .3gp (kAudioFile3GPType).

AudioFile does not currently support writing to existing files of these types.



看到:
http://developer.apple.com/library/mac/#qa/qa1676/_index.html

关于objective-c - AudioFileOpen无法以读/写权限打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11512302/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com