Alternative to ffmpeg for iOS

青春壹個敷衍的年華 提交于 2019-12-02 19:51:55

I've experienced similar problems. There were two bottlenecks:

  1. decoding
  2. conversion from yuv to rgb formats

I solved the second problem by converting image using shaders. It works really fast now (I can render 6 videos simulteneously at 30 fps on iPad2).

Here is part of the fragment shader:

    uniform sampler2D y;
    uniform sampler2D u;
    uniform sampler2D v;

    ...
    y = texture2D(y, vec2(nx,ny)).r;
    u = texture2D(u, vec2(nx, ny)).r - 0.5;
    v = texture2D(v, vec2(nx, ny)).r - 0.5;

    r = y + 1.13983*v;
    g = y - 0.39465*u - 0.58060*v;
    b = y + 2.03211*u;

    gl_FragColor = vec4(r, g, b, 1.0);

NOTE: you have to store y,u,v components in 3 different textures.

nx and ny - are normalized texture coordinates (from 0 to 1 texture ).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!