Have problem with CLI and Scripts on Windows build 2.6 versions

Started by SeventyPlus, May 31, 2012, 05:37:45 AM

Previous topic - Next topic

SeventyPlus

My working environment is Windows XP SP3.

I use avidemux_cli + JS scripts in a Visual Basic GUI project to join multiple .MOD MPEG2 files into a single MPEG2 Program Stream output file (the input files are capture files from a Panasonic SDR-S150 video camera and are plain SD format MPEG-PS, frame size 704x576, aspect-ratio 4:3, with display size 540x576 in Sequence Display Extension header, 25 fps, GOP length 12, 3 P-frames per GOP).

In my project, the join is "raw": Avidemux_cli + JS scripts do basically "copy" (load and appends), no cutting or trimming of input segments is involved at this stage.

Because I have a problem with stable Avidemux v2.5.6 (produces output with the 2 missing B-frames at the end of each segment (*); this happens with both Avidemux GUI manually joins and with Avidemux_cli + script automated joins), I gave the Avidemux Experimental 2.6 builds a try.

The good news is: the 3 experimental V2.6 versions I tried (Grunster builds r7959, r7989, r7990) entirely solve my '2 missing B-frames' problem.
With the Avidemux GUI of these versions, I produce complete and clean joined output when I manually load+append and copy to PS-MPEG output.

The bad news is: with none of the 3 tested experimental V2.6 versions I tried, I was capable to make my avidemux_cli + scripts work (not even the most simple test script, based on a 'template' saved as a project with a avidemux V2.6 GUI version).

This is what happens:

(1) Javascripts fail with a message "Avidemux is not defined" (example) :


run-->1
[Script] SpiderMonkey INFO - Compiling "C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_BetaVersion.js"...
[Script] SpiderMonkey INFO - Done.
[Script] SpiderMonkey INFO - Executing C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_BetaVersion.js...
[Script] SpiderMonkey ERROR - ReferenceError: Avidemux is not defined
[Script] SpiderMonkey INFO - Done
quit-->0


Probably error when Spidermonkey starts reading my script that begins like this (example):


//AD  <- Needed to identify//
//--automatically built--
//--Project: E:\PANASONIC_CAPTURES\STEP_3_JOIN_AVIDEMUX_AVI\VARIA1\Avidemix_Join_project

var app = new Avidemux();


(2) Python scripts are partially executed, but I never got an output file : neither with the '--save(fullPathNameOutputFile)' argument in the CLI command line, nor with a (example) 'adm.save("E:/PANASONIC_CAPTURES/STEP_3_JOIN_AVIDEMUX_AVI/VARIA1/OUTPUT_123.MPG")' command in the .py script file;

There is also always this error(?) message in the (very verbose) StdOu/ErrorOut (example):


[switchToSegment] Switched ok to segment 0 (dontdecode=0)
[start] admPreview,starting

*********** BACKTRACE **************
PythonEngine::runScript(std::string, IScriptEngine::RunMode) <+0x6DBF>  [D:\users\hv\AVIDEMUX\avidemux_2.6_r7990_win32(no_installer)\libADM_coreScriptPython.dll]
unknown function <+0x6DBF>  [unknown module]
*********** BACKTRACE **************

Cleaning up
[deleteAll] [Editor] Deleting all videos


This situation is rather frustrating (because I managed relatively well with scripting in the V.2.5.6 version) and I have the feeling I am doing somewhere a basic mistake.
So: if someone could point my nose in the right direction, I will be very, very grateful.

Remark: actually, all my avidemux experiments - both with stable v.2.5.6 version and experimental v.2.6 versions are done with 'no-windows-installer' win32 builds.

I have also a question about apparent difference in scripting syntax between V2.5.6 Javascript and V2.6 Python script:

(1) In V2.5.6 JavaScript (examples auto-generated scripts in the GUI) the following commands have 'frameNumbers' as parameter-values:


app.addSegment(segmentIndex,beginFrameNumber,endFrameNumber)
app.markerA=beginFrameNumber
app.markerB=endFrameNumber


(2) In v2.6 Python scripts (examples also auto-generated scripts in the GUI) the same commands seem to have 'beginTime' and 'endTime' as parameter-values (instead of frameNumbers):


