AVFileType.MpegLayer3
是一种可以在 mpeg 视频容器中使用的图层类型,但您不能使用它来导出到仅音频.mp3
文件。
注意:您可以导入mp3,但不能导出,我从未见过官方答案,但大多数人都提到了mp3许可问题......(?)
您可以测试资产与AVFoundation
文件类型 (UTI) 和导出预设的组合是否是有效组合,以避免通过DetermineCompatibilityOfExportPreset
/出现本机异常DetermineCompatibilityOfExportPresetAsync
:
var ok = await AVAssetExportSession.DetermineCompatibilityOfExportPresetAsync(
preset,
asset,
UTIConstant
);
根据所有可用的预设和导出类型测试.wav
资产,您会发现 mp3 不是受支持的格式。可用选项之一是:
AppleM4a : com.apple.m4a-audio : AVAssetExportPresetAppleM4A
如果.m4a
格式是您的应用程序的选项。
我 NSLog 列出了针对wav
资产的所有预设/文件类型:
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPreset1920x1080
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetLowQuality
False: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetAppleM4A
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetHEVCHighestQuality
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPreset640x480
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPreset3840x2160
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetHEVC3840x2160
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetHighestQuality
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPreset1280x720
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetMediumQuality
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPreset960x540
True: QuickTimeMovie : com.apple.quicktime-movie : AVAssetExportPresetHEVC1920x1080
True: Mpeg4 : public.mpeg-4 : AVAssetExportPreset1920x1080
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetLowQuality
False: Mpeg4 : public.mpeg-4 : AVAssetExportPresetAppleM4A
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetHEVCHighestQuality
True: Mpeg4 : public.mpeg-4 : AVAssetExportPreset640x480
True: Mpeg4 : public.mpeg-4 : AVAssetExportPreset3840x2160
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetHEVC3840x2160
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetHighestQuality
True: Mpeg4 : public.mpeg-4 : AVAssetExportPreset1280x720
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetMediumQuality
True: Mpeg4 : public.mpeg-4 : AVAssetExportPreset960x540
True: Mpeg4 : public.mpeg-4 : AVAssetExportPresetHEVC1920x1080
True: AppleM4V : com.apple.m4v-video : AVAssetExportPreset1920x1080
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetLowQuality
False: AppleM4V : com.apple.m4v-video : AVAssetExportPresetAppleM4A
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetHEVCHighestQuality
True: AppleM4V : com.apple.m4v-video : AVAssetExportPreset640x480
True: AppleM4V : com.apple.m4v-video : AVAssetExportPreset3840x2160
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetHEVC3840x2160
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetHighestQuality
True: AppleM4V : com.apple.m4v-video : AVAssetExportPreset1280x720
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetMediumQuality
True: AppleM4V : com.apple.m4v-video : AVAssetExportPreset960x540
True: AppleM4V : com.apple.m4v-video : AVAssetExportPresetHEVC1920x1080
False: ThreeGpp : public.3gpp : AVAssetExportPreset1920x1080
False: ThreeGpp : public.3gpp : AVAssetExportPresetLowQuality
False: ThreeGpp : public.3gpp : AVAssetExportPresetAppleM4A
False: ThreeGpp : public.3gpp : AVAssetExportPresetHEVCHighestQuality
False: ThreeGpp : public.3gpp : AVAssetExportPreset640x480
False: ThreeGpp : public.3gpp : AVAssetExportPreset3840x2160
False: ThreeGpp : public.3gpp : AVAssetExportPresetHEVC3840x2160
False: ThreeGpp : public.3gpp : AVAssetExportPresetHighestQuality
False: ThreeGpp : public.3gpp : AVAssetExportPreset1280x720
False: ThreeGpp : public.3gpp : AVAssetExportPresetMediumQuality
False: ThreeGpp : public.3gpp : AVAssetExportPreset960x540
False: ThreeGpp : public.3gpp : AVAssetExportPresetHEVC1920x1080
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPreset1920x1080
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetLowQuality
True: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetAppleM4A
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetHEVCHighestQuality
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPreset640x480
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPreset3840x2160
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetHEVC3840x2160
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetHighestQuality
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPreset1280x720
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetMediumQuality
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPreset960x540
False: AppleM4a : com.apple.m4a-audio : AVAssetExportPresetHEVC1920x1080
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPreset1920x1080
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetLowQuality
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetAppleM4A
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetHEVCHighestQuality
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPreset640x480
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPreset3840x2160
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetHEVC3840x2160
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetHighestQuality
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPreset1280x720
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetMediumQuality
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPreset960x540
False: CoreAudioFormat : com.apple.coreaudio-format : AVAssetExportPresetHEVC1920x1080
False: Wave : com.microsoft.waveform-audio : AVAssetExportPreset1920x1080
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetLowQuality
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetAppleM4A
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetHEVCHighestQuality
False: Wave : com.microsoft.waveform-audio : AVAssetExportPreset640x480
False: Wave : com.microsoft.waveform-audio : AVAssetExportPreset3840x2160
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetHEVC3840x2160
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetHighestQuality
False: Wave : com.microsoft.waveform-audio : AVAssetExportPreset1280x720
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetMediumQuality
False: Wave : com.microsoft.waveform-audio : AVAssetExportPreset960x540
False: Wave : com.microsoft.waveform-audio : AVAssetExportPresetHEVC1920x1080
False: Aiff : public.aiff-audio : AVAssetExportPreset1920x1080
False: Aiff : public.aiff-audio : AVAssetExportPresetLowQuality
False: Aiff : public.aiff-audio : AVAssetExportPresetAppleM4A
False: Aiff : public.aiff-audio : AVAssetExportPresetHEVCHighestQuality
False: Aiff : public.aiff-audio : AVAssetExportPreset640x480
False: Aiff : public.aiff-audio : AVAssetExportPreset3840x2160
False: Aiff : public.aiff-audio : AVAssetExportPresetHEVC3840x2160
False: Aiff : public.aiff-audio : AVAssetExportPresetHighestQuality
False: Aiff : public.aiff-audio : AVAssetExportPreset1280x720
False: Aiff : public.aiff-audio : AVAssetExportPresetMediumQuality
False: Aiff : public.aiff-audio : AVAssetExportPreset960x540
False: Aiff : public.aiff-audio : AVAssetExportPresetHEVC1920x1080
False: Aifc : public.aifc-audio : AVAssetExportPreset1920x1080
False: Aifc : public.aifc-audio : AVAssetExportPresetLowQuality
False: Aifc : public.aifc-audio : AVAssetExportPresetAppleM4A
False: Aifc : public.aifc-audio : AVAssetExportPresetHEVCHighestQuality
False: Aifc : public.aifc-audio : AVAssetExportPreset640x480
False: Aifc : public.aifc-audio : AVAssetExportPreset3840x2160
False: Aifc : public.aifc-audio : AVAssetExportPresetHEVC3840x2160
False: Aifc : public.aifc-audio : AVAssetExportPresetHighestQuality
False: Aifc : public.aifc-audio : AVAssetExportPreset1280x720
False: Aifc : public.aifc-audio : AVAssetExportPresetMediumQuality
False: Aifc : public.aifc-audio : AVAssetExportPreset960x540
False: Aifc : public.aifc-audio : AVAssetExportPresetHEVC1920x1080
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPreset1920x1080
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetLowQuality
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetAppleM4A
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetHEVCHighestQuality
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPreset640x480
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPreset3840x2160
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetHEVC3840x2160
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetHighestQuality
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPreset1280x720
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetMediumQuality
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPreset960x540
False: Amr : org.3gpp.adaptive-multi-rate-audio : AVAssetExportPresetHEVC1920x1080
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPreset1920x1080
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetLowQuality
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetAppleM4A
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetHEVCHighestQuality
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPreset640x480
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPreset3840x2160
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetHEVC3840x2160
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetHighestQuality
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPreset1280x720
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetMediumQuality
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPreset960x540
False: ThreeGpp2 : public.3gpp2 : AVAssetExportPresetHEVC1920x1080
False: MpegLayer3 : public.mp3 : AVAssetExportPreset1920x1080
False: MpegLayer3 : public.mp3 : AVAssetExportPresetLowQuality
False: MpegLayer3 : public.mp3 : AVAssetExportPresetAppleM4A
False: MpegLayer3 : public.mp3 : AVAssetExportPresetHEVCHighestQuality
False: MpegLayer3 : public.mp3 : AVAssetExportPreset640x480
False: MpegLayer3 : public.mp3 : AVAssetExportPreset3840x2160
False: MpegLayer3 : public.mp3 : AVAssetExportPresetHEVC3840x2160
False: MpegLayer3 : public.mp3 : AVAssetExportPresetHighestQuality
False: MpegLayer3 : public.mp3 : AVAssetExportPreset1280x720
False: MpegLayer3 : public.mp3 : AVAssetExportPresetMediumQuality
False: MpegLayer3 : public.mp3 : AVAssetExportPreset960x540
False: MpegLayer3 : public.mp3 : AVAssetExportPresetHEVC1920x1080
False: SunAU : public.au-audio : AVAssetExportPreset1920x1080
False: SunAU : public.au-audio : AVAssetExportPresetLowQuality
False: SunAU : public.au-audio : AVAssetExportPresetAppleM4A
False: SunAU : public.au-audio : AVAssetExportPresetHEVCHighestQuality
False: SunAU : public.au-audio : AVAssetExportPreset640x480
False: SunAU : public.au-audio : AVAssetExportPreset3840x2160
False: SunAU : public.au-audio : AVAssetExportPresetHEVC3840x2160
False: SunAU : public.au-audio : AVAssetExportPresetHighestQuality
False: SunAU : public.au-audio : AVAssetExportPreset1280x720
False: SunAU : public.au-audio : AVAssetExportPresetMediumQuality
False: SunAU : public.au-audio : AVAssetExportPreset960x540
False: SunAU : public.au-audio : AVAssetExportPresetHEVC1920x1080
False: AC3 : public.ac3-audio : AVAssetExportPreset1920x1080
False: AC3 : public.ac3-audio : AVAssetExportPresetLowQuality
False: AC3 : public.ac3-audio : AVAssetExportPresetAppleM4A
False: AC3 : public.ac3-audio : AVAssetExportPresetHEVCHighestQuality
False: AC3 : public.ac3-audio : AVAssetExportPreset640x480
False: AC3 : public.ac3-audio : AVAssetExportPreset3840x2160
False: AC3 : public.ac3-audio : AVAssetExportPresetHEVC3840x2160
False: AC3 : public.ac3-audio : AVAssetExportPresetHighestQuality
False: AC3 : public.ac3-audio : AVAssetExportPreset1280x720
False: AC3 : public.ac3-audio : AVAssetExportPresetMediumQuality
False: AC3 : public.ac3-audio : AVAssetExportPreset960x540
False: AC3 : public.ac3-audio : AVAssetExportPresetHEVC1920x1080
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPreset1920x1080
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetLowQuality
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetAppleM4A
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetHEVCHighestQuality
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPreset640x480
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPreset3840x2160
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetHEVC3840x2160
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetHighestQuality
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPreset1280x720
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetMediumQuality
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPreset960x540
False: EnhancedAC3 : public.enhanced-ac3-audio : AVAssetExportPresetHEVC1920x1080
False: Jpeg : public.jpeg : AVAssetExportPreset1920x1080
False: Jpeg : public.jpeg : AVAssetExportPresetLowQuality
False: Jpeg : public.jpeg : AVAssetExportPresetAppleM4A
False: Jpeg : public.jpeg : AVAssetExportPresetHEVCHighestQuality
False: Jpeg : public.jpeg : AVAssetExportPreset640x480
False: Jpeg : public.jpeg : AVAssetExportPreset3840x2160
False: Jpeg : public.jpeg : AVAssetExportPresetHEVC3840x2160
False: Jpeg : public.jpeg : AVAssetExportPresetHighestQuality
False: Jpeg : public.jpeg : AVAssetExportPreset1280x720
False: Jpeg : public.jpeg : AVAssetExportPresetMediumQuality
False: Jpeg : public.jpeg : AVAssetExportPreset960x540
False: Jpeg : public.jpeg : AVAssetExportPresetHEVC1920x1080
False: Dng : com.adobe.raw-image : AVAssetExportPreset1920x1080
False: Dng : com.adobe.raw-image : AVAssetExportPresetLowQuality
False: Dng : com.adobe.raw-image : AVAssetExportPresetAppleM4A
False: Dng : com.adobe.raw-image : AVAssetExportPresetHEVCHighestQuality
False: Dng : com.adobe.raw-image : AVAssetExportPreset640x480
False: Dng : com.adobe.raw-image : AVAssetExportPreset3840x2160
False: Dng : com.adobe.raw-image : AVAssetExportPresetHEVC3840x2160
False: Dng : com.adobe.raw-image : AVAssetExportPresetHighestQuality
False: Dng : com.adobe.raw-image : AVAssetExportPreset1280x720
False: Dng : com.adobe.raw-image : AVAssetExportPresetMediumQuality
False: Dng : com.adobe.raw-image : AVAssetExportPreset960x540
False: Dng : com.adobe.raw-image : AVAssetExportPresetHEVC1920x1080
False: Heic : public.heic : AVAssetExportPreset1920x1080
False: Heic : public.heic : AVAssetExportPresetLowQuality
False: Heic : public.heic : AVAssetExportPresetAppleM4A
False: Heic : public.heic : AVAssetExportPresetHEVCHighestQuality
False: Heic : public.heic : AVAssetExportPreset640x480
False: Heic : public.heic : AVAssetExportPreset3840x2160
False: Heic : public.heic : AVAssetExportPresetHEVC3840x2160
False: Heic : public.heic : AVAssetExportPresetHighestQuality
False: Heic : public.heic : AVAssetExportPreset1280x720
False: Heic : public.heic : AVAssetExportPresetMediumQuality
False: Heic : public.heic : AVAssetExportPreset960x540
False: Heic : public.heic : AVAssetExportPresetHEVC1920x1080
False: Avci : public.avci : AVAssetExportPreset1920x1080
False: Avci : public.avci : AVAssetExportPresetLowQuality
False: Avci : public.avci : AVAssetExportPresetAppleM4A
False: Avci : public.avci : AVAssetExportPresetHEVCHighestQuality
False: Avci : public.avci : AVAssetExportPreset640x480
False: Avci : public.avci : AVAssetExportPreset3840x2160
False: Avci : public.avci : AVAssetExportPresetHEVC3840x2160
False: Avci : public.avci : AVAssetExportPresetHighestQuality
False: Avci : public.avci : AVAssetExportPreset1280x720
False: Avci : public.avci : AVAssetExportPresetMediumQuality
False: Avci : public.avci : AVAssetExportPreset960x540
False: Avci : public.avci : AVAssetExportPresetHEVC1920x1080
False: Heif : public.heif : AVAssetExportPreset1920x1080
False: Heif : public.heif : AVAssetExportPresetLowQuality
False: Heif : public.heif : AVAssetExportPresetAppleM4A
False: Heif : public.heif : AVAssetExportPresetHEVCHighestQuality
False: Heif : public.heif : AVAssetExportPreset640x480
False: Heif : public.heif : AVAssetExportPreset3840x2160
False: Heif : public.heif : AVAssetExportPresetHEVC3840x2160
False: Heif : public.heif : AVAssetExportPresetHighestQuality
False: Heif : public.heif : AVAssetExportPreset1280x720
False: Heif : public.heif : AVAssetExportPresetMediumQuality
False: Heif : public.heif : AVAssetExportPreset960x540
False: Heif : public.heif : AVAssetExportPresetHEVC1920x1080
False: Tiff : public.tiff : AVAssetExportPreset1920x1080
False: Tiff : public.tiff : AVAssetExportPresetLowQuality
False: Tiff : public.tiff : AVAssetExportPresetAppleM4A
False: Tiff : public.tiff : AVAssetExportPresetHEVCHighestQuality
False: Tiff : public.tiff : AVAssetExportPreset640x480
False: Tiff : public.tiff : AVAssetExportPreset3840x2160
False: Tiff : public.tiff : AVAssetExportPresetHEVC3840x2160
False: Tiff : public.tiff : AVAssetExportPresetHighestQuality
False: Tiff : public.tiff : AVAssetExportPreset1280x720
False: Tiff : public.tiff : AVAssetExportPresetMediumQuality
False: Tiff : public.tiff : AVAssetExportPreset960x540
False: Tiff : public.tiff : AVAssetExportPresetHEVC1920x1080