Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I recording a video, how can I record a new video with a custom rect in camera frame #1472

Open
Miles087 opened this issue May 6, 2024 · 4 comments

Comments

@Miles087
Copy link

Miles087 commented May 6, 2024

Hello, I want to record a custom place when I recording. How can I do with this?
354251714973252_ pic
For example, red rect is my recording frame. I want to record another video with green rect. What can I do?
I use OpenGlView with RtspCamera2

@pedroSG94
Copy link
Owner

Hello,

You have a filter that allow you to crop the video as you want but this affect to stream, record and preview:
https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/utils/FilterMenu.kt#L158

@Miles087
Copy link
Author

Miles087 commented May 7, 2024

Hello,

You have a filter that allow you to crop the video as you want but this affect to stream, record and preview: https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/utils/FilterMenu.kt#L158

Thank you very mush, I mean when I preview normal frame, and recording a normal video, at the same time record a new video with crop. Do you have any idea to resolve it?

@pedroSG94
Copy link
Owner

pedroSG94 commented May 7, 2024

Hello,

By default the library no allow record 2 videos at the same time. You can modify the library to do it but this could be difficult.

I think this could work:

  • Create a new GlStreamInterface and a new VideoEncoder (of course you need to handle with lifecycle of both classes)
  • Link VideoEncoder with GlStreamInterface (You can check StreamBase class)
  • Add a SurfaceManager to OpenGlView and link that SurfaceManager to the GlStreamInterface created (similar to https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/view/OpenGlView.java#L277)
  • Render the new SurfaceManager in draw method like others SurfaceManager
  • Create a new AndroidMediaMuxer class
  • Record the video using video data from the new VideoEncoder and reuse current audio data (duplicate the ByteBuffer is a good idea to avoid problems)
  • Add the filter to GlStreamInterface
  • You also need to do all code related with release all when you don't need it anymore

This feels difficult, so maybe the best idea is find a library that allow you modify the video as you want and create a new video modified when you call stopRecord.

@Miles087
Copy link
Author

Hello,

By default the library no allow record 2 videos at the same time. You can modify the library to do it but this could be difficult.

I think this could work:

  • Create a new GlStreamInterface and a new VideoEncoder (of course you need to handle with lifecycle of both classes)
  • Link VideoEncoder with GlStreamInterface (You can check StreamBase class)
  • Add a SurfaceManager to OpenGlView and link that SurfaceManager to the GlStreamInterface created (similar to https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/view/OpenGlView.java#L277)
  • Render the new SurfaceManager in draw method like others SurfaceManager
  • Create a new AndroidMediaMuxer class
  • Record the video using video data from the new VideoEncoder and reuse current audio data (duplicate the ByteBuffer is a good idea to avoid problems)
  • Add the filter to GlStreamInterface
  • You also need to do all code related with release all when you don't need it anymore

This feels difficult, so maybe the best idea is find a library that allow you modify the video as you want and create a new video modified when you call stopRecord.

Sorry for reply late, I use OpenCV clip and record frame at the same time. For now it seems working : D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants