草庐IT

AVfoundation

全部标签

swift - AVPlayer/AVPlayerLayer 未出现在使用自动布局的 subview 中

我正在尝试在包含视频和一些文本的subview中显示视频。我用了recommendedUIViewsubclassfromApple创建一个UIView来包含我的AVPlayer:importFoundationimportAVFoundationclassJSAVPlayerView:UIView{varplayer:AVPlayer?{get{return(self.layeras!AVPlayerLayer).player}set(newPlayer){(self.layeras!AVPlayerLayer).player=newPlayer}}overrideclassfunc

swift - 将 pcm 加载到 AVAudioPCMBuffer

我有这个代码:funcloadSoundfont(_pitch:String){letpath:String=Bundle.main.path(forResource:"\(self.id)/\(pitch)",ofType:"f32")!leturl=URL(fileURLWithPath:path)do{letfile=tryAVAudioFile(forReading:url,commonFormat:AVAudioCommonFormat.pcmFormatFloat32,interleaved:true)letformat=file.processingFormatletca

ios - 反转音频文件 Swift/Objective-C

有没有办法可以反转和导出.m4a音频文件?我找到了反转音轨的解决方案here,但它似乎只适用于.caf文件格式。如果唯一的方法是使用.caf,有没有办法先将.m4a文件转换为.caf?更新:在anotherpost我发现AVAssetReader可用于从音频文件中读取音频样本,但我不知道如何以相反的顺序写回样本。下面的代码片段是直接来自帖子的答案。任何帮助,将不胜感激。谢谢+(void)reverseAudioTrack:(AVAsset*)audioAssetoutputURL:(NSURL*)outputURL{NSError*error;AVAssetReader*reader=

ios - didFinishProcessingPhotoSampleBuffer 未调用

我正在尝试学习如何使用AVFoundation拍摄和保存照片。我目前已经能够使用链接到拍照操作的按钮制作自定义相机View。当我单击按钮时,未调用委托(delegate)方法。这是我的ViewController.swift:classViewController:UIViewController,AVCapturePhotoCaptureDelegate{@IBOutletweakvarcamerView:UIView!@IBOutletweakvarphotoButton:UIButton!varcaptureSession:AVCaptureSession?varsessionO

ios - 播放 mp3/wav 声音导致异常

当使用AVAudioPlayer播放音频时,无论是mp3还是wav,我在所有iPad和iPhone4S上遇到异常,只有iOS9。这不会发生在任何其他设备上。异常产生于com.apple.coreaudio.AQClient(18):breakpoint2.2来自libc++abi.dylib`__cxa_throw:我正在使用用户断点捕获它。$arg1不包含任何内容这就是我初始化AVAudioPlayer的方式guardletpath=Bundle.main.path(forResource:file,ofType:type)else{returnnil}guardleturl=URL

ios - 无法使用 AVCaptureAudioDataOutputSampleDelegate 播放从语音录制的音频

几天来我一直在谷歌搜索和研究,但我似乎无法让它工作,而且我在互联网上找不到任何解决方案。我正在尝试使用麦克风捕捉我的声音,然后通过扬声器播放。这是我的代码:classViewController:UIViewController,AVAudioRecorderDelegate,AVCaptureAudioDataOutputSampleBufferDelegate{varrecordingSession:AVAudioSession!varaudioRecorder:AVAudioRecorder!varcaptureSession:AVCaptureSession!varmicrop

ios - 如何在 Swift 3 中将 UIImage 数组导出为电影?

我需要导出一个UIImage数组并构建一个电影,在图像前面放置一些文本,如果可能的话还可以放音乐。你能帮我写代码吗?我只在Objective-c和旧版本的Swift中找到了一些东西。 最佳答案 这是我对问题发布的第一个答案:createmoviefrom[UIImage],Swift以下是答案的副本:我将“@CameronE”发布的objective-c代码转换为Swift3,它正在运行。答案链接:@CameronE'sCEMovieMakerimportFoundationimportAVFoundationimportUIKit

swift - 即使其类别设置为播放(Swift), Audio Session 也会与其他 session 混合?

我正在使用AudioKit管理我的应用程序中的声音。我试图在锁定屏幕上显示播放/暂停按钮,这要求AudioSession不能与可能正在运行的其他AudioSession混合。为此,我将我的AudioSession设置为“播放”类别,该类别不应与其他类别混合。这是我的设置方法:privatefuncconfigureAudio(){do{tryAKSettings.setSession(category:.playback,with:[])tryAVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayba

ios - 在 iOS Swift 中捕获具有特定采样率的音频样本,例如 Android

我是在IOS中使用声音和AVAudioEngine的初学者,我正在开发一个应用程序来捕获音频样本作为缓冲区并对其进行分析。此外,采样率必须为8000kHz,并且还必须编码为PCM16Bit,但AVAudioEngine中的默认inputNode为44.1kHz。在Android中,这个过程非常简单:AudioRecordaudioRecord=newAudioRecord(MediaRecorder.AudioSource.MIC,8000,AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT,bufferSize);然后

ios - AVMediaTypeVideo 捕获静止图像方向

我已经看到了这个问题的其他几乎答案,但似乎无法让它发挥作用。我正在从AVMediaTypeVideo捕获图像,它的方向始终是UIImageOrientation3(我不知道这在现实中意味着什么)。我尝试使用状态栏方向来纠正它,但似乎没有任何效果。我不需要将这些图像保存到相机胶卷,它现在就在那里进行验证。我不确定这是否也对方向有任何影响。importUIKitimportAVFoundationclassViewController:UIViewController{letcaptureSession=AVCaptureSession()letstillImageOutput=AVCap