Before we begin, let’s introduce GPUImage, an open source image processing library based on OpenGL ES 2.0. In iOS, OpenGL ES is encapsulated as objective-C interface, which can be used to add filters and other rendering operations to images, camera videos, and videos. GPUImage generation is no longer maintained, OC can only be used for iOS and Mac; GPUImage2 is also developed using Swift(based on Swift 3) for Mac, iOS and Linux. The latest GPUImage3 is still under development, based on Swift4, and replaces OpenGL ES with Apple’s Metal, which is expected to be more performance efficient than using OpenGL ES as it is Apple’s official method of packaging Gpus. This paper still uses the first-generation GPUImage.

Access the GPUImage directly from Cocoapods without further ado. Here is a simple filter to use:

PS: About the problem of video coding, Tencent’s QQ and wechat SDK can only share videos from network sources, not local sources. However, if you share videos through apple system, you can share videos. Some videos of the latest version may fail to be compressed and cannot be uploaded. At first it was thought to be a video coding problem that could not be solved by ffMPEG using H264 again or libx264. Later, I found that the audio that could not be compressed by Tencent was re-synthesized, so I re-coded the audio and used aAC, which is currently more common in network streaming media. The result made me disappointed, and it still didn’t work! Tencent can not find the coding problem required by these two shared videos online, and if I do not edit through FFMPEG, the h.264 + AAC of the original video is good, there is no way but to adopt control variable method to try coding one by one. In the end, it was found that the video H.264 had no problem, and the audio needed to be encoded using AC3 to pass.