September 30, 2020, 03:30:43 pm



Getting length of video?

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

Previous topic - Next topic


Hi everyone,

The scripting documentation gives examples like this:

app.addSegment(0,600,19468); 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?



March 23, 2010, 04:30:57 am #1 Last Edit: October 10, 2011, 10:09:58 am by FeRD_NYC
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
        //displayError("A=" + app.markerA + " B=" + app.markerB)
        len = app.markerB+1;

        //01 segments

Hope this helps!


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.


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.


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


March 30, 2010, 04:07:01 pm #5 Last Edit: October 10, 2011, 10:10:36 am by FeRD_NYC
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.


Really useful, thanks Fred!


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

is the answer. Check below in your scripts.