tags:

views:

1574

answers:

4

I have C# .net client on windows and need to extract start timecode and duration/length metadata from a .mov file. Anyone out there who knows how to do it? I looked around on net but not found anything yet. Thanks in advance for your time.

A: 

I don't know of any C# library that is able to parse .mov files. Can you call unmanaged code in your environment? (requires FullTrust permissions)

It's really hard to parse the files yourself (we did that once in a DirectShow filter), so I recommend to use a library to do the job for you. Look for example at MediaInfo or ffmpeg

The MP4 container is very similar to .mov files, so you can also use MP4 tools like mp4box to extract very detailed information (e.g. for the start timecode)

chris166
Yes, I can call unmanaged code in my environment.I looked at MediaInfo and ffmpeg and don't see timecode and length attibutes. I am new to this can you tell me if I am missing something? Thanks!
In the GUI version of MediaInfo, you can change the view to show more details. I usually use the 'Tree' view.
chris166
I need to get the two attributes (start timecode and lenght) programatically, you think I can do it using MediaInfo? TIA
I've never done that, but the duration should be possible. The stream start time (i.e. the timestamp of the first sample) is harder. Don't know if MediaInfo can do it. Since .mov is very similar to .mp4 you can probably use mp4box for that (see above, I'll edit my answer)
chris166
+1  A: 

This code example should get you started.

MusiGenesis
A: 

If you can call unmanaged code, you might be able to just use QuickTime for Windows to get this information.

Failing that, all the information you want is in the movie header atom. All QuickTime movies start at time 0 (so there's half the problem solved) and end at their specified duration, which is equal to that of its longest track. Time is specified in terms of the movie time scale, which defines the number of time units per second; the default is 600 units per second.

You find the movie time scale and duration by scanning the file for the movie header atom, whose type is 'mvhd', and then skipping forward to the time scale and duration fields of the atom, which are 16 bytes past the start of the atom type field (the 'mvhd' that you found). Each is a big-endian 4-byte unsigned integer.

QuickTime is a container format, however, and not all movie files contain a movie header. Some are simply reference or streaming movies that point to some other location where the actual movie data resides. Even if the movie header is present, there's no requirement that it actually head the file's data.

You can read way too much about the QuickTime file format in the QuickTime File Format Specification. (The MPEG-4 file format is actually based on the QuickTime file format, so if you know anything about that, the knowledge should transfer.)

Jeremy W. Sherman
A: 

Do you have resolved the problem to read the timecode with C#?

Whiskyfire