typed-ffmpeg-compatible 3.3.1__py3-none-any.whl → 3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ from dataclasses import dataclass
2
+
3
+ from ..common.serialize import Serializable
4
+ from ..utils.frozendict import FrozenDict
5
+
6
+
7
+ @dataclass(frozen=True, kw_only=True)
8
+ class FFMpegCodecOption(Serializable):
9
+ kwargs: FrozenDict[str, str | int | float | bool] = FrozenDict({})
10
+
11
+
12
+ @dataclass(frozen=True, kw_only=True)
13
+ class FFMpegEncoderOption(FFMpegCodecOption): ...
14
+
15
+
16
+ @dataclass(frozen=True, kw_only=True)
17
+ class FFMpegDecoderOption(FFMpegCodecOption): ...
@@ -15,7 +15,7 @@ from enum import Enum
15
15
  from pathlib import Path
16
16
  from typing import Any
17
17
 
18
- from ..utils.forzendict import FrozenDict
18
+ from ..utils.frozendict import FrozenDict
19
19
 
20
20
  CLASS_REGISTRY: dict[str, type[Serializable | Enum]] = {}
21
21
  """
@@ -1,10 +1,18 @@
1
1
  # NOTE: this file is auto-generated, do not modify
2
+
3
+
2
4
  from __future__ import annotations
3
5
 
4
6
  from abc import ABC, abstractmethod
5
7
  from typing import TYPE_CHECKING, Any
6
8
 
7
- from ...types import Boolean, Float, Func, Int
9
+ from ...types import (
10
+ Boolean,
11
+ Float,
12
+ Func,
13
+ Int,
14
+ )
15
+ from ...utils.frozendict import merge
8
16
 
9
17
  if TYPE_CHECKING:
10
18
  from ..nodes import GlobalNode, GlobalStream, OutputStream
@@ -73,7 +81,7 @@ class GlobalArgs(ABC):
73
81
  adrift_threshold: Func = None,
74
82
  qphist: Func = None,
75
83
  vsync: Func = None,
76
- extra_options: dict[str, Any] = None,
84
+ extra_options: dict[str, Any] | None = None,
77
85
  ) -> GlobalStream:
78
86
  """
79
87
  Set global options.
