android how record video from media3 playerview surfaceview

21 Views Asked by At

I have a video currently playing as follows

 ExoPlayer exoPlayer = new ExoPlayer.Builder(getActivity()).build();
 PlayerView playerView = new PlayerView(getActivity());
 playerView.setPlayer(exoPlayer);
 MediaItem mediaItem = MediaItem.fromUri(videoUri);
 exoPlayer.setMediaItem(mediaItem);
 exoPlayer.prepare();

SurfaceHolder holder =(SurfaceView) playerView.getVideoSurfaceView().getHolder();
Surface surface = holder.getSurface();

During the video playback process, when I press the record button, I need to start recording it from the time when the video is played. When I press the stop button, I save the recorded video to a file.

Now I don't know how to get video and audio frames from Playview or surfaceTexture

I found out that it was obtained using mediecode and MediaMuxer, but both were obtained from the camera。

and Aug 23, 2016 has some answer You can't record from a SurfaceView. When you play video to a SurfaceView, the frames are being sent to a Surface, which is a queue of buffers with a producer-consumer interface. The app only has access to the producer end -- the system graphics compositor (SurfaceFlinger) is the consumer.

I use media3_version = "1.3.0".

0

There are 0 best solutions below