Getting a Whole Number Value from %_bitrate%?

Tags: #<Tag:0x00007f00c0ab2a30> #<Tag:0x00007f00c0ab2508>

I’m trying to figure out how to get a whole value from `%_bitrate%.

,$set(_bitRateValue,$left(%_bitrate%,3))) seems to work except I’m not convinced what happens the value of bitrate is less than three places left of the decimal. xx.xxx

…and when the bitrate is a 4 place value… you’re losing the thousandth position.

When I’ve tried ,$set(_bitRateValue,$left(%_bitrate%,4))) I sometimes get a decimal point which doesn’t work with $lt,lte,gt,gte etc. at all, and using ,3 of course will give me 140 for something that was 1400… so if the bitrate is showing higher than 999 I get bogus values to compare against.

$if($eq(%_bitRateType%,VBR)$set(_fileVBRRate,%_vbrRateValue%) ,
$if($gt(%_vbrRateValue%,319),$set(_fileVBRRate,320+),
$if($gt(%_vbrRateValue%,220),$set(_fileVBRRate,V0),
$if($gt(%_vbrRateValue%,191),$set(_fileVBRRate,V1),
$if($gt(%_vbrRateValue%,170),$set(_fileVBRRate,V2),
$if($gt(%_vbrRateValue%,150),$set(_fileVBRRate,V3),
$if($gt(%_vbrRateValue%,140),$set(_fileVBRRate,V4),
$if($gt(%_vbrRateValue%,130),$set(_fileVBRRate,V5),
$if($gt(%_vbrRateValue%,120),$set(_fileVBRRate,V6),
))))))))) 

You can replace everything starting from the decimal separator to the end of the string with nothing using the rreplace function:

$set(_foobar,$rreplace(%_bitrate%,\\.\\d*\$,))
%_foobar%

(Unfortunately, the mul and div functions restrict their arguments to integers, see PICARD-1713, so you can’t do $div($mul(%_bitrate%,100000),100000)).

2 Likes

Perfect. Now to completely figure out maths actions.

Perhaps I should look at those sort of like RPN.

$set(_theValue,$div(%_someNumberValue%,%_someOtherNumberValue%)
$if($gt(%_theValue%,xxx) … do whatever next.

I -really- need to get regex nailed down too. It’s total voodoo to me… but doesn’t have to be.