typed-ffmpeg-compatible 3.3.1__py3-none-any.whl → 3.4.1__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.
Files changed (30) hide show
  1. typed_ffmpeg/__init__.py +3 -1
  2. typed_ffmpeg/_version.py +2 -2
  3. typed_ffmpeg/base.py +1 -1
  4. typed_ffmpeg/codecs/__init__.py +3 -0
  5. typed_ffmpeg/codecs/decoders.py +6644 -0
  6. typed_ffmpeg/codecs/encoders.py +6401 -0
  7. typed_ffmpeg/codecs/schema.py +17 -0
  8. typed_ffmpeg/common/serialize.py +1 -1
  9. typed_ffmpeg/dag/global_runnable/global_args.py +59 -55
  10. typed_ffmpeg/dag/io/_input.py +76 -64
  11. typed_ffmpeg/dag/io/_output.py +118 -105
  12. typed_ffmpeg/dag/io/output_args.py +122 -104
  13. typed_ffmpeg/dag/nodes.py +1 -1
  14. typed_ffmpeg/dag/schema.py +1 -1
  15. typed_ffmpeg/filters.py +1717 -675
  16. typed_ffmpeg/formats/__init__.py +3 -0
  17. typed_ffmpeg/formats/demuxers.py +6664 -0
  18. typed_ffmpeg/formats/muxers.py +3774 -0
  19. typed_ffmpeg/formats/schema.py +17 -0
  20. typed_ffmpeg/sources.py +1641 -571
  21. typed_ffmpeg/streams/audio.py +1994 -1554
  22. typed_ffmpeg/streams/video.py +4540 -2843
  23. typed_ffmpeg/utils/{forzendict.py → frozendict.py} +56 -1
  24. typed_ffmpeg/utils/run.py +1 -1
  25. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/METADATA +1 -1
  26. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/RECORD +30 -22
  27. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/WHEEL +0 -0
  28. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/entry_points.txt +0 -0
  29. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/licenses/LICENSE +0 -0
  30. {typed_ffmpeg_compatible-3.3.1.dist-info → typed_ffmpeg_compatible-3.4.1.dist-info}/top_level.txt +0 -0
@@ -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,18 @@
4
4
  from pathlib import Path
5
5
  from typing import Any
6
6
 
7
+ from ...codecs.schema import FFMpegDecoderOption
8
+ from ...formats.schema import FFMpegDemuxerOption
7
9
  from ...streams.av import AVStream
8
- from ...types import Boolean, Double, Float, Int, String, Time
9
- from ...utils.forzendict import FrozenDict
10
+ from ...types import (
11
+ Boolean,
12
+ Double,
13
+ Float,
14
+ Int,
15
+ String,
16
+ Time,
17
+ )
18
+ from ...utils.frozendict import merge
10
19
  from ..nodes import InputNode
11
20
 
12
21
 
@@ -65,7 +74,9 @@ def input(
65
74
  dcodec: String = None,
66
75
  dn: Boolean = None,
67
76
  top: Int = None,
68
- extra_options: dict[str, Any] = None,
77
+ decoder_options: FFMpegDecoderOption | None = None,
78
+ demuxer_options: FFMpegDemuxerOption | None = None,
79
+ extra_options: dict[str, Any] | None = None,
69
80
  ) -> AVStream:
