AVAssetWriter在使用HEVC和Alpha时崩溃-寻找解决方法
创始人
2024-11-12 20:30:28
0

这是一个已知的问题,出现在使用HEVC视频编码器和Alpha通道(透明度)的情况下。目前还没有找到完美的解决方案,但是我们可以尝试以下几种方法:

方法1:使用HEVC而不含Alpha 这解决了HEVC与Alpha通道产生的冲突问题,因为不含Alpha的HEVC编码器不会产生任何问题。下面的是使用AVAssetWriter进行写操作的示例代码,使用HEVC编解码器:

let videoURL = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent("out.hevc") let assetWriter = try! AVAssetWriter(outputURL: videoURL, fileType: .mp4) let videoOutputSettings = [ AVVideoCodecKey : AVVideoCodecType.hevc, AVVideoWidthKey : 640, AVVideoHeightKey : 480, ] as [String : Any] let assetWriterVideoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoOutputSettings) assetWriter.add(assetWriterVideoInput)

方法2:将视频帧压缩为单独的Alpha和HEVC视频 这种方法需要将每个相邻的视频帧分离,并在HEVC和Alpha视频之间交替切换。由于这种方法需要额外的时间和空间,因此不适合所有情况。

方法3:使用其他编解码器 这种方法需要使用其他可用的编解码器,例如h.264,其可以同时使用HEVC和Alpha通道。下面的代码示例演示了如何在写入时使用h.264编解码器:

let assetWriter = try! AVAssetWriter(outputURL: videoURL, fileType: .mp4) let videoOutputSettings = [ AVVideoCodecKey : AVVideoCodecType.h264, AVVideoWidthKey : 640, AVVideoHeightKey : 480, ] as [String : Any] let assetWriterVideoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoOutputSettings) assetWriter.add(assetWriterVideoInput)

总之,我们需要在HEVC编码器和Alpha通道之间权衡,根据需要选择最适合应用程序的方法。

相关内容

热门资讯

透视游戏!wepoker私人局... 透视游戏!wepoker私人局透视方法,wepoker透视脚本免费,窍要教程(有挂分析)-哔哩哔哩1...
透视黑科技!德州透视插件,hh... 透视黑科技!德州透视插件,hhpoker有没有辅助,总结教程(有挂教学)-哔哩哔哩1、下载好hhpo...
透视苹果版!hhpoker怎么... 透视苹果版!hhpoker怎么破解,hhpoker德州牛仔视频,积累教程(有挂方针)-哔哩哔哩1、任...
透视科技!wpk透视是真的假的... 透视科技!wpk透视是真的假的,德州局怎么透视,法门教程(有挂透视)-哔哩哔哩1、让任何用户在无需w...
透视辅助!wpk插件辅助,约局... 透视辅助!wpk插件辅助,约局吧德州真的存在透视吗,总结教程(有挂实锤)-哔哩哔哩1)约局吧德州真的...
透视能赢!wepoker免费脚... 透视能赢!wepoker免费脚本弱密码,hhpoker底牌透视脚本,策略教程(有挂功能)-哔哩哔哩1...
透视好友房!poker辅助器免... 透视好友房!poker辅助器免费安装,hhpoker辅助软件下载,绝活教程(有挂工具)-哔哩哔哩1、...
透视脚本!佛手大菠萝13道挂哪... 透视脚本!佛手大菠萝13道挂哪里,德州辅助工具到底怎么样,要领教程(有挂方法)-哔哩哔哩德州辅助工具...
透视中牌率!wepoker辅助... 透视中牌率!wepoker辅助软件视频,红龙poker辅助指令,教程书教程(确实有挂)-哔哩哔哩该软...
透视科技!wepoker辅助工... 透视科技!wepoker辅助工具,智星德州可以透视吗,手筋教程(新版有挂)-哔哩哔哩1、下载好智星德...