app.addSegment(segmentIndex,beginTime,endTime)
app.markerA=beginTime
app.markerB=endTime


and from what I have seen in the StdOut/ErrOut when I do a 'load' or 'append' of an PS MPEG2 source file in such a Python script , the procedure followed by v2.6 avidemux to find the beginTime and EndTime seems not so simple (looking for PTS and DTS at the begin end end of the file, doing extrapolations and adjustments).

My question is:
(a) Do Python scripts in V2.6 accept 'addSegment' , 'markerA' and 'markerB' commands with frameNumber parameter-values (instead if 'time' values) ?
(b) I yes, is the syntax different or is there an 'option' parameter to make the choice ?
(c) If no, is there a simple application command (something like maybe 'amd.video.duration') to find the length (in time) of an MPEG2 Program stream source file?
(d) What is the time unit and exact syntax of those 'timeBegin' and 'timeEnd' parameter-values in V2.6 Pyton scripts.

I saw some remarkable 'endTime' values in auto-generated v2.6 Python scripts; example :


adm.clearSegments()
adm.addSegment(0,0,55680000)
adm.addSegment(1,0,18942222)
adm.addSegment(2,0,10080000)
adm.markerA=0
adm.markerB=84702222
[/code]

where '18942222' of segment #1 source is a rather unexpected value for a source file with a total of 466 frames at 25 fps = 18.640000 sec (or maybe this type of camera captures in variable frame-rate, and not in variable bit-rate [joke]  ;)).

(*) The '2 missing B-frames in output' problem has also been mentioned in another forum (see: //forum.doom9.org/showthread.php?p=789053 post #25)

Thank you for being so patient and read until the end of this story. I hope someone will comment.

Jan Gruuthuse

Can't help you much on these issues: one question: you do use avidemux3_cli.exe for 2.6 trials?

mean

If you dont do edit at all, just dont use the clearSegment/addSegment
As for saving if you do

avidemux3_cli --runpy foobar.py --save foo.mpg

with foo.mpg a very very simple path, does it work ?

SeventyPlus

Quote from: Jan Gruuthuse on May 31, 2012, 05:59:48 AM
Can't help you much on these issues: one question: you do use avidemux3_cli.exe for 2.6 trials?

The  V2.6 Windows win32 builds from grunster I tested (r7959, r7989, r7990) all contain an executable with name = 'avidemux_cli.exe'. But what is in a name ?

I also downloaded 'nightly' win32 builds  r7989-win32  and r7989-dev-win32 from www.avidemux.org/nightly but those packages contains no '_cli' executable at all (not an avidemux_cli.exe, not an avidemux2_cli.exe, not an 'avidemux3_cli.exe).

(btw: what is the difference between the 'rxxxx-win32' and the 'rxxxx-dev-win32' packaging ?)

So, where should I look to find an v2.6 'avidemux3_cli.exe' executable (with matching libraries) ?

mean

Same thing, it's just that on windows it's called avidemux_cli, on linux avidemux3_cli

Jan Gruuthuse

In that case, if you have several versions (2.5.6, 2.6) installed to different paths, check you're using the intended one.

SeventyPlus

Quote from: mean on May 31, 2012, 06:30:59 AM
If you dont do edit at all, just dont use the clearSegment/addSegment
As for saving if you do

avidemux3_cli --runpy foobar.py --save foo.mpg

with foo.mpg a very very simple path, does it work ?

I tested as you suggested (with grunster v2.6 r7990 win32), but same result as described in my initial post:
- no output (for the output file, I even respected the old DOS rule "File Name not longer than 8 characters")
- always the "unknown module" Python error.

This is the command-line of my test:


"D:\users\hv\AVIDEMUX\avidemux_2.6_r7990_win32(no_installer)\avidemux_cli.exe" --runpy "C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_SimpleJoin_BetaVersion.py" --save "E:/JOIN_OUT.MPG" --quit >"C:\My Programs and Doc\MyMpegJoiner\LOG\TestScript_SimpleJoin_BetaVersion.log" 2<&1



This is the script from file TestScript_SimpleJoin_BetaVersion.py


#PY  <- Needed to identify#
#--automatically built--
#--Project: C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_SimpleJoin_BetaVersion.py

adm=Avidemux()
#** Video **
# 03 videos source
adm.loadVideo("E:/PANASONIC_CAPTURES/STEP_3_JOIN_AVIDEMUX_AVI/VARIA1/2000-01-01_00.MPG")
adm.appendVideo("E:/PANASONIC_CAPTURES/STEP_3_JOIN_AVIDEMUX_AVI/VARIA1/2000-01-01_01.MPG")
adm.appendVideo("E:/PANASONIC_CAPTURES/STEP_3_JOIN_AVIDEMUX_AVI/VARIA1/2000-01-01_02.MPG")
#** Postproc **
adm.setPostProc(0,0,0)

#** Video Codec conf **
adm.videoCodec("Copy")

#** Filters **

#** Audio **
adm.audioClearTracks()

#** Track 0 **
adm.audioAddTrack(0)
adm.audioCodec(0,"copy");
adm.audioSetPal2Film(0,0)
adm.audioSetFilm2Pal(0,0)
adm.audioSetNormalize(0,0,0)

#** Muxer **
adm.setContainer("ffPS","muxingType=2","acceptNonCompliant=True","muxRatekBits=11000","videoRatekBits=9800","bufferSizekBytes=224")
#End of script



The file TestScript_SimpleJoin_BetaVersion.log, containing redirected StandardOut and ErrorOut is in attachment.

Although being no expert at all in Python scripting, the following messages striked me in that log file:

  • Apparantly the load of the first segment source file succeeds but the 'appends' of the succeeding source files never happen.
  • The error message comes after some 'admPreview' command . What is this admPreview command supposed to do and what command line in my script triggers a 'Preview' ?

extract from log file:

......(previous lines in log file)
[switchToSegment] Switched ok to segment 0 (dontdecode=0)
[start] admPreview,starting

*********** BACKTRACE **************
PythonEngine::runScript(std::string, IScriptEngine::RunMode) <+0x6DBF>  [D:\users\hv\AVIDEMUX\avidemux_2.6_r7990_win32(no_installer)\libADM_coreScriptPython.dll]
unknown function <+0x6DBF>  [unknown module]
*********** BACKTRACE **************

Cleaning up
......(following lines in log file)


Other: some idea why a JavaScript aborts with the "avidemux is not defined" message ?

SeventyPlus

Quote from: Jan Gruuthuse on May 31, 2012, 08:23:20 AM
In that case, if you have several versions (2.5.6, 2.6) installed to different paths, check you're using the intended one.

As stated in my initial post : NO Avidemux versions are "installed" (I am not a big fan of the Windows Register)

extract from my initial post :
Quote
Remark: actually, all my avidemux experiments - both with stable v.2.5.6 version and experimental v.2.6 versions are done with 'no-windows-installer' win32 builds.

As for using the intended one, I am quite confident (look at the command line example in my previous post in answer to mean).

Jan Gruuthuse

OK, did overlook that.
Scripting could also cause problems when there are spaces or other ASCII like ( ) in the filenames/paths or length and depth could also be an issue. If I remember correctly form the old days?
Keep paths and names as short and simple as possible, specially while testing.

SeventyPlus

Quote from: Jan Gruuthuse on May 31, 2012, 11:04:41 AM
OK, did overlook that.
Scripting could also cause problems when there are spaces or other ASCII like ( ) in the filenames/paths or length and depth could also be an issue. If I remember correctly form the old days?
Keep paths and names as short and simple as possible, specially while testing.

Remember from my initial post: my scripts are 'replicata' of automatic generated scripts (projects) by avidemux when doing the same thing (join mpeg files) in GUI mode, with exactly the same fullpath/filenames.
So my guess is: if a script can do in avidemux GUI, then that script should also be able to do in avidemux CLI.

I believe the problems are rather elsewhere:

  • why a JavaScript aborts with the "avidemux is not defined" message ?
  • why does the Python script loads the first source file OK, but then chokes on that 'admPreview' command (+"unknown module" Python error ) and never appends the other source files  (see log file attached in my previous post) ?



Jan Gruuthuse

You could test the scripting and replace the avidemux_cli.exe with its graphic equivalent and see what is going on when scripting. Will be a bit annoying: opening and closing windows.

Regarding paths and filenames: In the program everything stays in that program, scripting passes info to external processes.

mean

The javascript syntax is different between 2.5 & 2.6
tinyPy is the preffered way for 2.6

As far as the render issue is concerned, i'm looking into it

SeventyPlus

Quote from: Jan Gruuthuse on May 31, 2012, 02:10:06 PM
You could test the scripting and replace the avidemux_cli.exe with its graphic equivalent and see what is going on when scripting. Will be a bit annoying: opening and closing windows.
[/i]

Jan, this was a VERY GOOD IDEA.

The results are interesting:

(1) DOS commands, with avidemux.exe (GUI avidemux from avidemux_2.6_r7990_win32) in the command-line and Python .py script as the avidemux argument, work OK and produce a correct and clean result of a join of mpeg source files.
I tested both cases:
(a) with the  avidemux '--save' argument in the DOS command line.
(b) with the 'adm.save(targetFile)' command in the Python script.

I verified with good old GSPOT and checked with the Visual GOP Structure function: the GOP structures, the number of frames, the B-frame dependencies, the closed GOPs, the coded-order versus presentation-order of the frames, the GOP structure of the last GOP and the B-frames in the last GOP of every segment; all is correct and all frames are there.

Conclusion #1: my Python script is correct but probably something in the actual V2.6 avidemux_cli.exe of a "non-installed" win32 build is not working correctly. I think someone should look into "why does the Python script loads the first source file OK, but then chokes on that 'admPreview' command (+"unknown module" Python error ) and never appends the other source files  (see log file attached in my previous post)".

For information, this is a tested DOS command line with avidemux.exe running a Python script:


"D:\users\hv\AVIDEMUX\avidemux_2.6_r7990_win32(no_installer)\avidemux.exe" --runpy "C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_SimpleJoin_BetaVersion.py" --quit >"C:\My Programs and Doc\MyMpegJoiner\LOG\TestScript_SimpleJoin_BetaVersion.log" 2<&1


(2) DOS commands, with avidemux.exe (GUI avidemux from avidemux_2.6_r7990_win32) in the command-line and JavaScript .js script as the avidemux argument, do NOT work ok.
Because the redirection of StandardOut and ErrorOut in my DOS command line do not work with a avidemux GUI executable, I can not check the error reason (but I guess it is still something like ""avidemux is not defined"). The avidemux GUI executable opens a fraction of a second but closes instantly.

Conclusion #2: someone should tell us whether yes or no v2.6 avidemux win32 builds are supposed to accept JavaScripts or if the 'needed to identify' code in the first line of the script should be adapted.

For information, this is the DOS command line with avidemux.exe not liking my Javascript:


"D:\users\hv\AVIDEMUX\avidemux_2.6_r7990_win32(no_installer)\avidemux.exe" --run "C:/My Programs and Doc/MyMpegJoiner/TEMPLATES/TestScript_SimpleJoin_BetaVersion.js" --quit >"C:\My Programs and Doc\MyMpegJoiner\LOG\TestScript_SimpleJoin_BetaVersion.log" 2<&1



Thanks again for the suggestion, but I will leave this thread open, because the real problem (avidemux_cli.exe not working) persists.

SeventyPlus

Quote from: mean on May 31, 2012, 03:18:53 PM
The javascript syntax is different between 2.5 & 2.6
tinyPy is the preffered way for 2.6

OK, that is good to know.

But in my initial post I was more concerned about the difference in argument contents between a V2.5.6 addSegment script command and a v2.6 addsegment script command (independant from the language in which the script is written).

For me a command 'addSegment(segmentNumber,beginFrameNumber,endFrameNumber)' is essentially different from a command 'addSegment(segmentNumber,beginTime,endTime)

But if you want, I can open a different thread for this kind of subject, and remain concentrated in this thread on the main issue: how to make avidemux  cli + script work in a win32 environment.

Jan Gruuthuse

I've seen mean made new revision available, can you test that one? most likely dealing with your issue?
2.60 r7996 http://avidemux.org/nightly/