IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> calculate average bitrate
gladglam
post Nov 18 2017, 20:36
Post #1


Member


Group: Full Members
Posts: 5
Joined: 18-November 17
Member No.: 24186
Mp3tag Version: 2.84a



Hi. I recently tried to create .nfos with some homemade template heavily borrowing from existing scripts since scripting isn't my area of expertise biggrin.gif

One thing I can't make work and I have no clue why is calculating average bitrate. I stole the "looping add and divide" formula from old scripts found in this forum section, the addition part works, not the division...

ie this is supposed to display the average number :
$loop(%_filename_ext%)$puts(Vbitrate,$add($get(Vbitrate),%_bitrate%))$puts(cnt1,$add($get(cnt1),1))$loopend()$div($get(Vbitrate),get(cnt1))

but all I get is numbers around of above 10000 for standard flac 16-44 or typically 3200 for say a ten tracks album @ 320k (it's sure useless to calculate average for CBR by definition, it's just to show what's calculated)
so either the division function must be called differently or the cnt1 number/divider is stuck to one...

what am I missing ?
Go to the top of the page
 
+Quote Post
gladglam
post Nov 18 2017, 20:51
Post #2


Member


Group: Full Members
Posts: 5
Joined: 18-November 17
Member No.: 24186
Mp3tag Version: 2.84a



ah, forget it, found the missing character, it's $get(cnt1) at the end, not get(cnt1)
Go to the top of the page
 
+Quote Post
gladglam
post Dec 2 2017, 14:02
Post #3


Member


Group: Full Members
Posts: 5
Joined: 18-November 17
Member No.: 24186
Mp3tag Version: 2.84a



me again...

the formula above is "okayish", but I soon noticed variations, sometiimes huge ones, with bitrate indicated by foobar for instance. and I (think I) understand it has to do with track lengths. Foobar takes that into account (as it should) while the script above doesn't care and just divides by track numbers. So if you have say 2 indexes, 1mn interlude @ 300k, then one 20mn piece @ 900k, the script will give average 600k while foobar will more accurately report something much closer to 900...

so in short : is there a way to script an average bitrate taking track timings into accounts ?
meaning
-each track bitrate should be multiplied with individual length in seconds
-added to previous one till last track (that part doesn"t change)
then the whole should be divided by global timing in seconds.

This post has been edited by gladglam: Dec 2 2017, 14:06
Go to the top of the page
 
+Quote Post
DetlevD
post Dec 2 2017, 14:30
Post #4


Member


Group: Full Members
Posts: 6750
Joined: 26-May 06
From: Wuppertal, Germany, Planet Earth
Member No.: 3194
Mp3tag Version: 2.85



QUOTE (gladglam @ Dec 2 2017, 14:02) *
... is there a way to script an average bitrate taking track timings into accounts ? ...

Hmm, you may do such mathematics within an export script, which can create for example a CSV text file, which provides all the related data like filename and the other calculated data, for later import.

As a starting point ... to calculate average bitrate ...

$filename($getEnv('USERPROFILE')'\Desktop\Mp3tag.Report.Bitrate.txt',UTF-8)
$loop(%_path%)$puts(SUMBITRATE,$add($get(SUMBITRATE),%_bitrate%))$puts(SUMTRACKS,$if(%_bitrate%,$add($get(SUMTRACKS),1),$get(SUMTRACKS)))$loopend()
'Max Tracks     : '%_max_counter%
'Sum Bitrate    : '$get(SUMBITRATE)
'Sum Tracks (BR): '$get(SUMTRACKS)
'Average Bitrate: '$div($get(SUMBITRATE),$get(SUMTRACKS))


DD.20171202.1500.CET

This post has been edited by DetlevD: Dec 2 2017, 15:01


--------------------
* Beyond that, don't ask, when you don't know what to do with the answer. *
♥ home is where the heart is ♥
Go to the top of the page
 
+Quote Post
gladglam
post Dec 2 2017, 15:00
Post #5


Member


Group: Full Members
Posts: 5
Joined: 18-November 17
Member No.: 24186
Mp3tag Version: 2.84a



can't we just do it within the loop without export->import ??

I see you mentionned %_length_seconds% in another thread, can't we just use this for each track "mul"tiplication and add it to the global counter ? (cnt1 becoming total length instead of total tracks and used for final division) I now zilch about scripting but I don't see any obstacle, just clueless about the required syntax...
it's just (bitrate-x1*seconds+bitrate-x2*seconds+bitrate-x3*seconds, etc, loop till last track)/(total seconds)
if %_length_seconds% can be used as numeric value, where is the obstacle ?

This post has been edited by gladglam: Dec 2 2017, 15:08
Go to the top of the page
 
+Quote Post
gladglam
post Dec 3 2017, 13:36
Post #6


Member


Group: Full Members
Posts: 5
Joined: 18-November 17
Member No.: 24186
Mp3tag Version: 2.84a



Ok I did it myself, %_length_seconds% works wonders, nothing to export/re-import
you just have to replace the average bitrate formula this way :

OLD formula

$loop(%_filename_ext%)
$puts(Vbitrate,$add($get(Vbitrate),%_bitrate%))
$puts(cnt1,$add($get(cnt1),1))
$loopend()
$div($get(Vbitrate),$get(cnt1))


NEW formula

$loop(%_filename_ext%)
$puts(Vbitrate,$add($get(Vbitrate),$mul(%_bitrate%,%_length_seconds%)))
$puts(cnt1,$add($get(cnt1),%_length_seconds%))
loopend()
$div($get(Vbitrate),$get(cnt1))

This post has been edited by gladglam: Dec 3 2017, 13:37
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 16th January 2018 - 08:50