Alternative to ffmpeg for iOS

后端 未结 1 1740
心在旅途
心在旅途 2021-02-02 04:37

I\'ve been trying to implement ffmpeg in my ios app several weeks. And now I can play several avi files, but other files like a flv, wma, mp4... play slow.

I have spent

1条回答
  •  伪装坚强ぢ
    2021-02-02 05:14

    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 ).

    0 讨论(0)
提交回复
热议问题