iOS 版 ffmpeg 的替代方案
几周来我一直在尝试在我的 ios 应用程序中实现 ffmpeg。现在我可以播放几个 avi 文件,但其他文件(例如 flv、wma、mp4...)播放速度很慢。
我花了很多时间使用 ffmpeg 和 opengl 但没有找到解决方案。
我正在寻找其他替代方案来在 ios 设备上播放此文件。
有人知道其他库、框架……我可以用它们来播放这个文件。不管有没有营业执照。
非常感谢,
编辑:
初始化着色器:
shader = [[GLShader alloc] initWithFileName:@"render" attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:0], @"position",
[NSNumber numberWithInt:1], @"texCoords", nil]
uniforms:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0], @"sampler0",
[NSNumber numberWithInt:0], @"viewProjectionMatrix",nil]];
render.fsv:
uniform sampler2D sampler0;
varying highp vec2 _texcoord;
void main()
{ gl_FragColor = texture2D(sampler0, _texcoord);}
render.vsf:
attribute vec4 position;
attribute vec2 texCoords;
varying vec4 colorVarying;
varying vec2 _texcoord;
uniform mat4 viewProjectionMatrix;
void main()
{ _texcoord = texCoords;
gl_Position = viewProjectionMatrix * position;}
我如何在此代码中实现您的解决方案?
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 much time with ffmpeg and opengl and I don't find solution.
I'm looking other alternatives to play this files on ios device.
Someone know other libraries, frameworks, ... that I can use to play this files. No matter if they have business licenses.
Very thanks,
Edited:
Init Shader:
shader = [[GLShader alloc] initWithFileName:@"render" attributes:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:0], @"position",
[NSNumber numberWithInt:1], @"texCoords", nil]
uniforms:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0], @"sampler0",
[NSNumber numberWithInt:0], @"viewProjectionMatrix",nil]];
render.fsv:
uniform sampler2D sampler0;
varying highp vec2 _texcoord;
void main()
{ gl_FragColor = texture2D(sampler0, _texcoord);}
render.vsf:
attribute vec4 position;
attribute vec2 texCoords;
varying vec4 colorVarying;
varying vec2 _texcoord;
uniform mat4 viewProjectionMatrix;
void main()
{ _texcoord = texCoords;
gl_Position = viewProjectionMatrix * position;}
How I can implement your solution in this code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也遇到过类似的问题。有两个瓶颈:
转换我通过使用着色器转换图像解决了第二个问题。现在它的运行速度非常快(我可以在 iPad2 上以 30 fps 的速度同时渲染 6 个视频)。
以下是片段着色器的一部分:
注意:您必须将 y、u、v 分量存储在 3 个不同的纹理中。
nx 和 ny - 是标准化纹理坐标(从 0 到 1 纹理)。
I've experienced similar problems. There were two bottlenecks:
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:
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 ).