Page 2 of 2

Re: Calculate audio playtime

Posted: 23 Mar 2023 00:25
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

Re: Calculate audio playtime

Posted: 23 Mar 2023 06:38
by highend
Try this version:
Calculate audio playtime_v0.5.xys
(6.12 KiB) Downloaded 167 times

Re: Calculate audio playtime

Posted: 23 Mar 2023 15:38
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

Re: Calculate audio playtime

Posted: 23 Mar 2023 16:56
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

Re: Calculate audio playtime

Posted: 23 Mar 2023 18:05
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

Re: Calculate audio playtime

Posted: 23 Mar 2023 18:16
by highend
Looks correct. Used XY version?

Re: Calculate audio playtime

Posted: 23 Mar 2023 19:00
by suslo
i have:
xy-19.40.0100

Re: Calculate audio playtime

Posted: 23 Mar 2023 20:22
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.

Re: Calculate audio playtime

Posted: 23 Mar 2023 21:02
by suslo
highend, thank you for the attempts to help me

Re: Calculate audio playtime

Posted: 24 Mar 2023 01:48
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>"

Re: Calculate audio playtime

Posted: 24 Mar 2023 02:34
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.

Re: Calculate audio playtime

Posted: 24 Mar 2023 03:00
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

Re: Calculate audio playtime

Posted: 24 Mar 2023 03:26
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)

Re: Calculate audio playtime

Posted: 08 Apr 2023 21:10
by Ysl
Hi

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