下载时解压压缩包

发布于 2024-11-17 14:55:51 字数 273 浏览 16 评论 0原文

我有一个程序可以下载通过互联网分割的 rar 文件的第 01 部分,然后是第 02 部分等。 我的程序首先下载part01,然后下载part02,依此类推。 经过一些测试,我发现使用例如 UnRAR2 for python,我可以提取存档中包含的文件的第一部分(.avi 文件),并且我可以在前几分钟播放它。当我添加另一个文件时,它会提取更多内容,依此类推。我想知道的是:是否可以在下载单个文件时提取它们? 我需要它开始提取part01,而不必等待它完成下载......这可能吗?

非常感谢!

马泰奥

I've got a program that downloads part01, then part02 etc of a rar file split across the internet.
My program downloads part01 first, then part02 and so on.
After some tests, I found out that using, on example, UnRAR2 for python I can extract the first part of the file (an .avi file) contained in the archive and I'm able to play it for the first minutes. When I add another file it extracts a bit more and so on. What I wonder is: is it possible to make it extract single files WHILE downloading them?
I'd need it to start extracting part01 without having to wait for it to finish downloading... is that possible?

Thank you very much!

Matteo

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

破晓 2024-11-24 14:55:51

您正在谈论 rar 档案中的 .avi 文件。您确定档案确实被压缩了吗? warez 场景发布的视频文件不使用压缩:

由于文件较大,翻录的电影仍会打包,但不允许压缩,并且 RAR 格式仅用作容器。因此,现代播放软件可以轻松地直接从打包文件播放版本,甚至可以在下载版本时进行流式传输(如果网络足够快)。

