News:

--

Main Menu

Getting length of video?

Started by gbell12, March 16, 2010, 03:24:16 AM

Previous topic - Next topic

gbell12

Hi everyone,

The scripting documentation gives examples like this:

app.clearSegments();
app.addSegment(0,0,500);
app.addSegment(0,600,19468);

...to delete frames between 500 and 600.  Problem is the length of the video, 19468, is a magic number, specific to the video.  This makes automated editing difficult.  I don\'t see a get function to get the size (in frames) of the loaded video.  Am I missing something?

Thanks,
George

FeRD_NYC

#1
I was stuck on this problem for a while, also. My current scripting need is to trim the first N frames off of a directory full of different-length AVI files, which requires setting a segment {N,$END] and using copy mode. There didn't seem to be any way to get the length via the script functions provided.

Fortunately, I found a solution. Experimenting with the GUI, I noticed that immediately after loading a file, the display showed that markers A and B were set to the 0'th and last frames, respectively.

Sure enough, that's true when scripting as well, at least UNTIL you call app.clearSegments();

So, the solution I used in my script, to properly trim a fixed number of frames from the start of an arbitrarily-long file, ended up looking like so:

function processFile(filename, targetfile) {
        var len;
        // Load the file
        app.load(filename);
        //displayError("A=" + app.markerA + " B=" + app.markerB)
        len = app.markerB+1;

        //01 segments
        app.clearSegments();
        app.addSegment(0,0,len);
        app.markerA=425;
        app.markerB=len-1;


Hope this helps!

gbell12

Excellent, thanks Ferd!  There\'s some mention of using the markers in the docs, but I couldn\'t find how to access their values from a script.
Cheers,
gbell

Pulson229

Interesting post dude....discussion are always helpful in one way or the other. Thanks for giving out information. It’s really nice and mean full.

Agent_007

Pulson229: you are a spammer?
I am away between 15th of May - 15th of June. (yes, I am playing D3)

FeRD_NYC

#5
Quote from: Agent_007Pulson229: you are a spammer?

LOL. Just because his first ever post on the forum, which consists of nothing but "Generic Thread-Response Verbiage Selection D", was posted at 04:00:10? As if on some sort of automated schedule, or something? To jump right to the suggestion that he might be some sort of spambot... Why, Agent_007, that seems a bit mean... full! ;)

Anyway, back on topic... glad I could be of assistance, grbell12, hope you managed to get your script sorted out! If it's anything involved, please do share. There's far too few examples of "real-world task" script solutions available in the documentation, IMHO! I have a feeling looking at others' code is the best way to really get a feel for avidemux scripting.

bazu

Really useful, thanks Fred!

ykmgt

If you want to know not selected area of markerA to markerB but whole length on Avidemux,

app.video.frameCount

is the answer. Check below in your scripts.

displayInfo(app.video.frameCount.toString());