Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 23rd, 2024, 8:20 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to find the duration of an MP3
PostPosted: October 29th, 2007, 3:16 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I have searched the forum and old forum for how to find the length of an MP3 and there have been many suggestions.
The 'GetLength()' function doesn't work directly on sound files--it's a video script function, however I did read you can load an MP3 into a video object and simply use the GetLength() function, but it didn't work. I could load the MP3, but the returned value was not correct.
I looked at the 'Seek()' function.... thought I could do a Seek("end") then Seek("backward",1), but this doesn't work.

There are programs for reading the MP3 tag and if you look at any MP3 in windows, it will tell you the duration.

I just wondered if anyone has a way of doing it in Opus


Sandy

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: October 29th, 2007, 10:12 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
Change the video type to on-top.

Mack


You do not have the required permissions to view the files attached to this post.

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: October 29th, 2007, 11:37 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Brilliant!!!!

Thanks Mack!!

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: November 6th, 2007, 9:14 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
mackavi wrote:
Change the video type to on-top.

Mack


In your example it displays incorectly and i can even get it to display at all LOL...............could you send it as an IMP instead of an exe..

Thank

Al

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 1:08 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
It's an exe because it contains a function I use in commericial applications to convert between bases but this has no impact on the principle as you simply point the video object to the MP3 (or any other sound file format) and use the GetLenght() object that Sandy got from various other posts.

Have used this many times and never had an issue I can only wonder if something is wrong with the encoding of the audio file - but I've only experienced this with low quaility video.

Can you send me the file that is causing the problem to my email address or if it's a larger file, uploaded it somewhere and send me the link?

Mack

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 9:00 am 
It intrigues me every time this question comes up -- as it has done.

I must be missing something here. I using MP3 and WAV files for voice overs and background music. For voice overs, in my applications, the duration of a file can be critical.

I just play it and time it. Works every time :D

But, I'm sure this is not what you mean :?

Seriously though, there are so many variations in sound files and codecs that it can be easy to run into problems. I'm guessing that Macavi might have hit the nail on the head with the suggestion of a corrupt file.

A few weeks back I needed to work with some WAV files. These should be simple, because they're normally uncomplicated. Nothing worked. After banging my head on the wall, I saw the my app required uncompressed WAV files. More head banging that something so simple had held me up. :oops:


Top
   
 
 Post subject:
PostPosted: November 7th, 2007, 10:18 am 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Mack's EXE works fine--no problem and when I created my own imp to do it--it worked fine.... I can send Al my imp later, but I'm screwed for time just now.


I have been looking at a strange related problem, but I will start another post rather than hijack Al's query.

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Another problem LOL
PostPosted: November 7th, 2007, 2:28 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
sandyn wrote:
Mack's EXE works fine--no problem and when I created my own imp to do it--it worked fine.... I can send Al my imp later, but I'm screwed for time just now.


I have been looking at a strange related problem, but I will start another post rather than hijack Al's query.


Thanks Sandy for offering the imp ( i am patient LOL )i miss ur emails also...did we have a fight or a break up ( just teasing you )

The next problem if you use the Video method to play an MP3 file ( which is excellent ) but it has 1 fault.......What if you have 2 mp3 files running and you want to control the volume for each seperatly . I can't find a way to control the volume for 2 files with using the video method of playing media files ( mp3/video )....any idea's

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 2:45 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
I thought you could get round the problem by creating a publication for each 'video' but as soon as you alter the volume in one, the other changes as well.

so what you can do is just load the sound files as video, start and stop immediately--that's enough to get the length

Code:
Video1.Play()
   Video1.Stop()
MP3Length=Video1.GetLength()




once you have the mp3 length, load it as a sound object and then you can vary the volume of individual sound objects.

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: November 7th, 2007, 3:09 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
sandyn wrote:
I thought you could get round the problem by creating a publication for each 'video' but as soon as you alter the volume in one, the other changes as well.