(我正在考虑 VLC、BSPlayer、KMPlayer、Dziobas Rar Player、rarfilesource、rarfs,...)
您可以按如下方式检查压缩情况:

  • 在 WinRAR 中打开第一个 .rar 存档。 (name.part01.rar 或 name.rar 表示旧式卷名称
  • 单击信息按钮。

如果要提取的版本指示2.0,则存档不使用压缩。 (除非您有十年前的 rars)您可以看到总大小打包大小将相等。

是否可以解压
下载单个文件时?

是。当不使用压缩时,您可以编写自己的程序来提取文件。 (我知道有人编写了一个脚本来直接从外部 rar 文件下载电影;但它不是公开的,我也没有。)因为你提到了 Python,所以我建议你看一下 rarfile 2.2 由 Marko Kreen 编写,如 pyarrfs 做到了。存档只是添加了标头(rar 块)的切碎文件。这将是一个复制操作,您需要暂停直到下载下一个存档。

我坚信压缩文件也是可能的。您此处的方法会有所不同,因为您必须使用 unrar 来提取压缩文件。我必须补充一点,还有一个免费的 RARv3 实现 提取 The Unarchiver 中实现的 rars。

我认为 (un)rar 的这个参数将使之成为可能:

-vp 在每个卷之前暂停

        默认情况下,RAR 在创建之前要求确认
        或仅为可移动磁盘解压缩下一个卷。
        此开关强制 RAR 始终询问此类确认。
        如果磁盘空间有限并且您希望的话,它会很有用
        立即将每个卷复制到另一个媒体
        创建。

它将使您可以暂停提取,直到下载下一个存档。

我相信如果 rar 是在启用“solid”选项的情况下创建的,这将不起作用。

当solid选项用于rars时,所有打包文件都被视为一个大文件流。如果您始终从第一个文件开始,即使它不包含您要提取的文件,这也不会导致任何问题。
我还认为它可以与密码档案一起使用。

You are talking about an .avi file inside the rar archives. Are you sure the archives are actually compressed? Video files released by the warez scene do not use compression:

Ripped movies are still packaged due to the large filesize, but compression is disallowed and the RAR format is used only as a container. Because of this, modern playback software can easily play a release directly from the packaged files, and even stream it as the release is downloaded (if the network is fast enough).

(I'm thinking VLC, BSPlayer, KMPlayer, Dziobas Rar Player, rarfilesource, rarfs,...)
You can check for the compression as follows:

  • Open the first .rar archive in WinRAR. (name.part01.rar or name.rar for old style volumes names)
  • Click the info button.

If Version to extract indicates 2.0, then the archive uses no compression. (unless you have decade old rars) You can see Total size and Packed size will be equal.

is it possible to make it extract
single files WHILE downloading them?

Yes. When no compression is used, you can write your own program to extract the files. (I know of someone who wrote a script to directly download the movie from external rar files; but it's not public and I don't have it.) Because you mentioned Python I suggest you take a look at rarfile 2.2 by Marko Kreen like the author of pyarrfs did. The archive is just the file chopped up with headers (rar blocks) added. It will be a copy operation that you need to pause until the next archive is downloaded.

I strongly believe it is also possible for compressed files. Your approach here will be different because you must use unrar to extract the compressed files. I have to add that there is also a free RARv3 implementation to extract rars implemented in The Unarchiver.

I think this parameter for (un)rar will make it possible:

-vp     Pause before each volume

        By default RAR asks for confirmation before creating
        or unpacking next volume only for removable disks.
        This switch forces RAR to ask such confirmation always.
        It can be useful if disk space is limited and you wish
        to copy each volume to another media immediately after
        creation.

It will give you the possibility to pause the extraction until the next archive is downloaded.

I believe that this won't work if the rar was created with the 'solid' option enabled.

When the solid option is used for rars, all packed files are treated as one big file stream. This should not cause any problems if you always start from the first file even if it doesn't contain the file you want to extract.
I also think it will work with passworded archives.

山田美奈子 2024-11-24 14:55:51

我非常怀疑。根据压缩的本质(根据我的理解),需要每一比特来解压缩它。看来您下载的来源在压缩之前故意将 avi 分成几部分,但是当您应用压缩时,您压缩的任何内容现在都是一个原子单元。所以他们好心地将整个 avi 分成多个部分,但每个部分仍然是一个原子尼特。

但我不是压缩方面的专家。

我目前能想到的唯一测试是这样的: curl http://example.com/Part01 |解压

I highly doubt it. By nature of compression (from my understanding), every bit is needed to uncompress it. It seems that the source of where you are downloading from has intentionally broken the avi into pieces before compression, but by the time you apply compression, whatever you compressed is now one atomic unit. So they kindly broke the whole avi into Parts, but each Part is still an atomic nit.

But I'm not an expert in compression.

The only test I can currently think of is something like: curl http://example.com/Part01 | unrar.

我做我的改变 2024-11-24 14:55:51

我不知道这是否是针对特定语言提出的,但可以直接从互联网传输压缩的 RAR 并即时解压缩。我可以使用我的 C# 库 http://sharpcompress.codeplex.com/

RAR 格式实际上很友好不错的。它在每个条目之前都有标头,并且压缩数据本身不需要对字节流进行随机访问。

执行多部分文件,您必须首先完全提取第 1 部分,然后在第 2 部分可用时继续写入。

所有这一切都可以通过我的 RarReader API 实现。固体存档也是可流式传输的(事实上,它们只是可流式传输的。您不能随机访问固体存档中的文件。您几乎必须一次将它们全部提取出来。)

I don't know if this was asked with a specific language in mind, but it is possible to stream a compressed RAR directly from the internet and have it decompressed on the fly. I can do this with my C# library http://sharpcompress.codeplex.com/

The RAR format is actually kind of nice. It has headers preceding each entry and the compressed data itself does not require random access on the stream of bytes.

Do it multi-part files, you'd have to fully extract part 1 first, then continue writing when part 2 is available.

All of this is possible with my RarReader API. Solid archive are also streamable (in fact, they're only streamable. You can't randomly access files in a solid archive. You pretty much have to extract them all at once.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文