70
81
  """
71
82
  Input file URL (ffmpeg ``-i`` option)
@@ -124,6 +135,8 @@ def input(
124
135
  dcodec: alias for -c:d (select encoder/decoder for data streams)
125
136
  dn: disable data
126
137
  top: deprecated, use the setfield video filter
138
+ decoder_options: ffmpeg's decoder options
139
+ demuxer_options: ffmpeg's demuxer options
127
140
  extra_options: ffmpeg's input file options
128
141
 
129
142
  Returns:
@@ -135,66 +148,65 @@ def input(
135
148
  <AVStream:input.mp4:0>
136
149
  ```
137
150
  """
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
151
  return InputNode(
199
- filename=str(filename), kwargs=FrozenDict(options | (extra_options or {}))
152
+ filename=str(filename),
153
+ kwargs=merge(
154
+ {
155
+ "f": f,
156
+ "c": c,
157
+ "codec": codec,
158
+ "t": t,
159
+ "to": to,
160
+ "ss": ss,
161
+ "sseof": sseof,
162
+ "seek_timestamp": seek_timestamp,
163
+ "accurate_seek": accurate_seek,
164
+ "isync": isync,
165
+ "itsoffset": itsoffset,
166
+ "itsscale": itsscale,
167
+ "re": re,
168
+ "readrate": readrate,
169
+ "readrate_initial_burst": readrate_initial_burst,
170
+ "bitexact": bitexact,
171
+ "tag": tag,
172
+ "reinit_filter": reinit_filter,
173
+ "dump_attachment": dump_attachment,
174
+ "stream_loop": stream_loop,
175
+ "discard": discard,
176
+ "thread_queue_size": thread_queue_size,
177
+ "find_stream_info": find_stream_info,
178
+ "r": r,
179
+ "s": s,
180
+ "pix_fmt": pix_fmt,
181
+ "display_rotation": display_rotation,
182
+ "display_hflip": display_hflip,
183
+ "display_vflip": display_vflip,
184
+ "vn": vn,
185
+ "vcodec": vcodec,
186
+ "vtag": vtag,
187
+ "hwaccel": hwaccel,
188
+ "hwaccel_device": hwaccel_device,
189
+ "hwaccel_output_format": hwaccel_output_format,
190
+ "autorotate": autorotate,
191
+ "ar": ar,
192
+ "ac": ac,
193
+ "an": an,
194
+ "acodec": acodec,
195
+ "sample_fmt": sample_fmt,
196
+ "channel_layout": channel_layout,
197
+ "ch_layout": ch_layout,
198
+ "guess_layout_max": guess_layout_max,
199
+ "sn": sn,
200
+ "scodec": scodec,
201
+ "fix_sub_duration": fix_sub_duration,
202
+ "canvas_size": canvas_size,
203
+ "bsf": bsf,
204
+ "dcodec": dcodec,
205
+ "dn": dn,
206
+ "top": top,
207
+ },
208
+ decoder_options.kwargs if decoder_options else {},
209
+ demuxer_options.kwargs if demuxer_options else {},
210
+ extra_options,
211
+ ),
200
212
  ).stream()
@@ -4,8 +4,18 @@
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 ...formats.schema import FFMpegMuxerOption
9
+ from ...types import (
10
+ Boolean,
11
+ Float,
12
+ Func,
13
+ Int,
14
+ Int64,
15
+ String,
16
+ Time,
17
+ )
18
+ from ...utils.frozendict import merge
9
19
  from ..nodes import FilterableStream, OutputNode, OutputStream
10
20
 
11
21
 
@@ -106,7 +116,9 @@ def output(
106
116
  dcodec: String = None,
107
117
  dn: Boolean = None,
108
118
  top: Int = None,
109
- extra_options: dict[str, Any] = None,
119
+ encoder_options: FFMpegEncoderOption | None = None,
120
+ muxer_options: FFMpegMuxerOption | None = None,
121
+ extra_options: dict[str, Any] | None = None,
110
122
  ) -> OutputStream:
111
123
  """
112
124
  Output file URL
@@ -209,115 +221,116 @@ def output(
209
221
  dcodec: alias for -c:d (select encoder/decoder for data streams)
210
222
  dn: disable data
211
223
  top: deprecated, use the setfield video filter
224
+ encoder_options: ffmpeg's encoder options
225
+ muxer_options: ffmpeg's muxer options
212
226
  extra_options: the arguments for the output
213
227
 
214
228
  Returns:
215
229
  the output stream
216
230
  """
