Calculate with length of audiofile

Discuss RoboTask here
Post Reply
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Calculate with length of audiofile

Post by Rukbunker »

Hey Oleg,

I'm using sox in combination with Robotask and I'm facing an issue.
I have to merge 2 audiofiles:

File A = VoiceOver file (for example: 25.782000 sec, but length differs every day)
File B = Musicbed (for example: 180 sec)
File C = Merge of File B and A

File B should be first, and after 1.2 seconds File A should be mixed. This works. But, file C has to be trimmed depening on the length of File A + those 1.2 seconds. So, file C should have a duration of 25.782000 + 1.2 sec = 26.982000 seconds. I can use this value in my command for trimming file C to that length. Trimming the file with sox / Robotask is also not an issue, but calculating is :)

Robotask has the function of reading metadata of files and spits it out in hh:mm:ss. Sox only works with seconds. I need this value (which is text, not an integer) and need to add 1.2 to that.

I have tried this with VB Evaluate, but that didn't work out.

So, how I can solve this the best?
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Calculate with length of audiofile

Post by Oleg »

Look at my example below.
It convert the time from format hh:mm:ss to seconds

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|444033236
Comment=STRINGLIST
ContinueOnError=INTEGER|0
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task1343"
Hide=INTEGER|0
ID=INTEGER|-861424790
LogOnAsUser=INTEGER|1
Name=STRING|"hh:mm:ss to seconds"
OnErrorTaskID=INTEGER|1879502808
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER

[Actions\Action1]
ActionID=STRING|"A_SCRIPT_VBEVALUATE"
Enabled=INTEGER|-1
Name=STRING|"VB Evaluate"
Params=FOLDER

[Actions\Action1\Params]
expression=STRING|"ToSeconds(""1:25:06"")"
line00000000=STRING|"function ToSeconds(StdTimeString)"
line00000002=STRING|"  tim = CDate(StdTimeString)"
line00000004=STRING|"  h = hour(tim)"
line00000005=STRING|"  m = Minute(tim)"
line00000006=STRING|"  s = Second(tim)"
line00000007=STRING|"  'LogMessage(h)"
line00000008=STRING|"  'LogMessage(m)"
line00000009=STRING|"  'LogMessage(s)"
line0000000B=STRING|"  ToSeconds = h*3600 + m*60 + s"
line0000000D=STRING|"end Function"
line0000000F=STRING|"'Logmessage(ToSeconds(""1:25:06""))"
linecount=STRING|"16"
loadfromfile=STRING|"1"
variable=STRING|"NewTime"

[Actions\Action2]
ActionID=STRING|"A_ROBOTASK_LOG"
Enabled=INTEGER|-1
Name=STRING|"Log Message"
Params=FOLDER

[Actions\Action2\Params]
message=STRING|"{NewTime} seconds"
type=STRING|"3"

Oleg Yershov
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: Calculate with length of audiofile

Post by Rukbunker »

Thanks, this brought me into the right direction. I cannot add values with a comma (like 1,2 or 1.2 seconds) so I solved it by {Add({length},2)}, which comes the closest in my situation.

Thanks again!
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Calculate with length of audiofile

Post by Oleg »

1. You can do this by using VB Evaluate action
2. Use {Add("{length}","1,2")} expression
Oleg Yershov
Rukbunker
Posts: 192
Joined: Mon Feb 22, 2016 4:06 pm
Location: Netherlands

Re: Calculate with length of audiofile

Post by Rukbunker »

-edit-

Thanks for the hint!
Post Reply