duanmei2459 2013-02-05 13:07
浏览 27
已采纳

如何通过使用数据压缩将数据从服务器传输到Android设备?

I am writing an application which downloads data from a server and displays it. The data consists of text, video, audio and picture files. The data is downloaded in so called data-bundles. A data-bundle can consist of a collenction of all data types, ranging from a few kilobytes to many hundreds of megabytes. The reason for too large data-bundles are video files.

Server is written in Go and the application is written Java (Android).

Question: Which compression algorithm would be the best way to go, if I want to transmit data-bundles (small and large)? Is Deflate enough, or should I consider a more sophisticated approach?

  • 写回答

1条回答 默认 最新

  • dongmi5015 2013-02-05 13:34
    关注

    First of all, I assume that your video, audio and image files are already compressed with a lossy algorithm. In that case, you usually won't be able to compress the data (much) using an additional, different compression algorithm. If the text data is usually just a small part of the entire data-bundle, I don't think I would bother applying any further compression at all, since adding complexity to your software for a very small overall gain is not justified. For example, if you combine a 10MB audio file with a 5kB text file and could be able to compress the text to 1kB (which is probably much better than what you'd achieve in reality), the complete size of the data bundle would only be reduced from 10.005MB to 10.001MB, or by 0.04%.

    If the amount of text is generally so high, that you can justify the compression, Android supports inflate/deflate and gzip using the standard Android API. There are also 3rd party Java libraries for bzip2 and lzma(2), which I suppose would compile without modifications for Android (I haven't tried though). A quick Google search finds gzip, bzip2 and lzma implementations for Go as well.

    These algorithms generally compress the data better at the cost of higher computing costs and memory requirements in this order: deflate, gzip, bzip2, lzma. Especially the lzma encoder/decoder may require more memory than actually available to an Android application. Especially the compressor requires relatively much memory, the decoder not so much if you keep to smaller dictionaries.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器