217
231
 
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
232
  return OutputNode(
320
233
  inputs=streams,
321
234
  filename=str(filename),
322
- kwargs=FrozenDict(options | (extra_options or {})),
235
+ kwargs=merge(
236
+ {
237
+ "f": f,
238
+ "c": c,
239
+ "codec": codec,
240
+ "pre": pre,
241
+ "map": map,
242
+ "map_metadata": map_metadata,
243
+ "map_chapters": map_chapters,
244
+ "t": t,
245
+ "to": to,
246
+ "fs": fs,
247
+ "ss": ss,
248
+ "timestamp": timestamp,
249
+ "metadata": metadata,
250
+ "program": program,
251
+ "stream_group": stream_group,
252
+ "dframes": dframes,
253
+ "target": target,
254
+ "shortest": shortest,
255
+ "shortest_buf_duration": shortest_buf_duration,
256
+ "bitexact": bitexact,
257
+ "apad": apad,
258
+ "copyinkf": copyinkf,
259
+ "copypriorss": copypriorss,
260
+ "frames": frames,
261
+ "tag": tag,
262
+ "q": q,
263
+ "qscale": qscale,
264
+ "profile": profile,
265
+ "filter": filter,
266
+ "filter_script": filter_script,
267
+ "attach": attach,
268
+ "disposition": disposition,
269
+ "thread_queue_size": thread_queue_size,
270
+ "bits_per_raw_sample": bits_per_raw_sample,
271
+ "stats_enc_pre": stats_enc_pre,
272
+ "stats_enc_post": stats_enc_post,
273
+ "stats_mux_pre": stats_mux_pre,
274
+ "stats_enc_pre_fmt": stats_enc_pre_fmt,
275
+ "stats_enc_post_fmt": stats_enc_post_fmt,
276
+ "stats_mux_pre_fmt": stats_mux_pre_fmt,
277
+ "vframes": vframes,
278
+ "r": r,
279
+ "fpsmax": fpsmax,
280
+ "s": s,
281
+ "aspect": aspect,
282
+ "pix_fmt": pix_fmt,
283
+ "vn": vn,
284
+ "rc_override": rc_override,
285
+ "vcodec": vcodec,
286
+ "timecode": timecode,
287
+ "pass": _pass,
288
+ "passlogfile": passlogfile,
289
+ "vf": vf,
290
+ "intra_matrix": intra_matrix,
291
+ "inter_matrix": inter_matrix,
292
+ "chroma_intra_matrix": chroma_intra_matrix,
293
+ "vtag": vtag,
294
+ "fps_mode": fps_mode,
295
+ "force_fps": force_fps,
296
+ "streamid": streamid,
297
+ "force_key_frames": force_key_frames,
298
+ "b": b,
299
+ "autoscale": autoscale,
300
+ "fix_sub_duration_heartbeat": fix_sub_duration_heartbeat,
301
+ "aframes": aframes,
302
+ "aq": aq,
303
+ "ar": ar,
304
+ "ac": ac,
305
+ "an": an,
306
+ "acodec": acodec,
307
+ "ab": ab,
308
+ "atag": atag,
309
+ "sample_fmt": sample_fmt,
310
+ "channel_layout": channel_layout,
311
+ "ch_layout": ch_layout,
312
+ "af": af,
313
+ "sn": sn,
314
+ "scodec": scodec,
315
+ "stag": stag,
316
+ "muxdelay": muxdelay,
317
+ "muxpreload": muxpreload,
318
+ "sdp_file": sdp_file,
319
+ "time_base": time_base,
320
+ "enc_time_base": enc_time_base,
321
+ "bsf": bsf,
322
+ "apre": apre,
323
+ "vpre": vpre,
324
+ "spre": spre,
325
+ "fpre": fpre,
326
+ "max_muxing_queue_size": max_muxing_queue_size,
327
+ "muxing_queue_data_threshold": muxing_queue_data_threshold,
328
+ "dcodec": dcodec,
329
+ "dn": dn,
330
+ "top": top,
331
+ },
332
+ encoder_options.kwargs if encoder_options else {},
333
+ muxer_options.kwargs if muxer_options else {},
334
+ extra_options,
335
+ ),
323
336
  ).stream()