远程桌面撒施C#更好的压缩 [英] C# better compression for remote desktop broadcast application

查看:198
本文介绍了远程桌面撒施C#更好的压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建一个 TCP 远程桌面广播应用程序的过程。 (喜欢的东西团队浏览器或VNC)
服务器应用程序将

I am in the process of creating a TCP remote desktop broadcasting application. (Something like Team Viewer or VNC) the server application will

1. run on a PC listening for multiple clients on one Thread
2. and on another thread it will record the desktop every second
3. and it will broadcast the desktop for each connected client.



我需要这个应用程序可能与一个12Kbps的上传一个连接运行,50KBps下载DSL连接(客户端和服务器)。

i need to make this application possible to run on a connections with a 12KBps upload and 50KBps download DSL connection (client's and server).

所以..我不得不减少数据/图像每秒I发送的大小。

so.. i have to reduce the size of the data/image i send per second.

我试图通过执行以下操作,以减少。

i tried to reduce by doing the following.

I. first i send a Bitmap frame of the desktop and each other time i send only the difference of the previously sent frame.

II. the second way i tried was, each time i send a JPEG frame.



我是不成功发送JPEG帧,然后每下一次发送的先前发送JPEG的区别帧。

i was unsuccessful to send a JPEG frame and then each next time send the difference of the previously sent JPEG frame.

我试着用 LZMA 压缩(7zip的SDK)为当我传送位图的区别。

i tried using lzma compression (7zip SDK) for the when i was transmitting the difference of the Bitmap.

不过,我是不成功的数据减少到12Kbps的。最大的我是能够实现大约为50KBps。

But i was unsuccessful to reduce the data into 12KBps. the maximum i was able to achieve was around 50KBps.

有人能指点我的算法/程序这样做呢?

Can someone advice me an algorithm/procedure for doing this?

推荐答案

您想要做的是做什么的图像压缩格式做,但在自定义的方式(仅发送变化,而不是在整个图像及以上)。这里是我会做什么,在两个阶段(第1阶段:完成它,证明它的工作原理,第2阶段:优化)

What you want to do is do what image compression formats do, but in a custom way (Send only the changes, not the whole image over and over). Here is what I would do, in two phases (phase 1: get it done, prove it works, phase 2: optimize)

概念阶段的证明

1)捕获位图格式画面的图像

1) Capture an image of the screen in bitmap format

2)第影像分为连续字节的块。你需要玩找出最佳块大小是什么;它将被上行/下行速度有所不同。

2) Section the image into blocks of contiguous bytes. You need to play around to find out what the optimal block size is; it will vary by uplink/downlink speed.

3)获取短哈希值(CRC32,也许MD5,实验与此以及)每个块

3) Get a short hash (crc32, maybe md5, experiment with this as well) for each block

4)压缩(不要忘了这样做!),并传送各改变块(如果哈希变化,块发生变化,需要传送)。缝合在一起的图像在接收端进行显示。

4) Compress (don't forget to do this!) and transfer each changed block (If the hash changed, the block changed and needs to be transferred). Stitch the image together at the receiving end to display it.

5)使用UDP数据包进行数据传输。

5) Use UDP packets for data transfer.

优化阶段

这些事情可以做,以优化速度:

These are things you can do to optimize for speed:

1)收集的统计和硬编码的传输速度,相较于最佳的传输速度帧大小和散列法

1) Gather stats and hard code transfer speed vs frame size and hash method for optimal transfer speed

2)请为#1的自我调节机制

2) Make a self-adjusting mechanism for #1

3)图像压缩的正方形区域的字节而不是连续的块更好,因为我在上面的第一阶段#2解释。改变你的算法,以便你得到一个可视化的方形区域,而不是行的顺序块。这个广场方法是图像和视频压缩的人是怎么做的。

3) Images compress better in square areas rather then contiguous blocks of bytes, as I explained in #2 of the first phase above. Change your algorithm so you are getting a visual square area rather than sequential blocks of lines. This square method is how the image and video compression people do it.

4)玩的压缩算法。这会给你很多的变数与(CPU负载VS上网速度VS压缩算法的选择VS屏幕更新频率)

4) Play around with the compression algorithm. This will give you lots of variables to play with (CPU load vs internet access speed vs compression algorithm choice vs frequency of screen updates)

这基本上是如何汇总(大致)压缩的视频流媒体作品(你可以看到相似之处与你的任务,如果你想想看),所以它不是一个未经证实的概念。

This is basically a summary of how (roughly) compressed video streaming works (you can see the similarities with your task if you think about it), so it's not an unproven concept.

心连心

编辑::您可以体验一件事:你捕获屏幕的位图后,减少它的颜色数。如果从32位色深到16位,例如,你可以保存图像大小的一半。

One more thing you can experiment with: After you capture a bitmap of the screen, reduce the number of colors in it. You can save half the image size if you go from 32 bit color depth to 16 bit, for example.

这篇关于远程桌面撒施C#更好的压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