- Home /
Is there a faster way to encode JPG than EncodeToJPG?
The platform can be WIndows or Linux, it's a server app. The users connect to my app through HTTP. My app need to render things and send it back to users as jpg as quick as possible. For now, I am using just Unity's EncodeToJPG and send it through System.IO.Stream. But i feel there should be some way faster. Also, EncodeToJPG can only run in main thread.
Do you have any suggestion?
Edit: Also i am using ReadPixels after WaitForEndOfFrame. but it can be faster also
Answer by SunnyChow · Oct 12, 2020 at 04:43 AM
https://assetstore.unity.com/packages/tools/integration/lightbuzz-super-fast-jpeg-123585
i am answering my question. We are using this plugin for now. it's faster than EncodeToJPG () because they integrated libjpeg-turbo to make it faster.
However I believe there should be a way to use GPU for encoding. it should be even faster and may be able to bypass Texture2D.ReadPixels (which is slow). Still trying to improve.
Thanks for posting your solution, it helps others.
That plugin is a bit out-dated with some critical bug of crashing, and some multi-threading bugs with bad image data. But at least it gave me the keyword of libjpeg-turbo.
I've finally implemented libjpeg-turbo from github for my own project F$$anonymous$$ETP STREA$$anonymous$$ on asset store: http://u3d.as/1uHj
Because I have cross-platform need on HoloLens, and fixed some bugs on my own.
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Visually testing on Ubuntu Server? 0 Answers
How can I convert UTF8 string to arabic? 2 Answers
Unreasonable CPU consumption for server build with -nographics 0 Answers