1

I'm in a situation where I'd like to, using C#, look at .iso files that are in a directory and determine if they are indeed video discs (DVD/BD or similar).

I don't need to actually distinguish the type, just a blanket "yes this is a video disc". Is there a way to do this?

Redshirt
  • 654
  • 7
  • 25
  • 1
    .ISO is not a video format. It's an extension used to identify a CD or DVD image, which may contain video or not. See http://en.wikipedia.org/wiki/ISO_image – MPelletier Oct 12 '11 at 20:41
  • right. I'm looking for a way to look at a disc image and determine if it's a movie and not a playstation 2 game for example. – Redshirt Oct 12 '11 at 20:45

4 Answers4

2

the ISO file is actually a CD Image in file format. The easiest way to determine what is on it is to mount it with a Virtual CD program. Or you can look at the file contents.

Here is the Specifications for ISO files http://users.telenet.be/it3.consultants.bvba/handouts/ISO9960.html

After you are able to determine what information is on the disk then you can determine if there is video information on it by finding out what the contents of those files are.

That is a much more daunting task then just determining the file structure.

This specification file will only define ISO files. Other cd formats will need to be read using their own Specifications...

You can determine if the file is of type ISO using the header data

Here is a Stack Question explaining in a little more detail.

Using .NET, how can you find the mime type of a file based on the file signature not the extension

EDIT

Looking into the Mime type thing a little more reveals that Microsoft will have to have a registered mime type for that header data. It may not know that it is an ISO and may tell you application/octet-stream If this is the case then you can instead use your own judgement with the same first 256 bytes. Determine some things that tell you that it is an ISO file that you can handle. Usually you can tell what type and version a file is with the first 20 bytes or so.

Community
  • 1
  • 1
The Lazy Coder
  • 10,822
  • 4
  • 47
  • 69
  • It's possible that hundreds of .iso files could end up being parsed, negatively affecting performance of the application if I mount each in turn. I think your suggestion to look at the contents. Specifically the header may be the way to go. – Redshirt Oct 12 '11 at 21:03
  • bear in mind that this specification will only work on ISO files. other cd images have their own formats. You will have to build a parser for each one. Lucily most files give you a bit of information within the first 256 bytes that tells you what type of file it is. This is the data that operating systems like Macintosh and Linux use to determine what type of file something is when it has no extension. I will add a link to determine the file type from header data. – The Lazy Coder Oct 12 '11 at 21:14
  • the way I used the mime type function was to get the files I could work with and check their mime types with this. Then I would verify that they have this mime type before processing the file. – The Lazy Coder Oct 12 '11 at 21:18
  • *sigh* So close... It seems that a lot of the headers of my sample files have garbage in them or all 0's. returning application/octet-stream as the mime type. I guess it's mounting the image and looking at the file structure or nothing. – Redshirt Oct 12 '11 at 22:21
  • open them up in notepad or better yet a hex editor and view the first few bytes. Chances are that it will have the same Character sequence in most of the ISO's that you are using. Then you can verify those first few bytes and build a file structure reader. Or see if you can get an ISO Compression utility that will let you get at the File structure. – The Lazy Coder Oct 12 '11 at 23:10
0

I did some searching around for a library that you could use to read/write ISO files. You just need the read part obviously and this project is something you could probably use http://discutils.codeplex.com/

CraigW
  • 705
  • 4
  • 5
0

As another mentioned, an ISO file contains a file system. The easiest way to read it is to mount it as a virtual drive, using any one of a number of utilities. Once you've mounted it as a drive, then you can determine that it likely contains a movie by inspecting the file system (i.e. using Directory.GetFiles and similar methods in C#).

If you want to read the file's contents directly (without mounting it), I'm not sure what to tell you. I've heard that 7-zip has an API that will let you read the files. You might also check out DiscUtils, which claims to be able to read ISO files.

Once you can read the contents of the file system, see the "Filesystem" section of http://en.wikipedia.org/wiki/DVD-Video. That will tell you what files and directories you should expect to see in the ISO of a DVD movie.

Note that the files' existence is an indication that the image probably contains a DVD movie. There's no way to tell for sure without examining the files' contents individually. Tracking down the specifications for the individual file types might be a more difficult task.

Jim Mischel
  • 122,159
  • 16
  • 161
  • 305
0

try using IMAPIv2 to interrogate the iso.

This link doesnt do that.. but it should get you started in the right direction.

How to create optical ISO using IMAPIv2

Sam Axe
  • 31,472
  • 7
  • 52
  • 80