-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpythonreference.html
1530 lines (1388 loc) · 106 KB
/
pythonreference.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>Python Reference — VapourSynth-Classic R57 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/agogo.css" />
<link rel="stylesheet" type="text/css" href="_static/css/custom.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Function Reference" href="functions.html" />
<link rel="prev" title="Getting Started" href="gettingstarted.html" />
</head><body>
<div class="header-wrapper" role="banner">
<div class="header">
<div class="headertitle"><a
href="index.html">VapourSynth-Classic R57 documentation</a></div>
<div class="rel" role="navigation" aria-label="related navigation">
<a href="gettingstarted.html" title="Getting Started"
accesskey="P">previous</a> |
<a href="functions.html" title="Function Reference"
accesskey="N">next</a> |
<a href="genindex.html" title="General Index"
accesskey="I">index</a>
</div>
</div>
</div>
<div class="content-wrapper">
<div class="content">
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="python-reference">
<span id="pythonreference"></span><h1>Python Reference<a class="headerlink" href="#python-reference" title="Permalink to this heading">¶</a></h1>
<p>VapourSynth is separated into a core library and a Python module. This section
explains how the core library is exposed through Python and some of the
special things unique to Python scripting, such as slicing and output.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Any script executed through the vsscript api (that means vspipe, avfs, vsvfw or
other API users) will have __name__ set to “__vapoursynth__” unlike normal Python
scripts where it usually is “__main__”.</p>
</div>
<section id="vapoursynth-structure">
<h2>VapourSynth Structure<a class="headerlink" href="#vapoursynth-structure" title="Permalink to this heading">¶</a></h2>
<p>Most operations in the VapourSynth library are performed through the singleton
core object. This core may load plugins, which all end up in their own unit,
or namespace, so to say, to avoid naming conflicts in the contained functions.
For this reason you call a plugin function with <em>core.unit.Function()</em>.</p>
<p>All arguments to functions have names that are lowercase and all function names
are CamelCase. Unit names are also lowercase and usually short. This is good to
remember as a general rule.</p>
</section>
<section id="grammar">
<h2>Grammar<a class="headerlink" href="#grammar" title="Permalink to this heading">¶</a></h2>
<section id="slicing-and-other-syntactic-sugar">
<h3>Slicing and Other Syntactic Sugar<a class="headerlink" href="#slicing-and-other-syntactic-sugar" title="Permalink to this heading">¶</a></h3>
<p>The VideoNode and AudioNode class (always called “clip” in practice) supports the full
range of indexing and slicing operations in Python. If you do perform a slicing
operation on a clip, you will get a new clip back with the desired frames.
Here are a few examples.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Operation</p></th>
<th class="head"><p>Description</p></th>
<th class="head"><p>Equivalent</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>clip = clip[5]</p></td>
<td><p>Make a single frame clip containing frame number 5</p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p>clip = clip[5:11]</p></td>
<td><p>Make a clip containing frames 5 to 10 <a class="footnote-reference brackets" href="#f1" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a></p></td>
<td><div class="line-block">
<div class="line">clip = core.std.Trim(clip, first=5, last=10)</div>
<div class="line">clip = core.std.AudioTrim(clip, first=5, last=10)</div>
</div>
</td>
</tr>
<tr class="row-even"><td><p>clip = clip[::2]</p></td>
<td><p>Select even numbered frames</p></td>
<td><p>clip = core.std.SelectEvery(clip, cycle=2, offsets=0)</p></td>
</tr>
<tr class="row-odd"><td><p>clip = clip[1::2]</p></td>
<td><p>Select odd numbered frames</p></td>
<td><p>clip = core.std.SelectEvery(clip, cycle=2, offsets=1)</p></td>
</tr>
<tr class="row-even"><td><p>clip = clip[::-1]</p></td>
<td><p>Reverses a clip</p></td>
<td><div class="line-block">
<div class="line">clip = core.std.Reverse(clip)</div>
<div class="line">clip = core.std.AudioReverse(clip)</div>
</div>
</td>
</tr>
<tr class="row-odd"><td><p>clip = clip1 + clip2</p></td>
<td><p>The addition operator can be used to splice clips together</p></td>
<td><div class="line-block">
<div class="line">clip = core.std.Splice([clip1, clip2], mismatch=False)</div>
<div class="line">clip = core.std.AudioSplice([clip1, clip2])</div>
</div>
</td>
</tr>
<tr class="row-even"><td><p>clip = clip * 10</p></td>
<td><p>The multiplication operator can be used to loop a clip <a class="footnote-reference brackets" href="#f2" id="id2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a></p></td>
<td><div class="line-block">
<div class="line">clip = core.std.Loop(clip, times=10)</div>
<div class="line">clip = core.std.AudioLoop(clip, times=10)</div>
</div>
</td>
</tr>
</tbody>
</table>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="f1" role="note">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>
<p>Note that frame numbers, like python arrays, start counting at 0 and the end value of slicing is not inclusive</p>
</aside>
<aside class="footnote brackets" id="f2" role="note">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id2">2</a><span class="fn-bracket">]</span></span>
<p>Note that multiplication by 0 is a special case that will repeat the clip up to the maximum frame count</p>
</aside>
</aside>
<p>Filters can be chained with a dot:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clip</span> <span class="o">=</span> <span class="n">clip</span><span class="o">.</span><span class="n">std</span><span class="o">.</span><span class="n">Trim</span><span class="p">(</span><span class="n">first</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">last</span><span class="o">=</span><span class="mi">2000</span><span class="p">)</span><span class="o">.</span><span class="n">std</span><span class="o">.</span><span class="n">FlipVertical</span><span class="p">()</span>
</pre></div>
</div>
<p>Which is quivalent to:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clip</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">std</span><span class="o">.</span><span class="n">FlipVertical</span><span class="p">(</span><span class="n">core</span><span class="o">.</span><span class="n">std</span><span class="o">.</span><span class="n">Trim</span><span class="p">(</span><span class="n">clip</span><span class="p">,</span> <span class="n">first</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">last</span><span class="o">=</span><span class="mi">2000</span><span class="p">))</span>
</pre></div>
</div>
</section>
<section id="python-keywords-as-filter-arguments">
<h3>Python Keywords as Filter Arguments<a class="headerlink" href="#python-keywords-as-filter-arguments" title="Permalink to this heading">¶</a></h3>
<p>If a filter’s argument happens to be a Python keyword, you may prepend
an underscore to the argument’s name when invoking the filter. The Python
module will strip one leading underscore from all filter arguments before
passing them to the filters.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">clip</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">plugin</span><span class="o">.</span><span class="n">Filter</span><span class="p">(</span><span class="n">clip</span><span class="p">,</span> <span class="n">_lambda</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>Another way to deal with such arguments is to place them in a dictionary:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span> <span class="s2">"lambda"</span><span class="p">:</span> <span class="mi">1</span> <span class="p">}</span>
<span class="n">clip</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">plugin</span><span class="o">.</span><span class="n">Filter</span><span class="p">(</span><span class="n">clip</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>
</div>
<p>VapourSynth will also support the PEP8 convention of using a single trailing
underscore to prevent collisions with python keywords.</p>
</section>
<section id="windows-file-paths-strings-with-backslashes">
<h3>Windows File Paths (Strings With Backslashes)<a class="headerlink" href="#windows-file-paths-strings-with-backslashes" title="Permalink to this heading">¶</a></h3>
<p>If you have a string containing backslashes, you must either prefix the
string with “r”, or duplicate every single backslash. The reason is
that the backslash is an escape character in Python.</p>
<p>Incorrect; Python will think “\A” and “\G” are supposed to mean
something special:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">core</span><span class="o">.</span><span class="n">avs</span><span class="o">.</span><span class="n">LoadPlugin</span><span class="p">(</span><span class="s2">"B:\Avisynth plugins\GuavaComb.dll"</span><span class="p">)</span>
</pre></div>
</div>
<p>Correct; Python will think “\\” means something special, namely a
single backslash:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">core</span><span class="o">.</span><span class="n">avs</span><span class="o">.</span><span class="n">LoadPlugin</span><span class="p">(</span><span class="s2">"B:</span><span class="se">\\</span><span class="s2">Avisynth plugins</span><span class="se">\\</span><span class="s2">GuavaComb.dll"</span><span class="p">)</span>
</pre></div>
</div>
<p>Correct; Python will not consider any combination of characters special:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">core</span><span class="o">.</span><span class="n">avs</span><span class="o">.</span><span class="n">LoadPlugin</span><span class="p">(</span><span class="sa">r</span><span class="s2">"B:\Avisynth plugins\GuavaComb.dll"</span><span class="p">)</span>
</pre></div>
</div>
<p>Additionally, if the string is a Windows file path, it can also be
written with forward slashes instead of backslashes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">core</span><span class="o">.</span><span class="n">avs</span><span class="o">.</span><span class="n">LoadPlugin</span><span class="p">(</span><span class="s2">"B:/Avisynth plugins/GuavaComb.dll"</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="output">
<h3>Output<a class="headerlink" href="#output" title="Permalink to this heading">¶</a></h3>
<p>The normal way of specifying the clip(s) to output is to call
<em>clip.set_output()</em>. All standard VapourSynth components only use output
index 0, except for vspipe where it’s configurable but defaults to 0.
There are also other variables that can be set to control how a format is
output. For example, setting <em>alt_output=1</em> changes the packing of the
YUV422P10 format to one that is common in professional software (like Adobe
products). Note that currently <em>alt_output</em> modes only has an effect with
YUV420P8 (I420, IYUV), YUV422P8 (YUY2, UYVY) and YUV422P10 (v210).</p>
<p>An example on how to get v210 output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">some_clip</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">resize</span><span class="o">.</span><span class="n">Bicubic</span><span class="p">(</span><span class="n">clip</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">vs</span><span class="o">.</span><span class="n">YUV422P10</span><span class="p">)</span>
<span class="n">some_clip</span><span class="o">.</span><span class="n">set_output</span><span class="p">(</span><span class="n">alt_output</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>An example on how to get UYVY output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">some_clip</span> <span class="o">=</span> <span class="n">core</span><span class="o">.</span><span class="n">resize</span><span class="o">.</span><span class="n">Bicubic</span><span class="p">(</span><span class="n">clip</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="n">vs</span><span class="o">.</span><span class="n">YUV422P8</span><span class="p">)</span>
<span class="n">some_clip</span><span class="o">.</span><span class="n">set_output</span><span class="p">(</span><span class="n">alt_output</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="raw-access-to-frame-data">
<h3>Raw Access to Frame Data<a class="headerlink" href="#raw-access-to-frame-data" title="Permalink to this heading">¶</a></h3>
<p>The VideoFrame and AudioFrame classes contains one picture/audio chunk and all the metadata
associated with it. It is possible to access the raw data using either
<em>get_read_ptr(plane)</em> or <em>get_write_ptr(plane)</em> and <em>get_stride(plane)</em> with ctypes.</p>
<p>A more Python friendly wrapping is also available where each plane/channel can be accessed
as a Python array using <em>frame[plane/channel]</em>.</p>
<p>For backward compatibility reasons, the VideoFrame class also provides <em>get_read_array(plane)</em>
and <em>get_write_array(plane)</em> whose returned value implements the Python buffer protocol, and
the pixels at using <em>arr[row,col]</em>.</p>
<p>To get a frame simply call <em>get_frame(n)</em> on a clip. Should you desire to get
all frames in a clip, use this code:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">frame</span> <span class="ow">in</span> <span class="n">clip</span><span class="o">.</span><span class="n">frames</span><span class="p">():</span>
<span class="c1"># Do stuff with your frame</span>
<span class="k">pass</span>
</pre></div>
</div>
</section>
</section>
<section id="classes-and-functions">
<h2>Classes and Functions<a class="headerlink" href="#classes-and-functions" title="Permalink to this heading">¶</a></h2>
<dl class="py attribute">
<dt class="sig sig-object py" id="core">
<span class="sig-name descname"><span class="pre">core</span></span><a class="headerlink" href="#core" title="Permalink to this definition">¶</a></dt>
<dd><p>Gets the singleton Core object. If it is the first time the function is called,
the Core will be instantiated with the default options. This is the preferred
way to reference the core.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="get_outputs">
<span class="sig-name descname"><span class="pre">get_outputs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#get_outputs" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a read-only mapping of all outputs registered on the current node.</p>
<p>The mapping will automatically update when a new output is registered.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="get_output">
<span class="sig-name descname"><span class="pre">get_output</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">index</span> <span class="pre">=</span> <span class="pre">0</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#get_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a previously set output node. Throws an error if the index hasn’t been
set. Will return a VideoOutputTuple containing <em>alpha</em> and the <em>alt_output</em> setting for video output and an AudioNode for audio.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="clear_output">
<span class="sig-name descname"><span class="pre">clear_output</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">index</span> <span class="pre">=</span> <span class="pre">0</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#clear_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Clears a clip previously set for output.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="clear_outputs">
<span class="sig-name descname"><span class="pre">clear_outputs</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#clear_outputs" title="Permalink to this definition">¶</a></dt>
<dd><p>Clears all clips set for output in the current environment.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="construct_signature">
<span class="sig-name descname"><span class="pre">construct_signature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">signature</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">injected=None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#construct_signature" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a <em>inspect.Signature</em> object for the given registration signature.</p>
<p>If <em>injected</em> is not None, the default of the first argument of the signature will be replaced with the value supplied with injected.</p>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="Core">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Core</span></span><a class="headerlink" href="#Core" title="Permalink to this definition">¶</a></dt>
<dd><p>The <em>Core</em> class uses a singleton pattern. Use the <em>core</em> attribute to obtain an
instance. All loaded plugins are exposed as attributes of the core object.
These attributes in turn hold the functions contained in the plugin.
Use <em>plugins()</em> to obtain a full list of all currently loaded plugins
you may call this way.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="Core.num_threads">
<span class="sig-name descname"><span class="pre">num_threads</span></span><a class="headerlink" href="#Core.num_threads" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of concurrent threads used by the core. Can be set to change the number. Setting to a value less than one makes it default to the number of hardware threads.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Core.max_cache_size">
<span class="sig-name descname"><span class="pre">max_cache_size</span></span><a class="headerlink" href="#Core.max_cache_size" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the upper framebuffer cache size after which memory is aggressively
freed. The value is in megabytes.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.plugins">
<span class="sig-name descname"><span class="pre">plugins</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Core.plugins" title="Permalink to this definition">¶</a></dt>
<dd><p>Containing all loaded plugins.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.get_plugins">
<span class="sig-name descname"><span class="pre">get_plugins</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Core.get_plugins" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>plugins()</em> instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.list_functions">
<span class="sig-name descname"><span class="pre">list_functions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Core.list_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>plugins()</em> instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.get_video_format">
<span class="sig-name descname"><span class="pre">get_video_format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.get_video_format" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a Format object corresponding to the specified id. Returns None if the <em>id</em> is invalid.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.get_format">
<span class="sig-name descname"><span class="pre">get_format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.get_format" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>get_video_format()</em> instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.query_video_format">
<span class="sig-name descname"><span class="pre">query_video_format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">color_family</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sample_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bits_per_sample</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subsampling_w</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subsampling_h</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.query_video_format" title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve a Format object corresponding to the format information, Invalid formats throw an exception.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.register_format">
<span class="sig-name descname"><span class="pre">register_format</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">color_family</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sample_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bits_per_sample</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subsampling_w</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">subsampling_h</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.register_format" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>query_video_format()</em> instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.add_log_handler">
<span class="sig-name descname"><span class="pre">add_log_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handler_func</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.add_log_handler" title="Permalink to this definition">¶</a></dt>
<dd><p>Installs a custom handler for the various error messages VapourSynth emits.
The message handler is currently global, i.e. per process, not per VSCore instance.
Returns a LogHandle object.
<em>handler_func</em> is a callback function of the form <em>func(MessageType, message)</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.remove_log_handler">
<span class="sig-name descname"><span class="pre">remove_log_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.remove_log_handler" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes a custom handler.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.log_message">
<span class="sig-name descname"><span class="pre">log_message</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">message_type</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#Core.log_message" title="Permalink to this definition">¶</a></dt>
<dd><p>Send a message through VapourSynth’s logging framework.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.version">
<span class="sig-name descname"><span class="pre">version</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Core.version" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns version information as a string.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Core.version_number">
<span class="sig-name descname"><span class="pre">version_number</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Core.version_number" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the core version as a number.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="VideoNode">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">VideoNode</span></span><a class="headerlink" href="#VideoNode" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a video clip. The class itself supports indexing and slicing to
perform trim, reverse and selectevery operations. Several operators are also
defined for the VideoNode class: addition appends clips and multiplication
repeats them. Note that slicing and indexing always return a new VideoNode
object and not a VideoFrame.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.format">
<span class="sig-name descname"><span class="pre">format</span></span><a class="headerlink" href="#VideoNode.format" title="Permalink to this definition">¶</a></dt>
<dd><p>A Format object describing the frame data. If the format can change
between frames, this value is None.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.width">
<span class="sig-name descname"><span class="pre">width</span></span><a class="headerlink" href="#VideoNode.width" title="Permalink to this definition">¶</a></dt>
<dd><p>The width of the video. This value will be 0 if the width and height can
change between frames.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.height">
<span class="sig-name descname"><span class="pre">height</span></span><a class="headerlink" href="#VideoNode.height" title="Permalink to this definition">¶</a></dt>
<dd><p>The height of the video. This value will be 0 if the width and height can
change between frames.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.num_frames">
<span class="sig-name descname"><span class="pre">num_frames</span></span><a class="headerlink" href="#VideoNode.num_frames" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of frames in the clip.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.fps">
<span class="sig-name descname"><span class="pre">fps</span></span><a class="headerlink" href="#VideoNode.fps" title="Permalink to this definition">¶</a></dt>
<dd><p>The framerate represented as a <em>Fraction</em>. It is 0/1 when the clip has a variable
framerate.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.numerator">
<span class="sig-name descname"><span class="pre">numerator</span></span><a class="headerlink" href="#VideoNode.numerator" title="Permalink to this definition">¶</a></dt>
<dd><p>The numerator of the framerate. If the clip has variable framerate, the value will be 0.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.denominator">
<span class="sig-name descname"><span class="pre">denominator</span></span><a class="headerlink" href="#VideoNode.denominator" title="Permalink to this definition">¶</a></dt>
<dd><p>The denominator of the framerate. If the clip has variable framerate, the value will be 0.</p>
</dd></dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.fps_num">
<span class="sig-name descname"><span class="pre">fps_num</span></span><a class="headerlink" href="#VideoNode.fps_num" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>fps.numerator</em> instead</p>
<p>The numerator of the framerate. If the clip has variable framerate, the
value will be 0.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.fps_den">
<span class="sig-name descname"><span class="pre">fps_den</span></span><a class="headerlink" href="#VideoNode.fps_den" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>fps.denominator</em> instead</p>
<p>The denominator of the framerate. If the clip has variable framerate, the
value will be 0.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoNode.flags">
<span class="sig-name descname"><span class="pre">flags</span></span><a class="headerlink" href="#VideoNode.flags" title="Permalink to this definition">¶</a></dt>
<dd><p>Special flags set for this clip. This attribute should normally be
ignored.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.get_frame">
<span class="sig-name descname"><span class="pre">get_frame</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.get_frame" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a VideoFrame from position <em>n</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.get_frame_async">
<span class="sig-name descname"><span class="pre">get_frame_async</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.get_frame_async" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a concurrent.futures.Future-object which result will be a VideoFrame instance or sets the
exception thrown when rendering the frame.</p>
<p><em>The future will always be in the running or completed state</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.get_frame_async_raw">
<span class="sig-name descname"><span class="pre">get_frame_async_raw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cb</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">callable</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.get_frame_async_raw" title="Permalink to this definition">¶</a></dt>
<dd><p>First form of this method. It will call the callback from another thread as soon as the frame is rendered.</p>
<p>The <cite>result</cite>-value passed to the callback will either be a VideoFrame-instance on success or a Error-instance
on failure.</p>
<p><em>This method is intended for glue code. For normal use, use get_frame_async instead.</em></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n</strong> – The frame number</p></li>
<li><p><strong>cb</strong> – A callback in the form <cite>cb(node, n, result)</cite></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">get_frame_async_raw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cb:</span> <span class="pre">Future</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">wrapper:</span> <span class="pre">callable</span> <span class="pre">=</span> <span class="pre">None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span></dt>
<dd><p>Second form of this method. It will take a Future-like object (including asyncio.Future or similar)
and set its result or exception according to the result of the function.</p>
<p>The optional <cite>wrapper</cite>-parameter is intended for calls like asyncio.EventLoop.call_soon_threadsafe in which
all calls to its future-object must be wrapped.</p>
<p><em>This method is intended for glue code. For normal use, use get_frame_async instead.</em></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n</strong> – The frame number</p></li>
<li><p><strong>cb</strong> – The future-object whose result will be set.</p></li>
<li><p><strong>wrapper</strong> – A wrapper-callback which is responsible for moving the result across thread boundaries. If not
given, the result of the future will be set in a random thread.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.set_output">
<span class="sig-name descname"><span class="pre">set_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpha</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alt_output</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.set_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the clip to be accessible for output. This is the standard way to
specify which clip(s) to output. All VapourSynth tools (vsvfw, vsfs,
vspipe) use the clip in <em>index</em> 0. It’s possible to specify an additional
containing the <em>alpha</em> to output at the same time. Currently only vspipe
takes <em>alpha</em> into consideration when outputting.
The <em>alt_output</em> argument is for optional alternate output modes. Currently
it controls the FOURCCs used for VFW-style output with certain formats.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.output">
<span class="sig-name descname"><span class="pre">output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fileobj</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">y4m</span> <span class="pre">=</span> <span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prefetch</span> <span class="pre">=</span> <span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">progress_update</span> <span class="pre">=</span> <span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backlog=-1</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.output" title="Permalink to this definition">¶</a></dt>
<dd><p>Write the whole clip to the specified file handle. It is possible to pipe to stdout by specifying <em>sys.stdout</em> as the file.
YUV4MPEG2 headers will be added when <em>y4m</em> is true.
The current progress can be reported by passing a callback function of the form <em>func(current_frame, total_frames)</em> to <em>progress_update</em>.
The <em>prefetch</em> argument is only for debugging purposes and should never need to be changed.
The <em>backlog</em> argument is only for debugging purposes and should never need to be changed.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoNode.frames">
<span class="sig-name descname"><span class="pre">frames</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">prefetch=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backlog=None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#VideoNode.frames" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a generator iterator of all VideoFrames in the clip. It will render multiple frames concurrently.</p>
<p>The <em>prefetch</em> argument defines how many frames are rendered concurrently. Is only there for debugging purposes and should never need to be changed.
The <em>backlog</em> argument defines how many unconsumed frames (including those that did not finish rendering yet) vapoursynth buffers at most before it stops rendering additional frames. This argument is there to limit the memory this function uses storing frames.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="VideoOutputTuple">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">VideoOutputTuple</span></span><a class="headerlink" href="#VideoOutputTuple" title="Permalink to this definition">¶</a></dt>
<dd><p>This class is returned by get_output if the output is video.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoOutputTuple.clip">
<span class="sig-name descname"><span class="pre">clip</span></span><a class="headerlink" href="#VideoOutputTuple.clip" title="Permalink to this definition">¶</a></dt>
<dd><p>A VideoNode-instance containing the color planes.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoOutputTuple.alpha">
<span class="sig-name descname"><span class="pre">alpha</span></span><a class="headerlink" href="#VideoOutputTuple.alpha" title="Permalink to this definition">¶</a></dt>
<dd><p>A VideoNode-instance containing the alpha planes.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoOutputTuple.alt_output">
<span class="sig-name descname"><span class="pre">alt_output</span></span><a class="headerlink" href="#VideoOutputTuple.alt_output" title="Permalink to this definition">¶</a></dt>
<dd><p>An integer with the alternate output mode to be used. May be ignored if no meaningful mapping exists.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="VideoFrame">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">VideoFrame</span></span><a class="headerlink" href="#VideoFrame" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>This class represents a video frame and all metadata attached to it.</p>
</div></blockquote>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFrame.format">
<span class="sig-name descname"><span class="pre">format</span></span><a class="headerlink" href="#VideoFrame.format" title="Permalink to this definition">¶</a></dt>
<dd><p>A Format object describing the frame data.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFrame.width">
<span class="sig-name descname"><span class="pre">width</span></span><a class="headerlink" href="#VideoFrame.width" title="Permalink to this definition">¶</a></dt>
<dd><p>The width of the frame.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFrame.height">
<span class="sig-name descname"><span class="pre">height</span></span><a class="headerlink" href="#VideoFrame.height" title="Permalink to this definition">¶</a></dt>
<dd><p>The height of the frame.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFrame.readonly">
<span class="sig-name descname"><span class="pre">readonly</span></span><a class="headerlink" href="#VideoFrame.readonly" title="Permalink to this definition">¶</a></dt>
<dd><p>If <em>readonly</em> is True, the frame data and properties cannot be modified.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFrame.props">
<span class="sig-name descname"><span class="pre">props</span></span><a class="headerlink" href="#VideoFrame.props" title="Permalink to this definition">¶</a></dt>
<dd><p>This attribute holds all the frame’s properties as a dict. They are also mapped as sub-attributes for
compatibility with older scripts. For more information, see:
<a class="reference external" href="apireference.html#reserved-frame-properties">API Reference</a>
Note: This includes the data for matrix, transfer and primaries. (_Matrix,
_Transfer, _Primaries) See <a class="reference external" href="functions/video/resize.html">Resize</a> for more information.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoFrame.copy">
<span class="sig-name descname"><span class="pre">copy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#VideoFrame.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a writable copy of the frame.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoFrame.get_read_ptr">
<span class="sig-name descname"><span class="pre">get_read_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoFrame.get_read_ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a pointer to the raw frame data. The data may not be modified.
Note that this is a thin wrapper for the underlying
C-api and as such calls to <em>get_write_ptr</em>, including the ones made internally by other functions in the Python bindings,
may invalidate any pointers previously gotten to the frame with
<em>get_read_ptr</em> when called.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoFrame.get_write_ptr">
<span class="sig-name descname"><span class="pre">get_write_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoFrame.get_write_ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a pointer to the raw frame data. It may be modified using ctypes
or some other similar python package. Note that this is a thin wrapper for the underlying
C-api and as such calls to <em>get_write_ptr</em>, including the ones made internally by other functions in the Python bindings,
may invalidate any pointers previously gotten to the frame with
<em>get_read_ptr</em> when called.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoFrame.get_stride">
<span class="sig-name descname"><span class="pre">get_stride</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoFrame.get_stride" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the stride between lines in a <em>plane</em>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="VideoFormat">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">VideoFormat</span></span><a class="headerlink" href="#VideoFormat" title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents all information needed to describe a frame format. It
holds the general color type, subsampling, number of planes and so on.
The names map directly to the C API so consult it for more detailed
information.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.id">
<span class="sig-name descname"><span class="pre">id</span></span><a class="headerlink" href="#VideoFormat.id" title="Permalink to this definition">¶</a></dt>
<dd><p>A unique <em>id</em> identifying the format.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.name">
<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#VideoFormat.name" title="Permalink to this definition">¶</a></dt>
<dd><p>A human readable name of the format.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.color_family">
<span class="sig-name descname"><span class="pre">color_family</span></span><a class="headerlink" href="#VideoFormat.color_family" title="Permalink to this definition">¶</a></dt>
<dd><p>Which group of colorspaces the format describes.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.sample_type">
<span class="sig-name descname"><span class="pre">sample_type</span></span><a class="headerlink" href="#VideoFormat.sample_type" title="Permalink to this definition">¶</a></dt>
<dd><p>If the format is integer or floating point based.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.bits_per_sample">
<span class="sig-name descname"><span class="pre">bits_per_sample</span></span><a class="headerlink" href="#VideoFormat.bits_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>How many bits are used to store one sample in one plane.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.bytes_per_sample">
<span class="sig-name descname"><span class="pre">bytes_per_sample</span></span><a class="headerlink" href="#VideoFormat.bytes_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>The actual storage is padded up to 2^n bytes for efficiency.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.subsampling_w">
<span class="sig-name descname"><span class="pre">subsampling_w</span></span><a class="headerlink" href="#VideoFormat.subsampling_w" title="Permalink to this definition">¶</a></dt>
<dd><p>The subsampling for the second and third plane in the horizontal
direction.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.subsampling_h">
<span class="sig-name descname"><span class="pre">subsampling_h</span></span><a class="headerlink" href="#VideoFormat.subsampling_h" title="Permalink to this definition">¶</a></dt>
<dd><p>The subsampling for the second and third plane in the vertical direction.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="VideoFormat.num_planes">
<span class="sig-name descname"><span class="pre">num_planes</span></span><a class="headerlink" href="#VideoFormat.num_planes" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of planes the format has.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="VideoFormat.replace">
<span class="sig-name descname"><span class="pre">replace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">core</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#VideoFormat.replace" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a new format with the given modifications.</p>
<p>The only supported attributes that can be replaced are <cite>color_family</cite>,
<cite>sample_type</cite>, <cite>bits_per_sample</cite>, <cite>subsampling_w</cite>, <cite>subsampling_h</cite>.</p>
<p>The optional <cite>core</cite>-parameter defines on which core the new format
should be registered. This is usually not needed and defaults
to the core of the current environment.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="AudioNode">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">AudioNode</span></span><a class="headerlink" href="#AudioNode" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents an audio clip. The class itself supports indexing and slicing to
perform trim, reverse and selectevery operations. Several operators are also
defined for the AudioNode class: addition appends clips and multiplication
repeats them. Note that slicing and indexing always return a new AudioNode
object and not a AudioFrame.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.sample_type">
<span class="sig-name descname"><span class="pre">sample_type</span></span><a class="headerlink" href="#AudioNode.sample_type" title="Permalink to this definition">¶</a></dt>
<dd><p>If the format is integer or floating point based.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.bits_per_sample">
<span class="sig-name descname"><span class="pre">bits_per_sample</span></span><a class="headerlink" href="#AudioNode.bits_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>How many bits are used to store one sample in one plane.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.bytes_per_sample">
<span class="sig-name descname"><span class="pre">bytes_per_sample</span></span><a class="headerlink" href="#AudioNode.bytes_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>The actual storage is padded up to 2^n bytes for efficiency.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.channel_layout">
<span class="sig-name descname"><span class="pre">channel_layout</span></span><a class="headerlink" href="#AudioNode.channel_layout" title="Permalink to this definition">¶</a></dt>
<dd><p>A mask of used channels.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.num_channels">
<span class="sig-name descname"><span class="pre">num_channels</span></span><a class="headerlink" href="#AudioNode.num_channels" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of channels the format has.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioNode.sample_rate">
<span class="sig-name descname"><span class="pre">sample_rate</span></span><a class="headerlink" href="#AudioNode.sample_rate" title="Permalink to this definition">¶</a></dt>
<dd><p>Playback sample rate.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioNode.get_frame">
<span class="sig-name descname"><span class="pre">get_frame</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioNode.get_frame" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an AudioFrame from position <em>n</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioNode.get_frame_async">
<span class="sig-name descname"><span class="pre">get_frame_async</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioNode.get_frame_async" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a concurrent.futures.Future-object which result will be an AudioFrame instance or sets the
exception thrown when rendering the frame.</p>
<p><em>The future will always be in the running or completed state</em></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioNode.get_frame_async_raw">
<span class="sig-name descname"><span class="pre">get_frame_async_raw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cb</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">callable</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioNode.get_frame_async_raw" title="Permalink to this definition">¶</a></dt>
<dd><p>First form of this method. It will call the callback from another thread as soon as the frame is rendered.</p>
<p>The <cite>result</cite>-value passed to the callback will either be a AudioFrame-instance on success or a Error-instance
on failure.</p>
<p><em>This method is intended for glue code. For normal use, use get_frame_async instead.</em></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n</strong> – The frame number</p></li>
<li><p><strong>cb</strong> – A callback in the form <cite>cb(node, n, result)</cite></p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py">
<span class="sig-name descname"><span class="pre">get_frame_async_raw</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cb:</span> <span class="pre">Future</span></span></em><span class="optional">[</span>, <em class="sig-param"><span class="n"><span class="pre">wrapper:</span> <span class="pre">callable</span> <span class="pre">=</span> <span class="pre">None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span></dt>
<dd><p>Second form of this method. It will take a Future-like object (including asyncio.Future or similar)
and set its result or exception according to the result of the function.</p>
<p>The optional <cite>wrapper</cite>-parameter is intended for calls like asyncio.EventLoop.call_soon_threadsafe in which
all calls to its future-object must be wrapped.</p>
<p><em>This method is intended for glue code. For normal use, use get_frame_async instead.</em></p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>n</strong> – The frame number</p></li>
<li><p><strong>cb</strong> – The future-object whose result will be set.</p></li>
<li><p><strong>wrapper</strong> – A wrapper-callback which is responsible for moving the result across thread boundaries. If not
given, the result of the future will be set in a random thread.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioNode.set_output">
<span class="sig-name descname"><span class="pre">set_output</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">index</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioNode.set_output" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the clip to be accessible for output.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioNode.frames">
<span class="sig-name descname"><span class="pre">frames</span></span><span class="sig-paren">(</span><span class="optional">[</span><em class="sig-param"><span class="n"><span class="pre">prefetch=None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">backlog=None</span></span></em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#AudioNode.frames" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a generator iterator of all AudioFrames in the clip. It will render multiple frames concurrently.</p>
<p>The <em>prefetch</em> argument defines how many frames are rendered concurrently. Is only there for debugging purposes and should never need to be changed.
The <em>backlog</em> argument defines how many unconsumed frames (including those that did not finish rendering yet) vapoursynth buffers at most before it stops rendering additional frames. This argument is there to limit the memory this function uses storing frames.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="AudioFrame">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">AudioFrame</span></span><a class="headerlink" href="#AudioFrame" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>This class represents an audio frame and all metadata attached to it.</p>
</div></blockquote>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.sample_type">
<span class="sig-name descname"><span class="pre">sample_type</span></span><a class="headerlink" href="#AudioFrame.sample_type" title="Permalink to this definition">¶</a></dt>
<dd><p>If the format is integer or floating point based.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.bits_per_sample">
<span class="sig-name descname"><span class="pre">bits_per_sample</span></span><a class="headerlink" href="#AudioFrame.bits_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>How many bits are used to store one sample in one plane.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.bytes_per_sample">
<span class="sig-name descname"><span class="pre">bytes_per_sample</span></span><a class="headerlink" href="#AudioFrame.bytes_per_sample" title="Permalink to this definition">¶</a></dt>
<dd><p>The actual storage is padded up to 2^n bytes for efficiency.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.channel_layout">
<span class="sig-name descname"><span class="pre">channel_layout</span></span><a class="headerlink" href="#AudioFrame.channel_layout" title="Permalink to this definition">¶</a></dt>
<dd><p>A mask of used channels.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.num_channels">
<span class="sig-name descname"><span class="pre">num_channels</span></span><a class="headerlink" href="#AudioFrame.num_channels" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of channels the format has.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.readonly">
<span class="sig-name descname"><span class="pre">readonly</span></span><a class="headerlink" href="#AudioFrame.readonly" title="Permalink to this definition">¶</a></dt>
<dd><p>If <em>readonly</em> is True, the frame data and properties cannot be modified.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="AudioFrame.props">
<span class="sig-name descname"><span class="pre">props</span></span><a class="headerlink" href="#AudioFrame.props" title="Permalink to this definition">¶</a></dt>
<dd><p>This attribute holds all the frame’s properties as a dict. Note that audio frame properties are fairly
non-sensical as a concept for audio due to an arbitrary number of samples being lumped together and rarely used.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioFrame.copy">
<span class="sig-name descname"><span class="pre">copy</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#AudioFrame.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a writable copy of the frame.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioFrame.get_read_ptr">
<span class="sig-name descname"><span class="pre">get_read_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioFrame.get_read_ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a pointer to the raw frame data. The data may not be modified.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioFrame.get_write_ptr">
<span class="sig-name descname"><span class="pre">get_write_ptr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioFrame.get_write_ptr" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a pointer to the raw frame data. It may be modified using ctypes
or some other similar python package.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="AudioFrame.get_stride">
<span class="sig-name descname"><span class="pre">get_stride</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">plane</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#AudioFrame.get_stride" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the stride between lines in a <em>plane</em>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="Plugin">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Plugin</span></span><a class="headerlink" href="#Plugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Plugin is a class that represents a loaded plugin and its namespace.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="Plugin.namespace">
<span class="sig-name descname"><span class="pre">namespace</span></span><a class="headerlink" href="#Plugin.namespace" title="Permalink to this definition">¶</a></dt>
<dd><p>The namespace of the plugin.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Plugin.name">
<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#Plugin.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name string of the plugin.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Plugin.identifier">
<span class="sig-name descname"><span class="pre">identifier</span></span><a class="headerlink" href="#Plugin.identifier" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Plugin.functions">
<span class="sig-name descname"><span class="pre">functions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Plugin.functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Containing all the functions in the plugin, You can access it by calling <em>core.<namespace>.functions()</em>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Plugin.get_functions">
<span class="sig-name descname"><span class="pre">get_functions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Plugin.get_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>functions()</em> instead.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="Plugin.list_functions">
<span class="sig-name descname"><span class="pre">list_functions</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Plugin.list_functions" title="Permalink to this definition">¶</a></dt>
<dd><p>Deprecated, use <em>functions()</em> instead.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="Function">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Function</span></span><a class="headerlink" href="#Function" title="Permalink to this definition">¶</a></dt>
<dd><p>Function is a simple wrapper class for a function provided by a VapourSynth plugin.
Its main purpose is to be called and nothing else.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="Function.name">
<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#Function.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The function name. Identical to the string used to register the function.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Function.plugin">
<span class="sig-name descname"><span class="pre">plugin</span></span><a class="headerlink" href="#Function.plugin" title="Permalink to this definition">¶</a></dt>
<dd><p>The <em>Plugin</em> object the function belongs to.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Function.signature">
<span class="sig-name descname"><span class="pre">signature</span></span><a class="headerlink" href="#Function.signature" title="Permalink to this definition">¶</a></dt>
<dd><p>Raw function signature string. Identical to the string used to register the function.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Function.return_signature">
<span class="sig-name descname"><span class="pre">return_signature</span></span><a class="headerlink" href="#Function.return_signature" title="Permalink to this definition">¶</a></dt>
<dd><p>Raw function signature string. Identical to the return type string used register the function.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="Environment">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Environment</span></span><a class="headerlink" href="#Environment" title="Permalink to this definition">¶</a></dt>
<dd><p>This class represents an environment.</p>
<p>Some editors allow multiple vapoursynth-scripts to run in the same process, each of them comes with a different Core-instance and
their own set of outputs. Each core-instance with their associated outputs represent their own environment.</p>
<p>At any given time, only one environment can be active (in the same context). This class allows introspection about
environments and allows to switch to them at will.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">env</span> <span class="o">=</span> <span class="n">get_current_environment</span><span class="p">()</span>
<span class="c1"># sometime later</span>
<span class="k">with</span> <span class="n">env</span><span class="o">.</span><span class="n">use</span><span class="p">():</span>
<span class="c1"># Do stuff inside this env.</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Environment-objects obtained using the <a class="reference internal" href="#vpy_current_environment" title="vpy_current_environment"><code class="xref py py-func docutils literal notranslate"><span class="pre">vpy_current_environment()</span></code></a> can directly be used as
as a context manager. This can cause undefined behaviour when used in combination with generators and/or
coroutines.</p>
<p>This context-manager maintains a thread-local environment-stack that is used to restore the previous environment.
This can cause issues if the frame is suspended inside the block.</p>
<p>A similar problem also existed in previous VapourSynth versions!</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">env</span> <span class="o">=</span> <span class="n">vpy_current_environment</span><span class="p">()</span>
<span class="k">with</span> <span class="n">env</span><span class="p">:</span>
<span class="k">yield</span>
</pre></div>
</div>
</div>
<dl class="py function">
<dt class="sig sig-object py" id="Environment.is_single">
<span class="sig-name descname"><span class="pre">is_single</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Environment.is_single" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the script is _not_ running inside a vsscript-Environment.
If it is running inside a vsscript-Environment, it returns False.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="Environment.env_id">
<span class="sig-name descname"><span class="pre">env_id</span></span><a class="headerlink" href="#Environment.env_id" title="Permalink to this definition">¶</a></dt>
<dd><p>Return -1 if the script is not running inside a vsscript-Environment.
Otherwise, it will return the current environment-id.</p>