Reputation: 117
I am developing a game where I want to stream the camera’s output from a server (which renders everything) to several clients. For simplicity, I am ignoring all audio data.
Currently, I record the camera’s render as a bitmap with a 400x300 resolution, and then I convert it to JPEG, add a time stamp and send it to the client over UDP.
With given resolution, my payload size varies from 13KB to 20KB. How can I make it more effective?
Upvotes: 2
Views: 750
Reputation: 163593
Use a video codec, not an image codec.
JPEG is appropriate for single images. (There is MJPEG, which is effectively a hack on this... but it's not all that great of quality.)
Most devices have a hardware codec for something like H.264 that you can use. If not, you can use H.264 in software, or use a free and open codec like VP8 or VP9... just be aware that those take more CPU for encoding. (Not that it will matter much at such a low resolution.)
Upvotes: 1
Reputation: 16693
Considering you want to keep the image dimensions, there are 2 things I can think of which can reduce the payload:
Here's a calculation I just made:
400 x 300 JPEG with 10/10 quality = 29.6KB.
400 x 300 JPEG with 8/10 quality = 19.6KB.
400 x 300 JPEG with 5/10 quality = 8.7KB.
400 x 300 JPEG with 2/10 quality = 5.6KB.
So, as you can see, losing 0.2 quality results in losing 1/3 of the image weight, which is significant.
Upvotes: 0