简体   繁体   English

在设备上导出时AVAssetExportSession缺少音轨

[英]AVAssetExportSession missing audio track when exporting on device

I run the export on the simulator and everything works great. 我在模拟器上运行了导出,并且一切正常。 I run it on the device and the video gets exported but there's no audio. 我在设备上运行它,视频被导出,但是没有音频。 This leads me to believe that I must be using an audio format that the device doesn't support but OS X does, as the simulator uses what OS X uses. 这使我相信,我必须使用设备不支持但OS X支持的音频格式,因为模拟器使用OS X所使用的格式。 I've tried m4a, aiff, and aifc and have had no luck! 我尝试过m4a,aiff和aifc,但没有运气! Any ideas?? 有任何想法吗??

I have a very similar problem. 我有一个非常相似的问题。 It does not seem to do with codecs, as I made a separate test case that runs fine with the same video. 它似乎与编解码器无关,因为我制作了一个单独的测试用例,可以在同一视频上正常运行。 There's a related question that says the problem might be in playing the same assets using MPMoviePlayerController . 有一个相关的问题说,问题可能出在使用MPMoviePlayerController播放相同的资产上。 That got me on the right track (sort of). 那使我走上了正确的轨道。

In my case the trouble stem from using the assets in an AVPlayer during the export. 就我而言,问题出在导出期间在AVPlayer中使用资产。 I was not able to find the exact combination that causes the export to drop the audio track – in the separate test project the export runs fine even though the asset plays in AVPlayer at the same time. 我无法找到导致导出丢失音轨的确切组合–在单独的测试项目中,即使资产同时在AVPlayer中播放,导出也可以正常运行。 After several hours of trying to find the exact cause I gave up and simply popped the asset out of the player using replaceCurrentItemWithPlayerItem:nil during export. 在尝试寻找确切原因几个小时后,我放弃了,只是在导出过程中使用replaceCurrentItemWithPlayerItem:nil将资产弹出播放器。 It's a hack, but it works. 这是一个hack,但可以。

AVFoundation is a very powerful framework, but God I wish it wasn't so finicky or at least logged more errors instead of silently producing garbage. AVFoundation是一个非常强大的框架,但是上帝,我希望它不是那么挑剔,或者至少记录了更多的错误,而不是无声地产生垃圾。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM