News:

--

Main Menu

Help for Spidermonkey script

Started by dinolib, November 24, 2012, 03:10:52 PM

Previous topic - Next topic

dinolib

I'm trying to write a script (spidermonkey) to automate video conversion to PSP compatible format.
<I've abandoned the idea to use Tinypy modifiyng the existing scripts because I get a lot of errors also for basic commands (tried with tinypy shell)>

First problem: with latest git source the adm.audioCodec(0, "Faac", "bitrate=128"); command does not work  :(
Second problem: I'm able to set video codec and container. Now I'm trying to apply some filter. But I've seen that all the object structure changed and I'm not able to find any documents on the web or source code   :(

I attached some code taken from py tutorial, but I'm not able to adapt to new script object model.
Can you help me? Thank you so much!
note: the code is not tested at all since I'm not able to run it  :-[

//AD  <- Needed to identify //
//--automatically built--

adm.videoCodec("x264", "general.params=AQ=20", "general.threads=99", "general.fast_first_pass=True", "level=31", "vui.sar_height=1", "vui.sar_width=1", "MaxRefFrames=2", "MinIdr=100", "MaxIdr=500", "MaxBFrame=2", "i_bframe_adaptive=0", "i_bframe_bias=0", "i_bframe_pyramid=0", "b_deblocking_filter=False", "i_deblocking_filter_alphac0=0", "i_deblocking_filter_beta=0", "cabac=True", "interlaced=False", "analyze.b_8x8=True", "analyze.b_i4x4=False", "analyze.b_i8x8=False"
, "analyze.b_p8x8=False", "analyze.b_p16x16=False", "analyze.b_b16x16=False", "analyze.weighted_pred=0", "analyze.weighted_bipred=False", "analyze.direct_mv_pred=0", "analyze.chroma_offset=0", "analyze.me_method=0", "analyze.subpel_refine=7", "analyze.chroma_me=False", "analyze.mixed_references=False", "analyze.trellis=1", "analyze.fast_pskip=True", "analyze.dct_decimate=False", "analyze.noise_reduction=0", "analyze.psy=True", "ratecontrol.rc_method=0", "ratecontrol.qp_constant=0", "ratecontrol.qp_min=0", "ratecontrol.qp_max=0"
, "ratecontrol.qp_step=0", "ratecontrol.bitrate=0", "ratecontrol.vbv_max_bitrate=0", "ratecontrol.vbv_buffer_size=0", "ratecontrol.vbv_buffer_init=0", "ratecontrol.ip_factor=0,000000", "ratecontrol.pb_factor=0,000000", "ratecontrol.aq_mode=0", "ratecontrol.aq_strength=0,000000", "ratecontrol.mb_tree=False", "ratecontrol.lookahead=0");
//adm.audioCodec(0, "Faac", "bitrate=128");
adm.setContainer("MP4", "muxerType=1", "useAlternateMp3Tag=True");

var targetX = 320;
var targetY = 240;
var width = Editor.videoFileProperties[0].width;
var height = Editor.videoFileProperties[0].height;
var rX = width / targetX;
var rY = height / targetY;
var newX;
var newY;
var newX;
var newY;
if (rX > rY)
{
    // resize by X
    newX = targetX;
    newY = Math.round(height / rX);
}
else
{
    // resize by Y
    newY = targetY;
    newX = Math.round(width / rY);
}
// resize to multiple of 4
newX -= newX % 4;
newY -= newY % 4;
if (newX != width || newY != height)
{
    adm.addVideoFilter("swscale", "width="+newX, "height="+newY, "algo=1", "sourceAR=0", "targetAR=2");
}

// Black bar filter
var barX = targetX - newX;
var barY = targetY - newY;
if (barX || barY)
{
    adm.addVideoFilter("addBorder", "left="+barX >> 1, "right="barX >> 1, "top="+barY >> 1, "bottom="+barY >> 1);
}


I'd like to use also a dialog window to get some information from user (as in auto scripts) but at the moment it's sufficient to run this script!

Jan Gruuthuse

When you start avidemux 2.6 you can save projects in spidermonkey. Load video make your settings and apply filters or changes. From main text menu: File -> SpiderMonkey Project -> Save As Project. You then could run these from batch processing.
Probably this give you more insight with avidemux usage. Avidemux Scripting tutorial <-  click
Avidemux Batch processing <-  click
Unfortunately I'm not a big help in programming or scripting.
Some more info and examples could be found here: Documentation & Tips

dinolib

Thankyou for your infos. I missed the Tips forum part.

Still I can't make to work this part of code:
adm.audioCodec(0, "Faac", "bitrate=128");

the same if I use
var app=Avidemux();
app.audioCodec(0, "Faac", "bitrate=128");


or change to any codec (even copy).
If I put inside the script, the script ends at this line. No errors in command line  :o

Jan Gruuthuse

Did test and saved spidermonkey project in avidemux and tried to run in avidemux 2.6 and nothing happened.
So it look like this broken.

dinolib

OK, thank you.
I'll compile 2.5.6 and for the moment use it.