@@ -131,58 +139,54 @@ class GlobalArgs(ABC):
131
139
  """
132
140
 
133
141
  return self._global_node(
134
- **(
142
+ **merge(
135
143
  {
136
- k: v
137
- for k, v in {
138
- "loglevel": loglevel,
139
- "v": v,
140
- "report": report,
141
- "max_alloc": max_alloc,
142
- "cpuflags": cpuflags,
143
- "cpucount": cpucount,
144
- "hide_banner": hide_banner,
145
- "y": y,
146
- "n": n,
147
- "ignore_unknown": ignore_unknown,
148
- "copy_unknown": copy_unknown,
149
- "recast_media": recast_media,
150
- "benchmark": benchmark,
151
- "benchmark_all": benchmark_all,
152
- "progress": progress,
153
- "stdin": stdin,
154
- "timelimit": timelimit,
155
- "dump": dump,
156
- "hex": hex,
157
- "frame_drop_threshold": frame_drop_threshold,
158
- "copyts": copyts,
159
- "start_at_zero": start_at_zero,
160
- "copytb": copytb,
161
- "dts_delta_threshold": dts_delta_threshold,
162
- "dts_error_threshold": dts_error_threshold,
163
- "xerror": xerror,
164
- "abort_on": abort_on,
165
- "filter_threads": filter_threads,
166
- "filter_complex": filter_complex,
167
- "filter_complex_threads": filter_complex_threads,
168
- "lavfi": lavfi,
169
- "filter_complex_script": filter_complex_script,
170
- "auto_conversion_filters": auto_conversion_filters,
171
- "stats": stats,
172
- "stats_period": stats_period,
173
- "debug_ts": debug_ts,
174
- "max_error_rate": max_error_rate,
175
- "vstats": vstats,
176
- "vstats_file": vstats_file,
177
- "vstats_version": vstats_version,
178
- "init_hw_device": init_hw_device,
179
- "filter_hw_device": filter_hw_device,
180
- "adrift_threshold": adrift_threshold,
181
- "qphist": qphist,
182
- "vsync": vsync,
183
- }.items()
184
- if v is not None
185
- }
186
- | (extra_options or {})
187
- ),
144
+ "loglevel": loglevel,
145
+ "v": v,
146
+ "report": report,
147
+ "max_alloc": max_alloc,
148
+ "cpuflags": cpuflags,
149
+ "cpucount": cpucount,
150
+ "hide_banner": hide_banner,
151
+ "y": y,
152
+ "n": n,
153
+ "ignore_unknown": ignore_unknown,
154
+ "copy_unknown": copy_unknown,
155
+ "recast_media": recast_media,
156
+ "benchmark": benchmark,
157
+ "benchmark_all": benchmark_all,
158
+ "progress": progress,
159
+ "stdin": stdin,
160
+ "timelimit": timelimit,
161
+ "dump": dump,
162
+ "hex": hex,
163
+ "frame_drop_threshold": frame_drop_threshold,
164
+ "copyts": copyts,
165
+ "start_at_zero": start_at_zero,
166
+ "copytb": copytb,
167
+ "dts_delta_threshold": dts_delta_threshold,
168
+ "dts_error_threshold": dts_error_threshold,
169
+ "xerror": xerror,
170
+ "abort_on": abort_on,
171
+ "filter_threads": filter_threads,
172
+ "filter_complex": filter_complex,
173
+ "filter_complex_threads": filter_complex_threads,
174
+ "lavfi": lavfi,
175
+ "filter_complex_script": filter_complex_script,
176
+ "auto_conversion_filters": auto_conversion_filters,
177
+ "stats": stats,
178
+ "stats_period": stats_period,
179
+ "debug_ts": debug_ts,
180
+ "max_error_rate": max_error_rate,
181
+ "vstats": vstats,
182
+ "vstats_file": vstats_file,
183
+ "vstats_version": vstats_version,
184
+ "init_hw_device": init_hw_device,
185
+ "filter_hw_device": filter_hw_device,
186
+ "adrift_threshold": adrift_threshold,
187
+ "qphist": qphist,
188
+ "vsync": vsync,
189
+ },
190
+ extra_options,
191
+ )
188
192
  ).stream()
@@ -4,9 +4,17 @@
4
4
  from pathlib import Path
5
5
  from typing import Any
6
6
 
7
+ from ...codecs.schema import FFMpegDecoderOption
7
8
  from ...streams.av import AVStream
8
- from ...types import Boolean, Double, Float, Int, String, Time
9
- from ...utils.forzendict import FrozenDict
9
+ from ...types import (
10
+ Boolean,
11
+ Double,
12
+ Float,
13
+ Int,
14
+ String,
15
+ Time,
16
+ )
17
+ from ...utils.frozendict import merge
10
18
  from ..nodes import InputNode
11
19
 
12
20
 
@@ -65,7 +73,8 @@ def input(
65
73
  dcodec: String = None,
66
74
  dn: Boolean = None,
67
75
  top: Int = None,
68
- extra_options: dict[str, Any] = None,
76
+ decoder_options: FFMpegDecoderOption | None = None,
77
+ extra_options: dict[str, Any] | None = None,
69
78
  ) -> AVStream:
70
79
  """
71
80
  Input file URL (ffmpeg ``-i`` option)
