[C# Unity] Class (or function) of multithread and async to save Texture2D as jpg(or png) img each frame without affecting to the main loop (frame rate) of the game
Budget: $30 – $250 USD
Hi, I need the functionality of multithread and async to save Texture2D as jpg(or png) img each frame without affecting to the main loop (frame rate) of the at Unity, C# environment.
I do not want re-invent the wheel, so, someone have already done the same/ similar tasks are welcomed.
[Current code]
//////// the process of every frame in Unity
System.IO.File.WriteAllBytes(savePath + "/img_name.jpg", texture.EncodeToJPG(100));
or
System.IO.File.WriteAllBytes(savePath + "/img_name.png", texture.EncodeToPng());
[Requirements]
Unity 2019.4.7f1 (limited concretely)
--- I know some improvement about treating Texture2D later version of the Unity though,
they are not the target of this project.
Main game loop fps should not be affected.
Some delay to save img are allowed but too long is not allowed.
It's not restrict requirement (probably trade off with memory and CPU usage).
So please tell me your estimation (Cpu/Memory usage and delay) before hand.
Some Memory usage is allowed but 1GB - 2GB or such.
Tmp variable, object, byte[] texture2D etc. or thread/sub-process should be disposed property to avoid memory leak.
The Class(or function ) should receive save target pass(string) and texture2D as arguments.
No need to return value.
One images save sequence may endure 30fps of main frame and 600sec(5 min)
Image(and Texture) size is 4096x4096px (would be lager in the near future)
[FYI]
Current version of sync logic at my hard ware soft ware environment,
without saving(and EncodeToJPG,orEncodeToPng), fps is 20-30.
(CPU usage is 30% or such)
With texture.EncodeToJPG(100)), it slow down to 6fps or such.
With texture.EncodeToPng(100)), it slow down to 3fps or such.
EncodeToJPG() or EncodeToPng() is the bottle neck.
Thanks in advance.
I do not want re-invent the wheel, so, someone have already done the same/ similar tasks are welcomed.
[Current code]
//////// the process of every frame in Unity
System.IO.File.WriteAllBytes(savePath + "/img_name.jpg", texture.EncodeToJPG(100));
or
System.IO.File.WriteAllBytes(savePath + "/img_name.png", texture.EncodeToPng());
[Requirements]
Unity 2019.4.7f1 (limited concretely)
--- I know some improvement about treating Texture2D later version of the Unity though,
they are not the target of this project.
Main game loop fps should not be affected.
Some delay to save img are allowed but too long is not allowed.
It's not restrict requirement (probably trade off with memory and CPU usage).
So please tell me your estimation (Cpu/Memory usage and delay) before hand.
Some Memory usage is allowed but 1GB - 2GB or such.
Tmp variable, object, byte[] texture2D etc. or thread/sub-process should be disposed property to avoid memory leak.
The Class(or function ) should receive save target pass(string) and texture2D as arguments.
No need to return value.
One images save sequence may endure 30fps of main frame and 600sec(5 min)
Image(and Texture) size is 4096x4096px (would be lager in the near future)
[FYI]
Current version of sync logic at my hard ware soft ware environment,
without saving(and EncodeToJPG,orEncodeToPng), fps is 20-30.
(CPU usage is 30% or such)
With texture.EncodeToJPG(100)), it slow down to 6fps or such.
With texture.EncodeToPng(100)), it slow down to 3fps or such.
EncodeToJPG() or EncodeToPng() is the bottle neck.
Thanks in advance.