1

I'm using surfaceView where i'm rendering the video. I have a .mp4 file with video/hevc and video/avc. I made two threads such that they are extracted, decoded and rendered to the surface though the surfaceView. i can choose which video to show in the surface by changing this line in the thread:

 decoder.configure(format, null, null, 0);

to

 decoder.configure(format, surface, null, 0);

But how to do this dynamically on the fly with a click of a button?

Coder7711
  • 61
  • 1
  • 7

1 Answers1

0

If you are targeting Android version since M, you can set the surface on the fly by using MediaCodec.SetOutputSurface(Surface) Note that for avoiding decoders concurrence on the same surface, a (only?) solution (bad?) is to use another hidden surface and pass it to the first decoder before setting your desirated surface to the second one

E.Abdel
  • 1,992
  • 1
  • 13
  • 24
  • Hi thank you for your comment, can you post an example of the usage of that. – Coder7711 Jan 30 '20 at 11:07
  • I did this by rendering the two videos in two separate surface view and then hiding one of it by using .setVisibility(View.INVISIBLE); – Coder7711 Feb 03 '20 at 03:12
  • Yes, you can do this, but to avoid using another SurfaceView, you can use a Surface like I mentionned above – E.Abdel Feb 03 '20 at 08:54