so what you can do is just load the sound files as video, start and stop immediately--that's enough to get the length

Code:
Video1.Play()
   Video1.Stop()
MP3Length=Video1.GetLength()




Thats Freaking Genius LOL , why didn't I think of that LOL....I will try it

AL

once you have the mp3 length, load it as a sound object and then you can vary the volume of individual sound objects.

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 3:59 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
[quote="al Barnes"][quote="sandyn"]I thought you could get round the problem by creating a publication for each 'video' but as soon as you alter the volume in one, the other changes as well.

so what you can do is just load the sound files as video, start and stop immediately--that's enough to get the length

Code:
Video1.Play()
   Video1.Stop()
MP3Length=Video1.GetLength()





OK ,but how to display the Getlength into a usable format...


As per my attached pic , its shows the getlength as 201.391 , the file it was supposed to display for was like over 3 megs . Back to the drawing table LOL


You do not have the required permissions to view the files attached to this post.

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 4:54 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Yes, start and stop will give the mp3 Length.


The MP3 Length is given in seconds, so you need to convert to minutes and seconds.
so....
a crude way is.... divide the MP3Length by 60 and use
Mins=Math.floor(MP3Length/60)
and
Secs=MP3Length%60 (modulus operator---which gives the remainder of dividing the MP3 length by 60)

there must be a more elegant way than that!!!
You could create a function to do it.---A good exercise for you :-)

So now you would have the length as two variables--Mins and Secs

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: November 7th, 2007, 5:57 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
sandyn wrote:
Yes, start and stop will give the mp3 Length.


The MP3 Length is given in seconds, so you need to convert to minutes and seconds.
so....
a crude way is.... divide the MP3Length by 60 and use
Mins=Math.floor(MP3Length/60)
and
Secs=MP3Length%60 (modulus operator---which gives the remainder of dividing the MP3 length by 60)

there must be a more elegant way than that!!!
You could create a function to do it.---A good exercise for you :-)

So now you would have the length as two variables--Mins and Secs



OK done that ( kinda ), the problem is when i click to start clock on the MP3 and the MP3Length The clock and MP3length show 2 different values LOL......Ex: i have a song that's 2:52 minutes long according to the clock , well its 3:69 as reported by the <MP3Length> variable

I have had to divide the <MP3Length> by 87 to get a close number represnting the actual time reported by the clock . Isn't this weird as seeing the varibale should be reporting the trac length in seconds to begin with .

Thanks for all you help

Al

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: November 7th, 2007, 7:47 pm 
Offline

Joined: November 25th, 2004, 1:24 pm
Posts: 512
Location: Scotland
Opus: 9.75
OS: Win 10
System: Asus i7-7700K 16Gb
Is this the time shown on your clock after the MP3 has been played??


So either the clock is wrong or the reported length of the MP3. You can time the MP3 or-----normally if you mouse-over the file in Windows file explorer, it will show the duration. I'm sure the MP3 length is reported correctly and your clock is wrong.

_________________
Whoever designed this, never actually used it!


For this message sandyn has been thanked by : mackavi


Top
 Profile  
 
 Post subject:
PostPosted: November 7th, 2007, 8:08 pm 
Offline

Joined: February 12th, 2005, 5:27 pm
Posts: 177
Location: Canada
Opus: Pro
OS: Win7
sandyn wrote:
Is this the time shown on your clock after the MP3 has been played??


So either the clock is wrong or the reported length of the MP3. You can time the MP3 or-----normally if you mouse-over the file in Windows file explorer, it will show the duration. I'm sure the MP3 length is reported correctly and your clock is wrong.


The reported time is wrong , the clock is correct as i played the files in Windows Media center to show time display...

Al

_________________
-------------------------------------------------------
Win7 AMD +5000 Dual Core with 4 gig ram Geforce 9600 OPUS V7.05 Novice to Scripts/willing to learn , Mp3 Files must be 128kb


For this message Al Barnes has been thanked by : mackavi


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group