PDA

View Full Version : Incorrect Audio Lengths! Help!



Haydeng
03-22-2007, 06:43 PM
For some reason my for some of my songs, it says that they are longer then they actually are. For instance, I have a 3:42 song, however my label says its 7:14. Thats more then 4 minutes longer. This incorrect file length makes my progress object for my songs not function properly. It only does it for SOME songs not ALL.

Any ideas?

RizlaUK
03-22-2007, 07:09 PM
that is strange, iv never had that (yet, lol)

how are you getting the length Audio.GetLength?

all i can suggest is upload one of the suspect tracks and i'll try it in some of my ams audio players (hence, iv made a few, lol)

it might have something to do with the file attributes wich would be unrelated to your code so changing it is useless if it only happens with some of your tracks

EDIT: Are you sure there is nothing in your code that could add to the track time.......just a tought

bule
03-23-2007, 06:31 AM
Have you used CoolEdit/Audition and saved the file as a VBR?

goukilord10
03-23-2007, 09:00 PM
yes vbr files return incorrect length.
only solution media player pluigin :(

srussell
04-19-2007, 11:07 PM
I am consistently seeing longer audio lengths (between 10 - 20 secs) using Audio.GetLength on 3:00 - 4:00 stereo 44 Khz .WAV files... Anyone else seeing this?

CrazyFrog
04-19-2007, 11:20 PM
Seems that the lenght witch is given by the function ( 7:14 ) is double to ( 3:42 ) . Use this :



CurrLength = Augio.GetLength () ;
RealLength = CurrLength / 2 ;

That's all , I hope this is usefull ! :yes

Anyone need a script to convert lenth in seconds , to the format : mm:ss ?

mindstitchdr
04-19-2007, 11:26 PM
Hey CrazyFrog, I'd like to see that script (mm:ss) if you dont mind.

CrazyFrog
04-20-2007, 03:26 AM
Put This Code in " On Audio " Event
the script is :

lengthsec = Audio.GetLength(5);
lengthminex = lengthsec/60;
slengthminex = lengthminex..""
min = Math.Floor(lengthminex);
smin = min.."";
target_index = String.Find(slengthminex.."", ".", 1, false);
safterdot = String.Mid(slengthminex.."", target_index, -1);
safterdotf = String.Concat("0",safterdot.."");
nafterdot = String.ToNumber(safterdotf.."");
nafterdotf = nafterdot*60;
ssec = Math.Floor(nafterdotf);
minsec = String.Concat(min..":",ssec.."");
Label.SetText("totmin", minsec.."");

Sorry for those nasty variables names
I had worked for this code over an hour
It has one Bug that when it should be 4:07 , the code returns 4:7

mindstitchdr
04-20-2007, 09:43 AM
Thanks CrazyFrog, works perfect.

TJ_Tigger
04-20-2007, 10:07 AM
Here is a function that uses string.format to add in the zeroes as necessary. This formats the string from milliseconds.


function MilliSecondsToClock(sMilliSeconds)
local nMilliSeconds = String.ToNumber(sMilliSeconds)
if nMilliSeconds == 0 then
--return nil;
return "00:00:00";
else
nHours = string.format("%02.f", Math.Floor(nMilliSeconds/3600000));
nMins = string.format("%02.f", Math.Floor(nMilliSeconds/60000 - (nHours*60000)));
nSecs = string.format("%02.f", Math.Floor(nMilliSeconds/1000 - nHours*3600000 - nMins *60000));
nMilliSecs = Math.Round(nMilliseconds - (nHours*3600000) - (nMins *60000) - (nSecs *1000))
return nHours..":"..nMins..":"..nSecs.."."..nMilliSecs
end
end

mindstitchdr
04-20-2007, 10:21 AM
Hey TJ_Tigger, I'm having a brain fart, how would I use this with the code above?

TJ_Tigger
04-20-2007, 11:45 AM
Place the above function into your global functions so it gets defined when the project starts. Then when you want to use it get the current position of the song, which if I recall correctly returns milliseconds and place that value into the function and it will return a formatted string.



nMilliSeconds = Audio.GetCurrentPosition() -- or whatever the appropriate command is
sFormattedTime = MilliSecondsToClock(nMilliSeconds)
Label.SetText("Label1", sFormattedTime);

mindstitchdr
04-20-2007, 12:26 PM
function MilliSecondsToClock(sMilliSeconds)
local nMilliSeconds = String.ToNumber(sMilliSeconds)
if nMilliSeconds == 0 then
--return nil;
return "00:00:00";
else
nHours = string.format("%02.f", Math.Floor(nMilliSeconds/3600000));
nMins = string.format("%02.f", Math.Floor(nMilliSeconds/60000 - (nHours*60000)));
nSecs = string.format("%02.f", Math.Floor(nMilliSeconds/1000 - nHours*3600000 - nMins *60000));
nMilliSecs = Math.Round(nMilliSeconds - (nHours*3600000) - (nMins *60000) - (nSecs *1000))
return nHours..":"..nMins..":"..nSecs.."."..nMilliSecs
end
end

Just to let you know there is a Cap problem in red. Thanks for the help TJ_Tigger

mindstitchdr
04-20-2007, 01:18 PM
Ok I'm having another problem that I didn't see when I tested this. The time is coming back as 00:00:00:110. Of course that is an example, but the second,minutes,and hours are not changing only the milliseconds. Am I missing something here?

on my mediaplayer OnPlay action:

Page.StartTimer(1000);

On page OnTimer Action

nMilliSeconds = MediaPlayer.GetLength("Video1");
length = MilliSecondsToClock(nMilliSeconds)
WinButton.SetText("time", length);

Global Function

function MilliSecondsToClock(sMilliSeconds)
local nMilliSeconds = String.ToNumber(sMilliSeconds)
if nMilliSeconds == 0 then
--return nil;
return "00:00:00";
else
nHours = string.format("%02.f", Math.Floor(nMilliSeconds/3600000));
nMins = string.format("%02.f", Math.Floor(nMilliSeconds/60000 - (nHours*60000)));
nSecs = string.format("%02.f", Math.Floor(nMilliSeconds/1000 - nHours*3600000 - nMins *60000));
nMilliSecs = Math.Round(nMilliSeconds - (nHours*3600000) - (nMins *60000) - (nSecs *1000))
return nHours..":"..nMins..":"..nSecs.."."..nMilliSecs
end
end

mindstitchdr
04-21-2007, 03:12 PM
Any help guys?

Haydeng
04-21-2007, 04:26 PM
Seems that the lenght witch is given by the function ( 7:14 ) is double to ( 3:42 ) . Use this :



CurrLength = Augio.GetLength () ;
RealLength = CurrLength / 2 ;

That's all , I hope this is usefull ! :yes

Anyone need a script to convert lenth in seconds , to the format : mm:ss ?

It doesn't mess up on all songs, just a few of them.

CrazyFrog
04-21-2007, 11:42 PM
The few of them.....in what format they are ? MP3 VBR ( Variable Bit Rate ) ?

Haydeng
04-22-2007, 07:37 AM
.mp3, bitrate: 256kbps