I'm creating video filter for Android app, so I'm using TextureView
to play video and filter on its SurfaceTexture
.
But the FPS of video's always lower than original(30fps).
As I checked on Galaxy S3, onSurfaceTextureUpdated()
only enter 5~8 times per sec although having filter or not. But on stronger device, as Samsung Galaxy J, it could increase to 10~13 times per sec
Note that this video load from SD card.
Does someone know the reason?
mVideoPlayer.reset();
mVideoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mVideoPlayer.setDataSource(mVideoPath);
mVideoPlayer.setSurface(new Surface(surfaceTexture));
mVideoPlayer.setLooping(true); mVideoPlayer.prepareAsync();
mVideoPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {mp.start(); }
});
答案 0 :(得分:1)
如果正在从软件访问视频帧,那么数据必须被复制几次,这会杀死你的FPS。
如果您将视频直接发送到与TextureView关联的Surface,您将看不到减速,但您也没有机会对其进行过滤。 (Grafika有基于SurfaceView和TextureView的视频播放器,性能没有明显差异.SurfaceView效率稍高,但并不是那么显着。)
要以30fps的速度进行实时过滤,您可以像this example一样使用GPU,尽管您可以使用它进行限制。
答案 1 :(得分:-1)
用更多设备检查后,我发现导致此问题的主要原因是内存。 所以我在完成此活动之前完成了之前的活动并发布了数据。 然后视频的FPS在S3上增加到10 +。
谢谢,