我正在尝试使用带有android的OEPNGL视频效果
我是下载源代码项目: https://www.virag.si/2014/03/playing-video-with-opengl-on-android/
在此代码中应用视频效果。但如何在sdcard中的textureview中存储视频
播放视频:代码
private void startPlaying()
{
renderer = new VideoTextureRenderer(this, surface.getSurfaceTexture(), surfaceWidth, surfaceHeight);
player = new MediaPlayer();
try
{
AssetFileDescriptor afd = getAssets().openFd("big_buck_bunny.mp4");
player.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
player.setSurface(new Surface(renderer.getVideoTexture()));
player.setLooping(true);
player.prepare();
renderer.setVideoSize(player.getVideoWidth(), player.getVideoHeight());
player.start();
}
catch (IOException e)
{
throw new RuntimeException("Could not open input video!");
}
}
应用效果代码:
private static final String fragmentShaderCode =
"#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;" +
"varying highp vec2 v_TexCoordinate;" +
"uniform samplerExternalOES texture;" +
"uniform sampler2D chrominanceTexture;" +
"void main () {" +
"mediump vec3 yuv;" +
"lowp vec3 rgb;" +
"yuv.x = texture2D(texture, v_TexCoordinate).r;" +
"yuv.yz = texture2D(chrominanceTexture, v_TexCoordinate).rg - vec2(0.7154, 0.0721);" +
"rgb = mat3(1,1,1,0,0.2125, 0.7154, 0.0721,-.38059,0) * yuv;"+
"gl_FragColor = vec4(rgb, 1);"+
"}&#34 ;;
感谢。