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.
views:
1574answers:
4I 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)
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.)