Author Topic: wrong duration for video/x-msvideo  (Read 3806 times)

phani

  • Newbie
  • *
  • Posts: 5
wrong duration for video/x-msvideo
« on: February 08, 2012, 10:55:14 AM »
I am trying to use the perl module to get video info.
One of the test videos I have is showing the wrong duration.
videolan and other players are showing the correct duration of around 2 hours

Can you help me figure this out?
Thanks
Phani

INFO dump from Exiftool
MIMEType => video/x-msvideo
VideoFrameRate => 23.976
ImageLength => 1167360
FileType => AVI
FilePermissions => rw-rw-rw-
ExifToolVersion => 8.77
StreamType (1) => Audio
Directory => test
ImageHeight => 304
FileName => test.avi
VideoFrameCount => 181416
NumImportantColors => All
SampleSize (1) => Variable
FrameRate => 23.976
StreamType => Video
Encoding => MP3
FileModifyDate => 2011:05:01 15:46:58-05:00
NumColors => Use BitDepth
BitDepth => 12
AudioCodec =>
Quality => 10000
FileSize => 693 MB
StreamCount => 2
Duration => 26.57 s
TotalFrameCount => 181416
AudioSampleCount => 210182
Software => AVI-Mux GUI 1.17.7, Aug  8 2006  20:59:17
ImageSize => 640x304

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16910
    • ExifTool Home Page
Re: wrong duration for video/x-msvideo
« Reply #1 on: February 08, 2012, 12:32:20 PM »
Hi Phani,

Thanks for this report, but I can't understand why ExifTool reports a duration for this video.

For AVI videos, the Duration calculation relies on having either FrameCount and FrameRate, or AvgBytesPerSec and FileSize.

Your metadata is missing both FrameCount (although VideoFrameCount does exist), and AvgBytesPerSec.

What does the command "exiftool -framecount FILE" give for this video?

Also, it may be useful if you could post the "exiftool -v" output for this file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

phani

  • Newbie
  • *
  • Posts: 5
Re: wrong duration for video/x-msvideo
« Reply #2 on: February 08, 2012, 03:41:05 PM »
Hi Phil ,
Thanks for the reply:
The requested output:

exiftool -framecount test.avi
Frame Count                     : 637


exiftool -v:
  ExifToolVersion = 8.77
  FileName = test.avi
  Directory = test
  FileSize = 727044246
  FileModifyDate = 1304282818
  FilePermissions = 33206
  FileType = AVI
  MIMEType = video/x-msvideo
RIFF 'LIST_hdrl' chunk (65430 bytes of data):
  Hdrl (SubDirectory) -->
  + [Hdrl directory, 65430 bytes]
  | AVIHeader (SubDirectory) -->
  | + [BinaryData directory, 56 bytes]
  | | FrameRate = 41708
  | | MaxDataRate = 0
  | | FrameCount = 637
  | | StreamCount = 2
  | | ImageWidth = 640
  | | ImageHeight = 304
  | Stream (SubDirectory) -->
  | + [Stream directory, 368 bytes]
  | | StreamHeader (SubDirectory) -->
  | | + [BinaryData directory, 56 bytes]
  | | | StreamType = vids
  | | | VideoCodec = xvid
  | | | VideoFrameRate = 0.0417083
  | | | VideoFrameCount = 181416
  | | | Quality = 10000
  | | | SampleSize = 0
  | | VideoFormat (SubDirectory) -->
  | | + [BinaryData directory, 40 bytes]
  | | | ImageWidth = 640
  | | | ImageHeight = 304
  | | | Planes = 1
  | | | BitDepth = 12
  | | | Compression = 1145656920
  | | | ImageLength = 1167360
  | | | PixelsPerMeterX = 0
  | | | PixelsPerMeterY = 0
  | | | NumColors = 0
  | | | NumImportantColors = 0
  | | RIFF_Stream_indx = ..00dc.....}..%?.....8RIw....;:....@...:.5{.(..a:....8.
.C;..T.[snip]
  | Stream (SubDirectory) -->
  | + [Stream directory, 392 bytes]
  | | StreamHeader (SubDirectory) -->
  | | + [BinaryData directory, 56 bytes]
  | | | StreamType = auds
  | | | AudioCodec =
  | | | AudioSampleRate = 0.036
  | | | AudioSampleCount = 210182
  | | | Quality = 4294967295
  | | | SampleSize = 0
  | | AudioFormat (SubDirectory) -->
  | | + [BinaryData directory, 30 bytes]
  | | | Encoding = 85
  | | | NumChannels = 2
  | | | SampleRate = 32000
  | | | AvgBytesPerSec = 10000
  | | | BitsPerSample = 0
  | | StreamName = dT802_0ch192KbpsDELAY0ms
  | | RIFF_Stream_indx = ..01wb...`.....@.....AJ.y....vC........C6.}.0...C....h%
..D~.V.[snip]
  | OpenDML (SubDirectory) -->
  | + [OpenDML directory, 256 bytes]
  | | ExtendedAVIHeader (SubDirectory) -->
  | | + [BinaryData directory, 248 bytes]
  | | | TotalFrameCount = 181416
  | RIFF_Hdrl_JUNK =
RIFF 'LIST_INFO' chunk (58 bytes of data):
  Info (SubDirectory) -->
  + [Info directory, 58 bytes]
  | Software = AVI-Mux GUI 1.17.7, Aug  8 2006  20:59:17
RIFF 'LIST_movi' chunk (1162872 bytes of data):
RIFF 'idx1' chunk (22096 bytes of data):
RIFF 'RIFF' chunk (725793726 bytes of data):
RIFF 'LIST_movi' chunk (725793710 bytes of data):


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16910
    • ExifTool Home Page
Re: wrong duration for video/x-msvideo
« Reply #3 on: February 08, 2012, 03:50:47 PM »
Oh.  FrameCount does exist.  (It wasn't there in your last output.)

The AVI header shows a FrameRate of 1000000/41708 = 23.97 frames per second, and a frame count of 637.

So the total duration of the video according to the AVI header is 637 / 23.97 = 26.57 seconds.  This is the value that ExifTool is reporting.

You could say that ExifTool should use the VideoFrameCount of 181416 instead of the FrameCount of 637, but unfortunately the VideoFrameCount is less reliable (many cameras don't write this value properly).

Other than parsing the entire video stream to determine the actual length (which ExifTool doesn't do because it would be too slow), I don't know what I can do.  ExifTool relies on the metadata stored in the video, and it seems like it just isn't written correctly for this video.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).