07 gsy render and effects

From CarGuo/GSYVideoPlayer · View interactive version

07 gsy render and effects is an AI agent skill from the GitHub repository CarGuo/GSYVideoPlayer. 三种渲染载体(TextureView / SurfaceView / GLSurfaceView)、显示比例(16:9/4:3/full/custom)、GL 滤镜与自定义 Shader。

How to use this skill

Skill file

gsy-render-and-effects

渲染类型 `GSYVideoType.setRenderType(int)`

| 常量 | 值 | 说明 |

|---|---|---|

| TEXTURE | 0 | 默认,与动画/圆角/缩放兼容最好 |

| SURFACE | 1 | 性能最好,但和 View 动画冲突 |

| GLSURFACE | 2 | 必需,若要用 setEffectFilter |

见 GSYVideoType#L39-L49。设置时机:setUp 之前,全局生效。

显示比例 `GSYVideoType.setShowType(int)`

| 常量 | 值 | 说明 |

|---|---|---|

| SCREEN_TYPE_DEFAULT | 0 | 按视频原比例居中 |

| SCREEN_TYPE_16_9 | 1 | 强制 16:9 |

| SCREEN_TYPE_4_3 | 2 | 强制 4:3 |

| SCREEN_TYPE_18_9 | 6 | 全面屏 |

| SCREEN_TYPE_FULL | 4 | 全屏裁减;surface_container 建议 FrameLayout |

| SCREEN_MATCH_FULL | -4 | 全屏拉伸;surface_container 建议 FrameLayout |

| SCREEN_TYPE_CUSTOM | -5 | 需先 setScreenScaleRatio(float) |

见 GSYVideoType#L10-L29 与 GSYVideoType#L165-L167。

硬解码开关

| 静态方法 | 说明 |

|---|---|

| enableMediaCodec() / disableMediaCodec() | IJK 硬解码总开关 #L71-L79 |

| enableMediaCodecTexture() / disableMediaCodecTexture() | 硬解 + Texture 直渲染优化 #L100-L108 |

| enableSmartMediaCodec() / disableSmartMediaCodec() | 硬解失败自动软解回退 #L86-L94 |

| isMediaCodec() / isMediaCodecTexture() / isSmartMediaCodec() | 查询 |

设置时机:setUp 之前,且部分机型需要在 Application.onCreate 就配好。

GL 滤镜

需要满足两个条件:

  1. GSYVideoType.setRenderType(GSYVideoType.GLSURFACE)
  2. builder.setEffectFilter(new XxxEffect()) 或 player.setEffectFilter(...)

SDK 内置滤镜(在 com.shuyu.gsyvideoplayer.render.effect.*):AutoFixEffect、BarrelBlurEffect、BlackAndWhiteEffect、BrightnessEffect、ContrastEffect、CrossProcessEffect、DocumentaryEffect、DuotoneEffect、FillLightEffect、GammaEffect、GaussianBlurEffect、GrainEffect、GreyScaleEffect、HueEffect、InvertColorsEffect、LamoishEffect、NoEffect、OverlayEffect、PosterizeEffect、SampleBlurEffect、SaturationEffect、SepiaEffect、SharpnessEffect、TemperatureEffect、TintEffect、VignetteEffect。目录:render/effect。

自定义 Shader:实现 CODE0。Demo 里 4 个复杂样例:GSYVideoGLViewCustomRender / 2 / 3 / 4,以及像素化 PixelationEffect、BitmapOverlay BitmapEffect / BitmapIconEffect。

v14.0.0 多 pass 与新效果

抓帧 / gif / 截图

在 GSYRenderView:

| 方法 | 回调 | 说明 |

|---|---|---|

| taskShotPic(GSYVideoShotListener) | 返 Bitmap | 单帧截图 |

| saveFrame(File, GSYVideoShotSaveListener) | 保存到磁盘 | 落盘截图 |

| taskGifPic(...) + GifCreateHelper | 生成 gif | 见 GifCreateHelper |

Demo 对照

常见坑

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.