gpt4 book ai didi

ios - 如何在 GPUImage 中立即停止解码?

转载 作者:行者123 更新时间:2023-11-29 13:00:27 24 4
gpt4 key购买 nike

我们使用 GPUImageMovie 解码嵌入掩码的 MP4 压缩视频。

如果用户在视频解码期间按下主页按钮的问题 - 应用程序因 OpenGL 陷阱而崩溃。 iOS 不允许在后台使用 OpenGL。

有什么方法可以让 GPUImageMovie 立即停止解码,包括视频线程?

最佳答案

您应该在处理电影的 View Controller 中监听 UIApplicationWillResignActiveNotification 和 UIApplicationWillEnterForegroundNotification:

// handles the user pressing the home or power button while the camera is onscreen
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didResignActive:)
name: UIApplicationWillResignActiveNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:nil];

然后您应该添加适当的方法来响应通知:

-(void) didResignActive: (NSString *) notification {
//stop processing the movie
}

-(void) willEnterForeground: (NSString *) notification {
// start processing the movie
}

我很确定您可以通过调用 [movie startProcessing]; 开始处理并使用 [movie endProcessing]; 停止处理,但我并不肯定。

关于ios - 如何在 GPUImage 中立即停止解码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19903542/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com