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

Recording in small chunks #335

Open
ranwer-dev opened this issue Dec 21, 2024 · 3 comments
Open

Recording in small chunks #335

ranwer-dev opened this issue Dec 21, 2024 · 3 comments

Comments

@ranwer-dev
Copy link

Is it possible to record screen in small chunks, so that those can be uploaded to a cloud service while the screen recording is in progress? And later merge those on cloud?

@sskodje
Copy link
Owner

sskodje commented Dec 21, 2024

Sure! Make a custom stream inheriting from System.IO.Stream, and pass it to the recorder. Then you can do whatever you wish with the bytes in the Write method, like caching and chunking them and writing to the internet.

@ranwer-dev
Copy link
Author

Thanks for your response! I want to create small .ts type chunks to support HLS. I can create a custom stream to handle chunking and uploading data during the screen recording. However, I have a few questions to clarify the implementation:

  • How exactly should I pass the custom stream to ScreenRecorderLib? Is there a specific method or property in the library where I can set this custom stream?

  • In the Write method of the custom stream, should I focus on writing data in specific time intervals (e.g., every 10 seconds) or when the buffer reaches a certain size? What would be the recommended strategy for chunking the data?

  • After the chunks are uploaded, is there any specific format or metadata I need to be aware of to merge the files correctly on the cloud? Will the chunks be self-contained or would I need to include additional information in each chunk to help with merging?

Any additional insights or examples on how to implement this smoothly would be greatly appreciated!

@sskodje
Copy link
Owner

sskodje commented Dec 21, 2024

How exactly should I pass the custom stream to ScreenRecorderLib? Is there a specific method or property in the library where I can set this custom stream?

Pass it to the Record method on your Recorder instance, instead of a file path.

In the Write method of the custom stream, should I focus on writing data in specific time intervals (e.g., every 10 seconds) or when the buffer reaches a certain size? What would be the recommended strategy for chunking the data?

I don't have any strong opinions on the matter. Both will work.

After the chunks are uploaded, is there any specific format or metadata I need to be aware of to merge the files correctly on the cloud? Will the chunks be self-contained or would I need to include additional information in each chunk to help with merging?

As long as you have all the data, and reassemble the bytes in the correct order, the files will work. The chuncks will not be self contained (if you mean playable on their own), because the header necessary for playback will be in the first chunk. Enabling fragmented mp4 setting will make the files more robust to data loss, and will allow playback before the recording ends, because without it, the header necessary for playback is written at the very end of the recording.

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