获取音频文件大小而不导出 [英] Get audio file size without export
本文介绍了获取音频文件大小而不导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个导出存储在iPod库中的音频文件的应用程序,但我应该在导出和上传之前验证文件大小(服务器具有固定的最大上传大小):
i'm developing an app that export audio file stored in the iPod library, but i should verify the file size before export and upload (server has a fixed max upload size):
- 我知道导出文件后,大小不一样:有没有什么方法可以估算新的大小?
- 主要问题:我可以在导出之前知道原始文件大小(使用MPMediaItem或其他东西),因此我可以告诉用户此文件无法上传(导出可能需要一段时间)。
谢谢。
推荐答案
我还没有测试,但AVAssetExportSession可以帮助你。
I have not tested but AVAssetExportSession can help you with this.
MPMediaItem *curItem = musicPlayer.nowPlayingItem;
NSURL *url = [curItem valueForProperty: MPMediaItemPropertyAssetURL];
AVURLAsset *songAsset = [AVURLAsset URLAssetWithURL: url options:nil];
AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset: songAsset
presetName: AVAssetExportPresetPassthrough];
exporter.estimatedOutputFileLength将为您提供字节大小。
exporter.estimatedOutputFileLength will give you size in bytes.
这篇关于获取音频文件大小而不导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文