0

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(); }
});
FormigaNinja
  • 1,571
  • 1
  • 24
  • 36
Trung NT Nguyen
  • 403
  • 2
  • 14
  • Is it faster on a SurfaceView? i.e. are you sure that it's the TextureView causing the bottleneck? How are you configuring the MediaPlayer? – fadden May 25 '15 at 17:50
  • Yes, it's faster on a SurfaceView. But I need to use TextureView for filtering purpose. I 've keep only Video playing but it's still in low fps – Trung NT Nguyen May 26 '15 at 02:06

2 Answers2

1

If the video frame is being accessed from software, then the data has to be copied a couple of times, and that will kill your FPS.

If you send the video directly to the Surface associated with the TextureView, you won't see a slowdown, but you will also have no opportunity to filter it. (Grafika has video players based on SurfaceView and TextureView, with no noticeable difference in performance. SurfaceView is slightly more efficient, but not dramatically so.)

To get real-time filtering at 30fps you can use the GPU, as in this example, though there are limits to what you can do with that.

fadden
  • 51,356
  • 5
  • 116
  • 166
-1

After checked with more devices, I found the main reason cause this issue is memory. So I finish previous activity and release data before go to this activity. Then the FPS of video increase to 10 + on S3.

Thanks,

Trung NT Nguyen
  • 403
  • 2
  • 14