hello_hello
11th August 2017, 23:53
Aside from Info(), is there a way to display the total audio and/or video duration with Avisynth? If there is, I haven't been clever enough to find it.
I wanted to display the total duration as part of a function I was playing around with, and not being able to find an easy way, I created a function for converting seconds to HH:MM:SS.
So far it seems to be working fine but my maths isn't the best. Could somebody please confirm I haven't done anything silly (or feel free to suggest a better way)?
For converting seconds to HH:MM:SS format:
function HMSConvert(float sec)
{
Hour = floor(sec/3600)
Minute = floor(sec/60 - Hour*60)
Second = floor(sec - Minute*60 - Hour*3600)
Millisecond = round((sec - floor(sec))*1000)
Hours = string(Hour, "%02.0f")
Minutes = string(Minute, "%02.0f")
Seconds = string(Second, "%02.0f")
Milliseconds = string(Millisecond, "%03.0f")
Converted_Duration = Hours + """ : """ + Minutes + """ : """ + Seconds + """ . """ + Milliseconds
return Converted_Duration
}
Same again except taking the duration info from the AudioDuration() function.
function HMSAudioConvert(clip c)
{
Hour = floor(c.AudioDuration/3600)
Minute = floor(c.AudioDuration/60 - Hour*60)
Second = floor(c.AudioDuration - Minute*60 - Hour*3600)
Millisecond = round((c.AudioDuration - floor(c.AudioDuration))*1000)
Hours = string(Hour, "%02.0f")
Minutes = string(Minute, "%02.0f")
Seconds = string(Second, "%02.0f")
Milliseconds = string(Millisecond, "%03.0f")
Converted_Audio_Duration = Hours + """ : """ + Minutes + """ : """ + Seconds + """ . """ + Milliseconds
return Converted_Audio_Duration
}
Have I done anything silly?
Thanks.
I wanted to display the total duration as part of a function I was playing around with, and not being able to find an easy way, I created a function for converting seconds to HH:MM:SS.
So far it seems to be working fine but my maths isn't the best. Could somebody please confirm I haven't done anything silly (or feel free to suggest a better way)?
For converting seconds to HH:MM:SS format:
function HMSConvert(float sec)
{
Hour = floor(sec/3600)
Minute = floor(sec/60 - Hour*60)
Second = floor(sec - Minute*60 - Hour*3600)
Millisecond = round((sec - floor(sec))*1000)
Hours = string(Hour, "%02.0f")
Minutes = string(Minute, "%02.0f")
Seconds = string(Second, "%02.0f")
Milliseconds = string(Millisecond, "%03.0f")
Converted_Duration = Hours + """ : """ + Minutes + """ : """ + Seconds + """ . """ + Milliseconds
return Converted_Duration
}
Same again except taking the duration info from the AudioDuration() function.
function HMSAudioConvert(clip c)
{
Hour = floor(c.AudioDuration/3600)
Minute = floor(c.AudioDuration/60 - Hour*60)
Second = floor(c.AudioDuration - Minute*60 - Hour*3600)
Millisecond = round((c.AudioDuration - floor(c.AudioDuration))*1000)
Hours = string(Hour, "%02.0f")
Minutes = string(Minute, "%02.0f")
Seconds = string(Second, "%02.0f")
Milliseconds = string(Millisecond, "%03.0f")
Converted_Audio_Duration = Hours + """ : """ + Minutes + """ : """ + Seconds + """ . """ + Milliseconds
return Converted_Audio_Duration
}
Have I done anything silly?
Thanks.