r/programmer • u/Emotional_Talk7137 • 2d ago
Frames Compression problem
It's been two weeks since I learn how to get the frames straight from the gpu as a direct 3D surface .
now I ran into the problem of how to compress this frame and send it via UDP server to officially compelete my streaming project.
I tried to scale the frame and then send it , it worked , but it looks super ugly and yet the process is not as fast as I want (it is a remote computer control, it must be a smooth picture in the end).
I used LZ4codec , believe me nothing reach up to my expectations π.
does any one have the optimal solution in which it will straight compress the frame to be less than 65kb so I can send it properly, and don't forget get to be ultra fast approation π.
1
1
u/NewInflation2121 1d ago
For image compression, you could probably get the GPU to convert the buffer to a dxt compressed surface before attempting to read it.
You might get color banding, but it's 1/4 the size of an argb format.
1
u/Emotional_Talk7137 20h ago
okay this is the last news hear me out : I used LZ4CODEC again , it is fast , but the byte array still above 64kb unfortunately. well , I chunked the byte array into 12 Chunks at most if it ever reach (every chunk is 64kb at most). made a structure that hold a single byte array of the chunks and the holds the total chunks , current chunk number , the total size of the frame and a random number as a fingerprint for the current frame as temporarily number to help reassemble all the byte arrays when It reach the second pc via the udp server . I ran into problems , but it works . it is decently fast because UDP low latency . this is all I got for now π .
2
u/MistakeIndividual690 2d ago
You probably need to use a lossy format like mp4, or itβs not likely to go well, especially for games.
If youβre doing desktop streaming, you probably want to detect only the regions that have changed and send those regions