@@ -124,6 +133,7 @@ def input(
124
133
  dcodec: alias for -c:d (select encoder/decoder for data streams)
125
134
  dn: disable data
126
135
  top: deprecated, use the setfield video filter
136
+ decoder_options: ffmpeg's decoder options
127
137
  extra_options: ffmpeg's input file options
128
138
 
129
139
  Returns:
@@ -135,66 +145,64 @@ def input(
135
145
  <AVStream:input.mp4:0>
136
146
  ```
137
147
  """
138
-
139
- options = {
140
- k: v
141
- for k, v in {
142
- "f": f,
143
- "c": c,
144
- "codec": codec,
145
- "t": t,
146
- "to": to,
147
- "ss": ss,
148
- "sseof": sseof,
149
- "seek_timestamp": seek_timestamp,
150
- "accurate_seek": accurate_seek,
151
- "isync": isync,
152
- "itsoffset": itsoffset,
153
- "itsscale": itsscale,
154
- "re": re,
155
- "readrate": readrate,
156
- "readrate_initial_burst": readrate_initial_burst,
157
- "bitexact": bitexact,
158
- "tag": tag,
159
- "reinit_filter": reinit_filter,
160
- "dump_attachment": dump_attachment,
161
- "stream_loop": stream_loop,
162
- "discard": discard,
163
- "thread_queue_size": thread_queue_size,
164
- "find_stream_info": find_stream_info,
165
- "r": r,
166
- "s": s,
167
- "pix_fmt": pix_fmt,
168
- "display_rotation": display_rotation,
169
- "display_hflip": display_hflip,
170
- "display_vflip": display_vflip,
171
- "vn": vn,
172
- "vcodec": vcodec,
173
- "vtag": vtag,
174
- "hwaccel": hwaccel,
175
- "hwaccel_device": hwaccel_device,
176
- "hwaccel_output_format": hwaccel_output_format,
177
- "autorotate": autorotate,
178
- "ar": ar,
179
- "ac": ac,
180
- "an": an,
181
- "acodec": acodec,
182
- "sample_fmt": sample_fmt,
183
- "channel_layout": channel_layout,
184
- "ch_layout": ch_layout,
185
- "guess_layout_max": guess_layout_max,
186
- "sn": sn,
187
- "scodec": scodec,
188
- "fix_sub_duration": fix_sub_duration,
189
- "canvas_size": canvas_size,
190
- "bsf": bsf,
191
- "dcodec": dcodec,
192
- "dn": dn,
193
- "top": top,
194
- }.items()
195
- if v is not None
196
- }
197
-
198
148
  return InputNode(
199
- filename=str(filename), kwargs=FrozenDict(options | (extra_options or {}))
149
+ filename=str(filename),
150
+ kwargs=merge(
151
+ {
152
+ "f": f,
153
+ "c": c,
154
+ "codec": codec,
155
+ "t": t,
156
+ "to": to,
157
+ "ss": ss,
158
+ "sseof": sseof,
159
+ "seek_timestamp": seek_timestamp,
160
+ "accurate_seek": accurate_seek,
161
+ "isync": isync,
162
+ "itsoffset": itsoffset,
163
+ "itsscale": itsscale,
164
+ "re": re,
165
+ "readrate": readrate,
166
+ "readrate_initial_burst": readrate_initial_burst,
167
+ "bitexact": bitexact,
168
+ "tag": tag,
169
+ "reinit_filter": reinit_filter,
170
+ "dump_attachment": dump_attachment,
171
+ "stream_loop": stream_loop,
172
+ "discard": discard,
173
+ "thread_queue_size": thread_queue_size,
174
+ "find_stream_info": find_stream_info,
175
+ "r": r,
176
+ "s": s,
177
+ "pix_fmt": pix_fmt,
178
+ "display_rotation": display_rotation,
179
+ "display_hflip": display_hflip,
180
+ "display_vflip": display_vflip,
181
+ "vn": vn,
182
+ "vcodec": vcodec,
183
+ "vtag": vtag,
184
+ "hwaccel": hwaccel,
185
+ "hwaccel_device": hwaccel_device,
186
+ "hwaccel_output_format": hwaccel_output_format,
187
+ "autorotate": autorotate,
188
+ "ar": ar,
189
+ "ac": ac,
190
+ "an": an,
191
+ "acodec": acodec,
192
+ "sample_fmt": sample_fmt,
193
+ "channel_layout": channel_layout,
194
+ "ch_layout": ch_layout,
195
+ "guess_layout_max": guess_layout_max,
196
+ "sn": sn,
197
+ "scodec": scodec,
198
+ "fix_sub_duration": fix_sub_duration,
199
+ "canvas_size": canvas_size,
200
+ "bsf": bsf,
201
+ "dcodec": dcodec,
202
+ "dn": dn,
203
+ "top": top,
204
+ },
205
+ decoder_options.kwargs if decoder_options else {},
206
+ extra_options,
207
+ ),
200
208
  ).stream()
@@ -4,8 +4,17 @@
4
4
  from pathlib import Path
5
5
  from typing import Any
6
6
 
7
- from ...types import Boolean, Float, Func, Int, Int64, String, Time
8
- from ...utils.forzendict import FrozenDict
7
+ from ...codecs.schema import FFMpegEncoderOption
8
+ from ...types import (
9
+ Boolean,
10
+ Float,
11
+ Func,
12
+ Int,
13
+ Int64,
14
+ String,
15
+ Time,
16
+ )
17
+ from ...utils.frozendict import merge
9
18
  from ..nodes import FilterableStream, OutputNode, OutputStream
10
19
 
11
20
 
@@ -106,7 +115,8 @@ def output(
106
115
  dcodec: String = None,
107
116
  dn: Boolean = None,
108
117
  top: Int = None,
109
- extra_options: dict[str, Any] = None,
118
+ encoder_options: FFMpegEncoderOption | None = None,
119
+ extra_options: dict[str, Any] | None = None,
110
120
  ) -> OutputStream:
111
121
  """
112
122
  Output file URL
@@ -209,115 +219,114 @@ def output(
209
219
  dcodec: alias for -c:d (select encoder/decoder for data streams)
210
220
  dn: disable data
211
221
  top: deprecated, use the setfield video filter
222
+ encoder_options: ffmpeg's encoder options
212
223
  extra_options: the arguments for the output
213
224
 
214
225
  Returns:
215
226
  the output stream
216
227
  """
217
228
 
218
- options = {
219
- k: v
220
- for k, v in {
221
- "f": f,
222
- "c": c,
223
- "codec": codec,
224
- "pre": pre,
225
- "map": map,
226
- "map_metadata": map_metadata,
227
- "map_chapters": map_chapters,
228
- "t": t,
229
- "to": to,
230
- "fs": fs,
231
- "ss": ss,
232
- "timestamp": timestamp,
233
- "metadata": metadata,
234
- "program": program,
235
- "stream_group": stream_group,
236
- "dframes": dframes,
237
- "target": target,
238
- "shortest": shortest,
239
- "shortest_buf_duration": shortest_buf_duration,
240
- "bitexact": bitexact,
241
- "apad": apad,
242
- "copyinkf": copyinkf,
243
- "copypriorss": copypriorss,
244
- "frames": frames,
245
- "tag": tag,
246
- "q": q,
247
- "qscale": qscale,
248
- "profile": profile,
249
- "filter": filter,
250
- "filter_script": filter_script,
251
- "attach": attach,
252
- "disposition": disposition,
253
- "thread_queue_size": thread_queue_size,
254
- "bits_per_raw_sample": bits_per_raw_sample,
255
- "stats_enc_pre": stats_enc_pre,
256
- "stats_enc_post": stats_enc_post,
257
- "stats_mux_pre": stats_mux_pre,
258
- "stats_enc_pre_fmt": stats_enc_pre_fmt,
259
- "stats_enc_post_fmt": stats_enc_post_fmt,
260
- "stats_mux_pre_fmt": stats_mux_pre_fmt,
261
- "vframes": vframes,
262
- "r": r,
263
- "fpsmax": fpsmax,
264
- "s": s,
265
- "aspect": aspect,
266
- "pix_fmt": pix_fmt,
267
- "vn": vn,
268
- "rc_override": rc_override,
269
- "vcodec": vcodec,
270
- "timecode": timecode,
271
- "pass": _pass,
272
- "passlogfile": passlogfile,
273
- "vf": vf,
274
- "intra_matrix": intra_matrix,
275
- "inter_matrix": inter_matrix,
276
- "chroma_intra_matrix": chroma_intra_matrix,
277
- "vtag": vtag,
278
- "fps_mode": fps_mode,
279
- "force_fps": force_fps,
280
- "streamid": streamid,
281
- "force_key_frames": force_key_frames,
282
- "b": b,
283
- "autoscale": autoscale,
284
- "fix_sub_duration_heartbeat": fix_sub_duration_heartbeat,
285
- "aframes": aframes,
286
- "aq": aq,
287
- "ar": ar,
288
- "ac": ac,
289
- "an": an,
290
- "acodec": acodec,
291
- "ab": ab,
292
- "atag": atag,
293
- "sample_fmt": sample_fmt,
294
- "channel_layout": channel_layout,
295
- "ch_layout": ch_layout,
296
- "af": af,
297
- "sn": sn,
298
- "scodec": scodec,
299
- "stag": stag,
300
- "muxdelay": muxdelay,
301
- "muxpreload": muxpreload,
302
- "sdp_file": sdp_file,
303
- "time_base": time_base,
304
- "enc_time_base": enc_time_base,
305
- "bsf": bsf,
306
- "apre": apre,
307
- "vpre": vpre,
308
- "spre": spre,
309
- "fpre": fpre,
310
- "max_muxing_queue_size": max_muxing_queue_size,
311
- "muxing_queue_data_threshold": muxing_queue_data_threshold,
312
- "dcodec": dcodec,
313
- "dn": dn,
314
- "top": top,
315
- }.items()
316
- if v is not None
317
- }
318
-
319
229
  return OutputNode(
320
230
  inputs=streams,
321
231
  filename=str(filename),
322
- kwargs=FrozenDict(options | (extra_options or {})),
232
+ kwargs=merge(
233
+ {
234
+ "f": f,
235
+ "c": c,
236
+ "codec": codec,
237
+ "pre": pre,
238
+ "map": map,
239
+ "map_metadata": map_metadata,
240
+ "map_chapters": map_chapters,
241
+ "t": t,
242
+ "to": to,
243
+ "fs": fs,
244
+ "ss": ss,
245
+ "timestamp": timestamp,
246
+ "metadata": metadata,
247
+ "program": program,
248
+ "stream_group": stream_group,
249
+ "dframes": dframes,
250
+ "target": target,
251
+ "shortest": shortest,
252
+ "shortest_buf_duration": shortest_buf_duration,
253
+ "bitexact": bitexact,
254
+ "apad": apad,
255
+ "copyinkf": copyinkf,
256
+ "copypriorss": copypriorss,
257
+ "frames": frames,
258
+ "tag": tag,
259
+ "q": q,
260
+ "qscale": qscale,
261
+ "profile": profile,
262
+ "filter": filter,
263
+ "filter_script": filter_script,
264
+ "attach": attach,
265
+ "disposition": disposition,
266
+ "thread_queue_size": thread_queue_size,
267
+ "bits_per_raw_sample": bits_per_raw_sample,
268
+ "stats_enc_pre": stats_enc_pre,
269
+ "stats_enc_post": stats_enc_post,
270
+ "stats_mux_pre": stats_mux_pre,
271
+ "stats_enc_pre_fmt": stats_enc_pre_fmt,
272
+ "stats_enc_post_fmt": stats_enc_post_fmt,
273
+ "stats_mux_pre_fmt": stats_mux_pre_fmt,
274
+ "vframes": vframes,
275
+ "r": r,
276
+ "fpsmax": fpsmax,
277
+ "s": s,
278
+ "aspect": aspect,
279
+ "pix_fmt": pix_fmt,
280
+ "vn": vn,
281
+ "rc_override": rc_override,
282
+ "vcodec": vcodec,
283
+ "timecode": timecode,
284
+ "pass": _pass,
285
+ "passlogfile": passlogfile,
286
+ "vf": vf,
287
+ "intra_matrix": intra_matrix,
288
+ "inter_matrix": inter_matrix,
289
+ "chroma_intra_matrix": chroma_intra_matrix,
290
+ "vtag": vtag,
291
+ "fps_mode": fps_mode,
292
+ "force_fps": force_fps,
293
+ "streamid": streamid,
294
+ "force_key_frames": force_key_frames,
295
+ "b": b,
296
+ "autoscale": autoscale,
297
+ "fix_sub_duration_heartbeat": fix_sub_duration_heartbeat,
298
+ "aframes": aframes,
299
+ "aq": aq,
300
+ "ar": ar,
301
+ "ac": ac,
302
+ "an": an,
303
+ "acodec": acodec,
304
+ "ab": ab,
305
+ "atag": atag,
306
+ "sample_fmt": sample_fmt,
307
+ "channel_layout": channel_layout,
308
+ "ch_layout": ch_layout,
309
+ "af": af,
310
+ "sn": sn,
311
+ "scodec": scodec,
312
+ "stag": stag,
313
+ "muxdelay": muxdelay,
314
+ "muxpreload": muxpreload,
315
+ "sdp_file": sdp_file,
316
+ "time_base": time_base,
317
+ "enc_time_base": enc_time_base,
318
+ "bsf": bsf,
319
+ "apre": apre,
320
+ "vpre": vpre,
321
+ "spre": spre,
322
+ "fpre": fpre,
323
+ "max_muxing_queue_size": max_muxing_queue_size,
324
+ "muxing_queue_data_threshold": muxing_queue_data_threshold,
325
+ "dcodec": dcodec,
326
+ "dn": dn,
327
+ "top": top,
328
+ },
329
+ encoder_options.kwargs if encoder_options else {},
330
+ extra_options,
331
+ ),
323
332
  ).stream()