February 25, 2021, 03:53:16 PM



[Tinypy] Tips & docs on Avidemux .py scripting

Started by butterw, January 17, 2021, 01:18:41 PM

Previous topic - Next topic


February 17, 2021, 04:22:17 PM #45 Last Edit: February 19, 2021, 08:09:31 AM by butterw
- Every loaded video has an index to reference it in segments and is counted in ed.nbVideos(). Videos loaded multiple times will have the same path.
Videos (end_pts, filepath) >= unique_Videos

- Segments are the result of loading/appending and edit operations.
Segments (Videos_Idx, video_start_offset, duration) >= used_Videos

So with the latest Avidemux dev version and some TinyPy code, it is possible to know:
- the duration and number of segments (nbSegments) of the current edit
- the total number of video files loaded (nbVideos)
- the number of videos files used, whether they are unique, their duration, filepath, filesize

It would be possible to list All segments, and use this to seek/jump to a segment start/end, or select the desired one.

Edit: here's an example of an info/command selection TinyPy dialog:


February 17, 2021, 08:41:02 PM #46 Last Edit: February 19, 2021, 08:05:04 AM by butterw
To jump to the 1st keyframe of segment_1:
e1 = ed.getDurationForSegment(0)
k1 = ed.getNextKFramePts(e1-1) #if segment_1 has an offset, e1 can directly be the keyframe we are looking for.

This could be used for a goToNextSegment() seek/jump function, which is useful for editing.

EDIT: You need to cumulate segments pts values durations to make this work. This could also be used to determine the segment corresponding to the current position (and associated video file, path, filesize).



February 19, 2021, 08:35:25 AM #47 Last Edit: February 19, 2021, 08:40:32 AM by butterw
Thinking about TinyPy bindings which could be useful for next-gen Avidemux (v2.8 ?):
- a binding to copy a str to system clipboard
- More pts markers (at least markers C, D) and make available a storage variable.
One issue with TinyPy scripts is that values are not persistent accross runs: Run script A, determine some values. These values are not then available for script B or script A if it is run again in the same GUI session.
The way around this currently is to first define variables (or as in the following example an empty object) in the interactive shell:
class Vars: pass
vars = Vars()
You can now store anything in vars from scripts in a persistent fashion, ex: vars.x = 100