Calculate audio playtime

Discuss and share scripts and script files...
suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

XY properties: 28
=================
#LinkTarget =
#ShortcutTarget =
#JunctionTarget =
#ResolveJunctions = E:\DM\G\Gathering\1992 - Always\1.wav
#ResolveJunctionsAll = E:\DM\G\Gathering\1992 - Always\1.wav
#Label =
#Tags =
#Comment =
#HardLinks = 1
#AspectRatio =
#audio.bitdepth = 16-bit
#audio.bitrate = 1411 kBit/s
#audio.channels = 2
#audio.length = 48:21.800
#audio.samplerate = 44100 Hz
#mp3.album =
#mp3.artist =
#mp3.Comments =
#mp3.genre =
#mp3.title =
#mp3.track =
#mp3.year =
#date.created = 2019 08 18 11 52 24
#date.modified = 2019 08 18 11 52 34
#date.accessed = 2019 09 06 15 23 32
#image.dimensions =
#image.datetaken =
#version =

IDs with names & values: 11
===========================
#001 | Size: 499 881 KB
#002 | Type: WAV File
#003 | Date Modified: 2019 08 18 11 52
#004 | Date Created: 2019 08 18 11 52
#005 | Date Accessed: 2019 09 06 15 23
#006 | Attributes: A
#007 | Status: Online
#008 | Owner: Administrators
#022 | Bit Rate: 1411kbps
#033 | Audio sample rate: 44 kHz
#034 | Channels: 2 (stereo)

IDs with names but not a value: 26
==================================
#009 = Author
#010 = Title
#011 = Subject
#012 =
#013 = Pages
#014 = Comments
#015 = Copyright
#016 = Artist
#017 = Album Title
#018 = Year
#019 = Track Number
#020 = Genre
#021 = Duration
#023 = Protected
#024 = Camera Model
#025 = Date Picture Taken
#026 = Dimensions
#029 = Episode Name
#030 =
#031 =
#032 =
#035 = Company
#036 = Description
#037 = File Version
#038 = Product Name
#039 = Product Version

Unused IDs: 2
=============
#027
#028

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Try this version:
Calculate audio playtime_v0.5.xys
(6.12 KiB) Downloaded 49 times
One of my scripts helped you out? Please donate via Paypal

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

i selected 2 wav-files:
1) 10:53.147
2) 6:24.880

v0.5 displays:

Code: Select all

Total playtime: 00 288055555555556:00:17

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Interesting, if I do it with similar files, the computation is fine.

find this line:

Code: Select all

    $start = now("msecs");
Add one line above (indented by at least one space!):

Code: Select all

    text $duration; end true;
Post the output
One of my scripts helped you out? Please donate via Paypal

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

Add one line above

Code: Select all

    text $duration; end true;
    $start = now("msecs");
    // Remove items which don't have a length
    $duration = formatlist($duration, 'tue', '+');
Post the output
0+00:10:53+00:06:24

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

Looks correct. Used XY version?
One of my scripts helped you out? Please donate via Paypal

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

i have:
xy-19.40.0100

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Calculate audio playtime

Post by highend »

I've just tried v19.40.0100 with two selected .wav files (06:24 + 10:53 playtime) and the v0.5 script calculates the result correctly. Sorry, I don't know what's wrong on your system.
One of my scripts helped you out? Please donate via Paypal

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

highend, thank you for the attempts to help me

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

a quick alternate script
jupe, thanks, it is working/displaying:

Code: Select all

00:17:18
i haven't tried to modify your script seriously yet (i also need to see the milliseconds), but i would like to specify:
could this modification be successful?

 
as decimal separator
generally, if i could choose, then the following variant would have been ideal to me:

Code: Select all

17 18 027
(when there are only: minutes, seconds, ms)

 
and if there are hours, minutes, seconds, ms,
then, for example, the ideal variant is:

Code: Select all

67 18 027
(which means: 67 minutes, 18 seconds, 027 ms)

 
 
(kind of off-topic) i wish my version of xy could be customized so that it displayed this total duration right in status-bar,
where i have this:

Code: Select all

StatusBar3OnFile="<curname>                         <datem yyyy mm dd   hh mm ss>                         <prop #audio.length>          <prop #audio.bitdepth>          <prop #audio.samplerate>"

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Calculate audio playtime

Post by jupe »

jupe wrote:I knocked up a quick alternate script If you are interested, since the inbuilt way doesn't work for you this version requires CLI version of MediaInfo, and you need to set the path in the script to it.
I removed my original post (but quoted some of it above), because I thought it might not work (without changes) in locales that don't use the decimal sep, but you had obviously already successfully tried it, anyway I read your requested changes and made some mods, I think something like the below script is what you want (with only minutes no hours + ms), I just did it in a quick janky way, so you may want to clean up the script a bit, but it should do what I think you are requesting.

Code: Select all

  $exe  = "MediaInfo.exe";
  $ms   = eval(trim(runret("""$exe"" --""Inform=General;%Duration%+"" <selitems>", <curitempath>, 65001), "<crlf>+", "R"));
  $secs = $ms / 1000;
  $ms   = substr(gettoken($secs, -1, ".") . "000",, 3);
  $secs = floor($secs);
  $mins = format(floor($secs / 60, "00"));
  $secs = format($secs % 60, "00");
  echo "$mins $secs $ms", "Total:";
Regarding the statusbar, if you pay to upgrade to a recent version of XY, then that is possible, you could test it out first by downloading a portable version, then run it and right click the statusbar and enable "Use Statusbar template" and select some files, but since you had issues with the orig script it may not work out of the box.

suslo
Posts: 178
Joined: 02 Feb 2015 05:02

Re: Calculate audio playtime

Post by suslo »

(with only minutes no hours + ms)
i'm not sure that i understood these words correctly
I just did it in a quick janky way
i appreciate your attention to this topic,

at a first glance:
- this version of script displays hours+minutes as minutes (which is the desired behavior)

- this version displays spaces between minutes/seconds/ms (which is the desired behavior)

- this version displays absolutely incorrect ms

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Calculate audio playtime

Post by jupe »

ms looks ok to me in most cases, but you could try changing the 4th line to something like this:

Code: Select all

  $ms   = regexmatches($secs, "\.") ? substr(gettoken($secs, -1, ".") . "000",, 3) : "000";
I was just providing a rough outline, any further changes are up to you, but with that change it should all work as requested anyway. (unless you don't use a decimal sep in your locale)

Ysl
Posts: 153
Joined: 03 Jan 2007 22:22

Re: Calculate audio playtime

Post by Ysl »

Hi

this look interesting !
Could this script add the timing of the folder to the name of the folder ?
Thanks

Post Reply