Author Topic: How can i read duration tag in a ogg audio file?  (Read 5862 times)

Mariano Grau

  • Newbie
  • *
  • Posts: 8
How can i read duration tag in a ogg audio file?
« on: July 27, 2012, 12:29:25 PM »
Hi Phil!

My favorite command to read all metadata is:
exiftool -X <file>

So i can easily process the xml file to get metadata.
However, in ogg audio files I not found the file duration tag.
In other formats as wav or mp3 i find the tags QuickTime:Duration or Composite:Duration.


Thanks, Mariano Grau

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17709
    • ExifTool Home Page
Re: How can i read duration tag in a ogg audio file?
« Reply #1 on: July 27, 2012, 12:39:12 PM »
Hi Mariano,

In many a/v file formats Duration is not stored in the metadata.  However, it will attempt to calculate Duration from other extracted information if possible.  If this is possible for your ogg file, then I should add this ability.  Please tell me if you know how to do this.

- 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 ($).

Mariano Grau

  • Newbie
  • *
  • Posts: 8
Re: How can i read duration tag in a ogg audio file?
« Reply #2 on: July 27, 2012, 02:11:19 PM »
Hi Phil,

I have found that VLC calculates the duration of the ogg file from the metada System:FileSize and Vorbis:NominalBitrate according to the formula:

Duration = System:FileSize / Vorbis:NominalBitrate

previous conversion to bits and bits/s

For mp3 uses Composite:AudioBitrate


Thanks, Mariano Grau

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17709
    • ExifTool Home Page
Re: How can i read duration tag in a ogg audio file?
« Reply #3 on: July 27, 2012, 08:15:37 PM »
Hi Mariano,

Thanks.  I'll add a new Composite Duration tag in ExifTool 8.98 which does this calculation.

- 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 ($).

Mariano Grau

  • Newbie
  • *
  • Posts: 8
Re: How can i read duration tag in a ogg audio file?
« Reply #4 on: August 10, 2012, 04:06:04 PM »
Hi Phil,

Thanks you for the speed to incorporate this new feature. I have downloaded the new version.

However, VLC calculates wrong the duration in some ogg files.

It is more correct to use the 'Overall bit rate' metadata than 'Nominal bit rate' for to compute the duration.

Thanks,

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17709
    • ExifTool Home Page
Re: How can i read duration tag in a ogg audio file?
« Reply #5 on: August 10, 2012, 05:02:08 PM »
Hi Mariano,

There is no Vorbis tag called "OverallBitrate" that is extracted by ExifTool.

I can only work with the metadata that is available.  Use "exiftool -a -s FILE" to see what is available, and let me know if there is something better to use than NominalBitrate.

Thanks.

- 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 ($).

Mariano Grau

  • Newbie
  • *
  • Posts: 8
Re: How can i read duration tag in a ogg audio file?
« Reply #6 on: August 10, 2012, 05:51:11 PM »
Hi Phil,

I can not find the metadata OverallBitRate or any similar running "exiftool -a -s FILE" .

This information is showed by mediainfo tool (http://mediainfo.sourceforge.net/en). It is not a vorbis tag but is included in general segment.

U:\Temp>mediainfo video.ogg
General
ID                               : 29949 (0x74FD)
Complete name                    : U:\Temp\video.ogg
Format                           : OGG
File size                        : 34.6 MiB
Duration                         : 3mn 23s
Overall bit rate                 : 1 431 Kbps
Writing application              : ffmpeg2theora-0.28
...


Thanks,
Mariano Grau

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 17709
    • ExifTool Home Page
Re: How can i read duration tag in a ogg audio file?
« Reply #7 on: August 10, 2012, 07:59:10 PM »
This information certainly exists in the video stream data, but ExifTool does not parse the video stream.  So unless this is found in the Vorbis information or somewhere in the Ogg container metadata, then I don't have access to it.

- 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 ($).