DETERMINE the duration of an MP3 audio file

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

DETERMINE the duration of an MP3 audio file

Post by ChrisGreaves »

There are numerous VBA samples for reading the duration of an audio file from the stored file properties, but I've not seen of a method to determine the duration of a file when the duration has not been lodged with the file in the first place. (see screen snapshot below)
Size-in-bytes is a rough guide, but MP3 files vary in construction, I gather: method of compression, also I assume that there is a fixed overhead.
I have been using, as a rough guide, a factor of 7000 bytes per millisecond (I divide the file size in bytes by 7 and then SLEEP the program for that many milliseconds).
Hans has previously pointed to John Walkenbach's DisplayMP3Info procedure, which works fine ( :artist: ) except that it cannot read the duration from the file information if the information has not previously been stored there.

I need a reasonably good way to partition a set of files into groups that will constitute about 80 minutes playing time; I will MOVE each group from a source folder into individual BURN folders prior to using CDBurnerXP to create CDs that are chock-full of music.
Untitled.png
You do not have the required permissions to view the files attached to this post.
Last edited by ChrisGreaves on 25 Nov 2013, 01:17, edited 1 time in total.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DETERMINE the duration of an MP3 audio file

Post by HansV »

John Walkenbach has a newer version of that workbook - see MP3 File Lister. It works OK for me on Windows 7.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: DETERMINE the duration of an MP3 audio file

Post by ChrisGreaves »

HansV wrote:John Walkenbach has a newer version of that workbook - see MP3 File Lister. It works OK for me on Windows 7.
Thanks Hans, I'll take a look.
(Minutes later: :clapping: :fanfare: :cheers: :chocciebar: :artist: :thankyou: (see image below))

In the meantime I RTM :angel: and discovered that CDBurnerXP will burn to multiple CDs, "Disk Spanning" they call it.
http://www.howtogeek.com/76264/how-to-burn-data-across-multiple-dvd-or-cd-discs/
Untitled.png
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: DETERMINE the duration of an MP3 audio file

Post by Rudi »

So strange to see the "B:\" drive listing...

:whisper: Don't tell me your music is still being stored on those old 3.5" floppies???
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: DETERMINE the duration of an MP3 audio file

Post by ChrisGreaves »

Rudi wrote:So strange to see the "B:\" drive listing... :whisper: Don't tell me your music is still being stored on those old 3.5" floppies???
Anything for you, Rudi.
OK: "My music is not still being stored on those old 3.5 inch floppies" (although you did ask me NOT to tell you that they WERE ...).

No. The B-drive on my computer is a SUBST drive, points to a folder on my T drive.

Code: Select all

::
:: Make the daily blotter folder as drive "B"lotter
::
		call T:\BatLap\setdate
		call T:\BatLap\settime
		T:
		CD T:\Blotter\
		if exist %yr%%mt%%dy% GoTo NotFirstBoot
		echo First boot
		MD %yr%%mt%%dy%
		subst B: T:\Blotter\%Daily%
%pause%
		call T:\BatLap\Lap_FirstBoot.bat
%pause%

:NotFirstBoot
		subst B: T:\Blotter\%Daily%

%pause%
Today the B: points to "T:\Blotter\20131125\", and will be used as a throw-away area for experimental files; typical use is storing, from MSPaint, the Untitled.PNG which will be used for a few minutes only to u/l an image to The Lounge. Or even over a period of about 48 hours, a duplicate copy of MP3 files which will be automatically tagged my my latest whiz-bang efforts in Word VBA.

"Blotter" because I am (ahem!) old enough to remember the cleaning ladies who removed the top sheet of blotting paper from the holder on the executive's desk. The top sheet carried yesterday's doodles & scribblings, and important phone numbers before they were copied into the back of the executive's (paper) diary.

T: is, of course, the drive letter of the TrueCrypt drive once I've entered in the appropriate password.

Code: Select all

::
::	Mount the encrypted drive
::
		if not exist T: "C:\Program Files\TrueCrypt\TrueCrypt.exe" /q /lT  /v\Device\Harddisk0\Partition3
It all is well-managed by a finely-tuned set of DOS batch files.

Which are themselves backed up by one of their own!

Code: Select all

title %0 - robocopy t:\ y:\LAP291  /s /r:0 /w:0
:: Backing up the current data to the old backup.

set pause=

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /q /lY  /v\Device\Harddisk2\Partition1
%pause%

if exist Y:\nul goto 20Backup
echo I could not mount the backup drive
pause
goto 99exit

:20Backup
robocopy t:\ y:\LAP291  /s /r:0 /w:0
%pause%

"C:\Program Files\TrueCrypt\TrueCrypt.exe" /dismount Y /force /q
%pause%

:99exit
There's nothing heavier than an empty water bottle

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: DETERMINE the duration of an MP3 audio file

Post by Rudi »

Wow...that is a lengthy (and detailed) reply Chris.
I feel quite guilty replying with a simple .... OK. :laugh:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15640
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: DETERMINE the duration of an MP3 audio file

Post by ChrisGreaves »

Rudi wrote:Wow...that is a lengthy (and detailed) reply Chris.
I feel quite guilty replying with a simple .... OK. :laugh:
To B: or not to B:, that is the (driving) question ...
Whether 'tis nobler in the RamDisk [ed: Thanks Chris; we'll let you know ...]
There's nothing heavier than an empty water bottle