0

I have used two wrappers now to try to extract an ISO file. But no success

I have tried sevenzipsharp and C-NET-Interface-for-7-Zip-Archive-DLLs But they both give this same Exception. The ISO file contains .vob files(movies) and the total size of the ISO file is 4.35GB. When I try to extract a single .vob file of 1GB from it, I get Out of Memory Exception.

I actually want to extract the .vob files and then stream them over Upnp/DLNA

    SevenZipExtractor Extractor;
    try
      {
         String[] FileNames = RawFileExtractor(path, out Extractor);
         Extractor.ExtractFile(FileNames[8], ms) //the 1GB file: exception is here
      }
    catch{}
    Extractor.Dispose();
Cœur
  • 37,241
  • 25
  • 195
  • 267
electricalbah
  • 2,227
  • 2
  • 22
  • 36
  • Are you using the 64-bit native libraries from 7-zip? Can you extract the ISO file using the 7-zip command line, GUI or shell extension? – Anders Gustafsson Nov 20 '13 at 10:21
  • I'm using 32 bit and my app is 32 bit version. Actually the code works if I try to extract a smaller .vob file from the ISo file. – electricalbah Nov 20 '13 at 10:25
  • If the entire file is kept in-memory at some point, you can't handle files of that size within 32 bits. – Anders Gustafsson Nov 20 '13 at 10:31
  • So, how much memory does it use and how much do you have? Extracting a 1GB file to memory will make at least one copy... 2GB gone just for that one file. – nvoigt Nov 20 '13 at 10:32
  • My Ram is 8GB and my C Drive has 4GB remaining. Is there a better way to do this ISO extraction and streaming in c#? I am now afraid that even if I meet the conditions, users of my program may not? – electricalbah Nov 20 '13 at 10:41

1 Answers1

0
     Extractor.ExtractFile(FileNames[8], ms)

Can't see "ms" but it is guessable at a MemoryStream. That indeed is not going to work so well with a jiggabyte file. Very likely to get an OutOfMemoryException when your program runs as a 32-bit process. Easy enough to fix on your machine, you've to the horsepower. Project + Properties, Build tab, select AnyCPU and untick "Prefer 32-bit" if you see it.

Still very wasteful and not exactly guaranteed to work on your user's machine if he doesn't have a 64-bit operating system. Pretty unclear what you are actually doing with that MemoryStream, high odds that you should use a FileStream instead so it is directly extracted to the disk. You'll use 4096 bytes instead of a jiggabyte. A video player doesn't care if it plays from memory or the disk. Also review the wisdom of compressing video, it is already compressed by the encoder.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • Thank you for your answer, My main problem is not still solved but atleast the out of memory problem was caused by loading the stream in memory. Now I tried to sned the stream directly to the client socket stream as shown here Extractor.ExtractFile(FileNames[8], request.Socket.GetStream()); I still get socket Exception but a huge part of the stream is received by the Client. Is there any suggestion of how I can accomplish this safely. 1) I need to open the ISO file using 7zip(takes a file path as input) and stream as output. 2) then stream this oput put to the client socket. – electricalbah Nov 21 '13 at 03:02