News:

--

Main Menu

audioProperties QT Script bug ?

Started by xpmule, March 02, 2013, 05:25:37 PM

Previous topic - Next topic

xpmule

I've been trying to get the audio channel count using a QT script (exactly as seen in the examples)
and it does NOT work.. the result returned is "undefined"
TranscodeDirectory.admjs (found in the QTScript reference web pages)
Shows exactly what i tried and expected to work.

    if( Editor.videoFileProperties[0].audioProperties.channels != 2 )
    {
        Editor.audioOutputs[0].mixer = AudioOutput.MixerMode.StereoMix;
    }


I tried variations on the code but they throw an error in the log so i'm guessing that code is the correct syntax.

The following also works but returns "Undefined"

    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.bitrate );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.channels );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.format );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.sampleRate );


I even tried using Editor.openVideo(inputPath); to open my video again and it made no difference.

So is this a bug ?

Also does Avidemux detect a source video as stereo and use stereo on a codec conversion ?
I noticed that new saved projects define Stereo for audio options.. is this needed now ?
Any time i converted a stereo to stereo video it always maintained the option, in other words
i never had to set Remix to Stereo before if it was already stereo.
I only ever used Remix if i was converting channels greater than 2..

I use to make scripts for Spidermonkey/Javascript on the old Avidemux and after trying to update my scripts
for the new Avidemux i decided to start making new scripts with QT Script'ing instead.
But what is the deal with the channel count audioProperties ?

One last question i was digging around inside the .exe and various .dlls looking for what happened
to the script command, displayError() etc.. they seem to be removed now ?
Is the only way to make a Dialog now with QT Scripts ?
I want what is basically a c/c++ command function kinda like Win32 Api MessageBox()
If the user does not open a video Before using my script i want a message to pop up telling them.. open a video first.

I know the rest of my script works fine i started out with,

if( Editor.isVideoOpen() )
{
// do stuff
}


and videoFileProperties returns the correct info unlike the audioProperties.

Can anyone shed some light on this stuff for me ?

xpmule

Another problem..

The reference shows an example on how to make a Dialog using all the controls..
BUT
What if i have a control that sets an integer but i want to use it (cast it) to a string ?

for example,

X264VideoEncoder.configuration.general_params = "AQ=" + spinbox.value.toString();

X264VideoEncoder.configuration.general_params
is expects a string value such as "AQ=22"
maybe not the best example but i can't seem to figure out a way to cast values from int to string etc.
i've done a lot of google searching and read the reference many times and i don't know what parts
of QT scripting Avidemux supports. All of it ? if not what parts ?

The QT script Dialog seems useless because the controls can not be used for much..

Jan Gruuthuse

Quote from: xpmule on March 02, 2013, 05:25:37 PM
I've been trying to get the audio channel count using a QT script (exactly as seen in the examples)
and it does NOT work.. the result returned is "undefined"
Not sure, difference between 2.5. and 2.6 branch is the audiotrack(s), 2.6 can handle 4 audiotracks. My guess would be you need to access audiotrack 1st? (I'm not a programmer, so could be wrong on this).
QuoteAvidemux 2.6 Scripting Reference: Classes: Class List: AudioOutputCollection Class Reference: Public Member Functions
AudioOutput operator[] (Number i)
Gets the AudioOutput object at the specified index.

Jan Gruuthuse

Quote from: xpmule on March 03, 2013, 06:32:52 AM
Another problem..

The reference shows an example on how to make a Dialog using all the controls..
BUT
What if i have a control that sets an integer but i want to use it (cast it) to a string ?
convert string to int and int to string

xpmule

#4
Thanks for trying to help Jan.
The examples i provided are copied from the Samples..
file:///C:/Program%20Files/Avidemux/help/QtScript/examples.html
and what i was pointing out is they don't work if you look closely,
run this and you will see (in the log) they all return "undefined" ..

    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.bitrate );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.channels );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.format );
    print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.sampleRate );

So what i'm saying is on the example "TranscodeDirectory.admjs"
on line 62 "audioProperties.channels" is used and it may *seem to work but it doesn't
it returns "undefined" so the if/else statement does nothing because it will always return true ;)
And this means a lot of stuff just isn't gonna work !
For example if i use the exact code above to check the sample rate so i know whether to convert or not
it will always return true etc..

and the 2nd problem i am having is i want to use ".toString" or what ever will work,
so i can simply enter an Integer value into a SpinBoxControl control in a Dialog
and then use the value it returns to set one of the x264 encoder settings (which takes a string not int)
but i havn't been able to find any way to make .toString work.. for example this does not work,

X264VideoEncoder.configuration.level =  "" + spinBox.value;
X264VideoEncoder.configuration.level =  " " + spinBox.value;
X264VideoEncoder.configuration.level =  "" + spinBox.value.toString;
X264VideoEncoder.configuration.level =  "" + spinBox.value.toString();

BUT .toString() should according to documentation found on the net for QT scripting. Make me wonder if its supported ?
And if it is not what is supported so people can script stuff ?
If people look close enough to what i'm saying here they should see the problem i think ;)

xpmule

Ok so i grabbed the 2.6.1 src code and i see ".toString()" does work but it's a bit hard to use :(
i found it used in the script "avidemux_2.6.1\avidemux_plugins\ADM_scriptEngines\qtScript\src\test\test.admjs"
I also looked at AudioProperties.h and cpp and i can see it's being used correctly but why it fails i don't know.
All audio properties return "undefined".
The easiest way to see what i mean is to add the following to TranscodeDirectory.admjs

print( "Audio Info = " + Editor.videoFileProperties[0].audioProperties.channels );

The script runs and the video(s) do in fact get converted but undefined will be listed in the log for that print command.

So at this point i have no more to say and i can't script anything because there is too many problems.. i guess i'm done and failed. the best i can do is make a script with no Dialog i suppose..

xpmule

i wonder if I got the dev's to confirm this problem ?
basically i used the code from the sample provided and part of it does not work.
to verify this should be easy.. either i'm right or i'm wrong lol
BUT other people may find this bug and or not know why their scripts don't work as intended.
Having 4 of the "audioProperties" values always "undefined" is a problem for a LOT of scripting situations.