cutcutcodec 1.0.post3__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.
Potentially problematic release.
This version of cutcutcodec might be problematic. Click here for more details.
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__main__.py +38 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/c_build.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/_helper_properties.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/duration.py +83 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/ffprobe.py +637 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/find.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/time_backprop.py +68 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_audio.py +239 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_video.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/shape.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/time_backprop.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/duration.py +162 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/nb_frames.py +159 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/rate.py +102 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/timestamps.py +194 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/container.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/encoder.py +152 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/filter.py +33 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame.py +127 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_audio.py +205 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_video.py +322 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/layout.py +206 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/meta_filter.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/muxer.py +184 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/node.py +164 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream.py +182 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_audio.py +130 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_video.py +193 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/__init__.py +7 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/ast_to_file.py +125 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/__init__.py +6 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/compatibility.py +734 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/default.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/encodec.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/muxer.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/rate.py +133 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_ast.py +477 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_json.py +104 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_tree.py +190 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/json_to_graph.py +114 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/parse.py +123 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/__init__.py +15 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/dynamic.py +544 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/lambdify.py +612 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/preprocess.py +698 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/printer.py +926 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/tree_to_graph.py +168 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/decision/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/add.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/remove.py +476 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/exceptions.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/add.py +170 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cut.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/delay.py +85 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/equation.py +261 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/fir.py +231 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/resample.py +451 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/cut.py +74 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/audio_cast.py +208 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/video_cast.py +197 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/subclip.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/add.py +331 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cat.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cut.py +113 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/delay.py +84 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/equation.py +265 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/identity.py +48 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/pad.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/subclip.py +91 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/empty.py +73 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/equation.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/noise.py +243 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/c_fractal.cpython-312-x86_64-linux-gnu.so +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/empty.py +69 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/equation.py +109 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/fractal.c +116 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/geometry.py +100 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/mandelbrot.py +176 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/noise.py +112 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/seedable.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_ffmpeg.py +904 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_svg.py +145 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/scheduler.py +356 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/write.py +340 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/basic.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/graph.py +80 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/graph.py +81 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/singleton.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cuda/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/proba.py +189 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/__init__.py +5 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/delay_to_fir.py +88 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/graph.py +17 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/buffer.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/utils.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/audio_5.1_narration.oga +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/intro.webm +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/logo.svg +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/project.json +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/video.mp4 +0 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__main__.py +25 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/actions.py +63 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/app.py +248 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/base.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/container_input_ffmpeg.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_equation.py +45 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_fir.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_cut.py +82 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_delay.py +20 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_subclip.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_delay.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_equation.py +53 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_subclip.py +9 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_equation.py +14 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_noise.py +19 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_equation.py +13 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_mandelbrot.py +60 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_noise.py +18 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/base.py +99 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/default.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/documentation.py +47 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/general.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/interface.py +305 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/loader.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/main.py +62 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edition_tabs.py +34 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/base.py +122 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/filters.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/generators.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry_tabs.py +46 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/_helper.py +54 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/container.py +226 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/doc.py +67 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/encodec.py +289 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/main.py +173 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/edge_properties.py +56 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/main.py +280 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/node.py +44 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/main.py +151 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/menu.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/audio_settings.py +183 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/main.py +41 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/video_settings.py +257 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/run.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/main.py +30 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/slider.py +286 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/track.py +97 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/view.py +90 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/toolbar.py +29 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/tools.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/__init__.py +3 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/audio_player.py +103 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/control.py +96 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/frame_extractor.py +254 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/main.py +115 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__init__.py +8 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__main__.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/coding_style.py +49 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/generation.py +52 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/install.py +72 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/run.py +58 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/abstract.py +215 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_cast.py +35 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_equation.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/c_memory.py +132 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compatibility.py +27 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compile.py +42 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/encoder.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_cut.py +107 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_delay.py +71 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_empty.py +40 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/fir.py +143 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/hashes.py +23 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/initialisation.py +24 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/muxer.py +22 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/nan_snapshot.py +39 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/read.py +192 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/serialization_equality.py +50 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/snapshot_shape.py +21 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/sympy_to_torch.py +135 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/thread_safe.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/time_range.py +55 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/video_equation.py +77 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/write.py +95 -0
- cutcutcodec-1.0.post3.data/platlib/cutcutcodec/utils.py +40 -0
- cutcutcodec-1.0.post3.dist-info/LICENSE +7 -0
- cutcutcodec-1.0.post3.dist-info/METADATA +271 -0
- cutcutcodec-1.0.post3.dist-info/RECORD +233 -0
- cutcutcodec-1.0.post3.dist-info/WHEEL +5 -0
- cutcutcodec-1.0.post3.dist-info/entry_points.txt +6 -0
- cutcutcodec-1.0.post3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Recover the date of all the frames that make up a video stream.
|
|
4
|
+
|
|
5
|
+
This information is more accurate than the simple ``fps``
|
|
6
|
+
but it takes much longer to retrieve since it requires decoding the entire file.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from fractions import Fraction
|
|
10
|
+
import collections
|
|
11
|
+
import pathlib
|
|
12
|
+
import typing
|
|
13
|
+
|
|
14
|
+
import cv2 # pip install opencv-contrib-python-headless
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
from cutcutcodec.core.analysis._helper_properties import _check_pathexists_index, _mix_and_check
|
|
18
|
+
from cutcutcodec.core.analysis.ffprobe import _decode_timestamps_ffmpeg, _map_index_rel_to_abs
|
|
19
|
+
from cutcutcodec.core.exceptions import MissingStreamError
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _decode_timestamps_cv2(filename: str, index: int) -> np.ndarray[typing.Union[None, Fraction]]:
|
|
23
|
+
"""Retrieve from cv2 the position of the frames in the video.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> from cutcutcodec.core.analysis.video.properties.timestamps import _decode_timestamps_cv2
|
|
28
|
+
>>> _decode_timestamps_cv2("cutcutcodec/examples/video.mp4", 0) # doctest: +ELLIPSIS
|
|
29
|
+
array([Fraction(0, 1), Fraction(1, 25), Fraction(2, 25), Fraction(3, 25),
|
|
30
|
+
Fraction(4, 25), Fraction(1, 5), Fraction(6, 25), Fraction(7, 25),
|
|
31
|
+
Fraction(8, 25), Fraction(9, 25), Fraction(2, 5), Fraction(11, 25),
|
|
32
|
+
...
|
|
33
|
+
Fraction(393, 25), Fraction(394, 25), Fraction(79, 5),
|
|
34
|
+
Fraction(396, 25), Fraction(397, 25), Fraction(398, 25),
|
|
35
|
+
Fraction(399, 25)], dtype=object)
|
|
36
|
+
>>>
|
|
37
|
+
"""
|
|
38
|
+
cap = cv2.VideoCapture(filename, index)
|
|
39
|
+
if not cap.isOpened():
|
|
40
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
41
|
+
|
|
42
|
+
pos_list = []
|
|
43
|
+
|
|
44
|
+
while True:
|
|
45
|
+
if not cap.read()[0]:
|
|
46
|
+
break
|
|
47
|
+
pos_curr = cap.get(cv2.CAP_PROP_POS_MSEC)
|
|
48
|
+
if pos_curr == 0.0 and pos_list:
|
|
49
|
+
pos_list.append(None)
|
|
50
|
+
else:
|
|
51
|
+
pos_list.append(Fraction(round(pos_curr), 1000))
|
|
52
|
+
cap.release()
|
|
53
|
+
|
|
54
|
+
if not pos_list:
|
|
55
|
+
raise MissingStreamError(f"'cv2' does not detect any frame in '{filename}' stream {index}")
|
|
56
|
+
if np.all(np.equal(pos_list, None)):
|
|
57
|
+
raise MissingStreamError(
|
|
58
|
+
f"'cv2' is unable to locate the frames of '{filename}' stream {index}"
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return np.array(pos_list, dtype=object)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _interpolate(
|
|
65
|
+
sequence: np.ndarray[typing.Optional[Fraction]]
|
|
66
|
+
) -> np.ndarray[typing.Union[None, Fraction]]:
|
|
67
|
+
"""Interpolates a numpy vector to replace the None with a consistent value.
|
|
68
|
+
|
|
69
|
+
The interpolation is a linear interpolation based on the least squares.
|
|
70
|
+
|
|
71
|
+
Parameters
|
|
72
|
+
----------
|
|
73
|
+
sequence : np.ndarray[typing.Union[None, Fraction]]
|
|
74
|
+
The 1d vector containing None.
|
|
75
|
+
|
|
76
|
+
Returns
|
|
77
|
+
-------
|
|
78
|
+
interp : np.ndarray[typing.Union[None, Fraction]]
|
|
79
|
+
The input vector with the nan replaced by there interpolated value.
|
|
80
|
+
|
|
81
|
+
Notes
|
|
82
|
+
-----
|
|
83
|
+
Modifies inplace the values of the array, does not make a copy.
|
|
84
|
+
|
|
85
|
+
Examples
|
|
86
|
+
--------
|
|
87
|
+
>>> from fractions import Fraction
|
|
88
|
+
>>> import numpy as np
|
|
89
|
+
>>> from cutcutcodec.core.analysis.video.properties.timestamps import _interpolate
|
|
90
|
+
>>> _interpolate(np.array([Fraction(0), None, Fraction(1)]))
|
|
91
|
+
array([Fraction(0, 1), Fraction(1, 2), Fraction(1, 1)], dtype=object)
|
|
92
|
+
>>> _interpolate(np.array([None, Fraction(1, 2), Fraction(1)]))
|
|
93
|
+
array([Fraction(0, 1), Fraction(1, 2), Fraction(1, 1)], dtype=object)
|
|
94
|
+
>>> _interpolate(np.array([Fraction(0), Fraction(1, 2), None]))
|
|
95
|
+
array([Fraction(0, 1), Fraction(1, 2), Fraction(1, 1)], dtype=object)
|
|
96
|
+
>>>
|
|
97
|
+
"""
|
|
98
|
+
assert isinstance(sequence, np.ndarray)
|
|
99
|
+
assert sequence.ndim == 1
|
|
100
|
+
|
|
101
|
+
nans = np.equal(sequence, None)
|
|
102
|
+
not_nans = ~nans
|
|
103
|
+
grade, mean = np.polyfit(
|
|
104
|
+
np.arange(len(sequence))[not_nans], sequence[not_nans].astype(float), deg=1
|
|
105
|
+
)
|
|
106
|
+
new_vals = mean + grade*np.arange(len(sequence))[nans]
|
|
107
|
+
new_vals = np.vectorize(lambda v: Fraction(v).limit_denominator(1001))(new_vals)
|
|
108
|
+
sequence[nans] = new_vals
|
|
109
|
+
return sequence
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def get_timestamps_video(
|
|
113
|
+
filename: typing.Union[str, bytes, pathlib.Path],
|
|
114
|
+
index: int = 0,
|
|
115
|
+
*,
|
|
116
|
+
backend: typing.Union[None, str] = None,
|
|
117
|
+
interpolate: bool = True
|
|
118
|
+
) -> np.ndarray[typing.Union[None, Fraction]]:
|
|
119
|
+
"""Recover the date of appearance of the frames.
|
|
120
|
+
|
|
121
|
+
In case the frame rate is perfectly constant, this returns
|
|
122
|
+
``[0, 1/fps, 2/fps, ..., (n-1)/fps]`` with n the number of frames present in the video.
|
|
123
|
+
But in case the frequency of images is not quite constant, this function has more interest.
|
|
124
|
+
|
|
125
|
+
Parameters
|
|
126
|
+
----------
|
|
127
|
+
filename : pathlike
|
|
128
|
+
The pathlike of the file containing a video stream.
|
|
129
|
+
index : int
|
|
130
|
+
The relative index of the video stream being considered,
|
|
131
|
+
by default the first stream encountered is selected.
|
|
132
|
+
backend : str, optional
|
|
133
|
+
- None (default) : Try to read the stream by trying differents backends.
|
|
134
|
+
- 'ffmpeg' : Uses the modules ``pip3 install ffmpeg-python``
|
|
135
|
+
which are using the ``ffmpeg`` program in the background.
|
|
136
|
+
- 'cv2' : Uses the module ``pip3 install opencv-contrib-python-headless``.
|
|
137
|
+
interpolate : bool, optional
|
|
138
|
+
If True (default), then the frames whose position is unknown
|
|
139
|
+
are interpolated from the set of correctly dated frames.
|
|
140
|
+
If False, the unconfirmed positions are translated as 'np.nan'.
|
|
141
|
+
|
|
142
|
+
Returns
|
|
143
|
+
-------
|
|
144
|
+
dates : Fraction or None
|
|
145
|
+
The numpy 1d list containing the dates in seconds, encoded in Fraction.
|
|
146
|
+
If a position is unknown and interpolate is set to False, the values None are used.
|
|
147
|
+
|
|
148
|
+
Raises
|
|
149
|
+
------
|
|
150
|
+
MissingStreamError
|
|
151
|
+
If the file does not contain a playable video stream.
|
|
152
|
+
|
|
153
|
+
Examples
|
|
154
|
+
--------
|
|
155
|
+
>>> from cutcutcodec.core.analysis.video.properties.timestamps import get_timestamps_video
|
|
156
|
+
>>> get_timestamps_video("cutcutcodec/examples/video.mp4") # doctest: +ELLIPSIS
|
|
157
|
+
array([Fraction(0, 1), Fraction(1, 25), Fraction(2, 25), Fraction(3, 25),
|
|
158
|
+
Fraction(4, 25), Fraction(1, 5), Fraction(6, 25), Fraction(7, 25),
|
|
159
|
+
Fraction(8, 25), Fraction(9, 25), Fraction(2, 5), Fraction(11, 25),
|
|
160
|
+
...
|
|
161
|
+
Fraction(393, 25), Fraction(394, 25), Fraction(79, 5),
|
|
162
|
+
Fraction(396, 25), Fraction(397, 25), Fraction(398, 25),
|
|
163
|
+
Fraction(399, 25)], dtype=object)
|
|
164
|
+
>>> get_timestamps_video("cutcutcodec/examples/intro.webm") # doctest: +ELLIPSIS
|
|
165
|
+
array([Fraction(0, 1), Fraction(33, 1000), Fraction(67, 1000),
|
|
166
|
+
Fraction(1, 10), Fraction(133, 1000), Fraction(167, 1000),
|
|
167
|
+
Fraction(1, 5), Fraction(117, 500), Fraction(267, 1000),
|
|
168
|
+
...
|
|
169
|
+
Fraction(961, 100), Fraction(9643, 1000), Fraction(2419, 250),
|
|
170
|
+
Fraction(971, 100), Fraction(9743, 1000), Fraction(1222, 125)],
|
|
171
|
+
dtype=object)
|
|
172
|
+
>>>
|
|
173
|
+
"""
|
|
174
|
+
_check_pathexists_index(filename, index)
|
|
175
|
+
assert isinstance(interpolate, bool), interpolate.__class__.__name__
|
|
176
|
+
|
|
177
|
+
timestamps = _mix_and_check(
|
|
178
|
+
backend, True, (str(pathlib.Path(filename)), index),
|
|
179
|
+
collections.OrderedDict([
|
|
180
|
+
(
|
|
181
|
+
(
|
|
182
|
+
lambda filename, index: _decode_timestamps_ffmpeg(
|
|
183
|
+
filename, _map_index_rel_to_abs(filename, index, "video")
|
|
184
|
+
)
|
|
185
|
+
),
|
|
186
|
+
{"accurate": True, "backend": "ffmpeg"},
|
|
187
|
+
),
|
|
188
|
+
(_decode_timestamps_cv2, {"accurate": True, "backend": "cv2"}),
|
|
189
|
+
])
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
if interpolate and None in timestamps:
|
|
193
|
+
return _interpolate(timestamps)
|
|
194
|
+
return timestamps
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the entry and exit points of the assembly graph."""
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
from cutcutcodec.core.classes.node import Node
|
|
8
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ContainerInput(Node):
|
|
12
|
+
"""Entry point of an assembly graph."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, out_streams: typing.Iterable[Stream]):
|
|
15
|
+
super().__init__((), out_streams)
|
|
16
|
+
assert len(self.out_streams) != 0, "at least one flow must leave in the input container"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ContainerOutput(Node):
|
|
20
|
+
"""Coming back point of an assembly graph."""
|
|
21
|
+
|
|
22
|
+
def __init__(self, in_streams: typing.Iterable[Stream]):
|
|
23
|
+
super().__init__(in_streams, ())
|
|
24
|
+
assert len(self.in_streams) != 0, "at least one flow must arrive in the output container"
|
|
25
|
+
|
|
26
|
+
def _getstate(self) -> dict:
|
|
27
|
+
return {}
|
|
28
|
+
|
|
29
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
30
|
+
assert state == {}, state
|
|
31
|
+
ContainerOutput.__init__(self, in_streams)
|
|
32
|
+
|
|
33
|
+
@classmethod
|
|
34
|
+
def default(cls):
|
|
35
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
36
|
+
raise NotImplementedError
|
|
37
|
+
|
|
38
|
+
def write(self):
|
|
39
|
+
"""Run the complete assembly graph and exploite the last streams."""
|
|
40
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""The codecs and encoders."""
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
|
|
7
|
+
import av
|
|
8
|
+
|
|
9
|
+
from cutcutcodec.core.opti.cache.singleton import MetaSingleton
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AllEncoders(metaclass=MetaSingleton):
|
|
13
|
+
"""Equivalent to parse ``ffmpeg -codecs`` and ``ffmpeg -encoders`` but use av insted.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
audio : frozenset[str]
|
|
18
|
+
All the referenced audio encoders (readonly).
|
|
19
|
+
set : frozenset[str]
|
|
20
|
+
All the referenced encoders (readonly).
|
|
21
|
+
subtitle : frozenset[str]
|
|
22
|
+
All the referenced subtitle encoders (readonly).
|
|
23
|
+
video : frozenset[str]
|
|
24
|
+
All the referenced video encoders (readonly).
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self):
|
|
28
|
+
self._encoders = set()
|
|
29
|
+
for encodec in av.codec.codecs_available:
|
|
30
|
+
if encodec in {
|
|
31
|
+
"anull", # empty audio
|
|
32
|
+
"msrle", # old on microsoft windows only, segfault on linux
|
|
33
|
+
"rle", # alias to 'msrle'
|
|
34
|
+
"smc", # old on microsoft windows only, segfault on linux
|
|
35
|
+
"vnull", # empty video
|
|
36
|
+
}:
|
|
37
|
+
continue
|
|
38
|
+
try:
|
|
39
|
+
encoder = av.codec.Codec(encodec, "w").name
|
|
40
|
+
except av.codec.codec.UnknownCodecError:
|
|
41
|
+
continue
|
|
42
|
+
self._encoders.add(encoder)
|
|
43
|
+
|
|
44
|
+
def _select(self, encoder_type: str) -> frozenset[str]:
|
|
45
|
+
"""Select the encoders of a specific type.
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
encoder_type : str
|
|
50
|
+
The codec type ``audio``, ``video`` or ``subtitle``.
|
|
51
|
+
|
|
52
|
+
Returns
|
|
53
|
+
-------
|
|
54
|
+
encoders : frozenset[str]
|
|
55
|
+
All the encoders of the provide type.
|
|
56
|
+
"""
|
|
57
|
+
assert isinstance(encoder_type, str), encoder_type.__class__.__name__
|
|
58
|
+
assert encoder_type in {"audio", "video", "subtitle"}, encoder_type
|
|
59
|
+
return frozenset(e for e in self._encoders if av.codec.Codec(e, "w").type == encoder_type)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def audio(self) -> frozenset[str]:
|
|
63
|
+
"""All the referenced audio encoders.
|
|
64
|
+
|
|
65
|
+
Examples
|
|
66
|
+
--------
|
|
67
|
+
>>> from cutcutcodec.core.classes.encoder import AllEncoders
|
|
68
|
+
>>> sorted(AllEncoders().audio) # doctest: +ELLIPSIS
|
|
69
|
+
['aac', 'ac3', ..., 'wmav1', 'wmav2']
|
|
70
|
+
>>>
|
|
71
|
+
"""
|
|
72
|
+
return self._select("audio")
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def set(self) -> frozenset[str]:
|
|
76
|
+
"""All the referenced encoders."""
|
|
77
|
+
return self._encoders
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def subtitle(self) -> frozenset[str]:
|
|
81
|
+
"""All the referenced subtitle encoders.
|
|
82
|
+
|
|
83
|
+
Examples
|
|
84
|
+
--------
|
|
85
|
+
>>> from cutcutcodec.core.classes.encoder import AllEncoders
|
|
86
|
+
>>> sorted(AllEncoders().subtitle) # doctest: +ELLIPSIS
|
|
87
|
+
['ass', 'dvbsub', ..., 'webvtt', 'xsub']
|
|
88
|
+
>>>
|
|
89
|
+
"""
|
|
90
|
+
return self._select("subtitle")
|
|
91
|
+
|
|
92
|
+
@property
|
|
93
|
+
def video(self) -> frozenset[str]:
|
|
94
|
+
"""All the referenced video encoders.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
>>> from cutcutcodec.core.classes.encoder import AllEncoders
|
|
99
|
+
>>> sorted(AllEncoders().video) # doctest: +ELLIPSIS
|
|
100
|
+
['a64multi', 'a64multi5', ..., 'zlib', 'zmbv']
|
|
101
|
+
>>>
|
|
102
|
+
"""
|
|
103
|
+
return self._select("video")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class Encoder(av.codec.Codec):
|
|
107
|
+
"""A specific encoder.
|
|
108
|
+
|
|
109
|
+
Attributes
|
|
110
|
+
----------
|
|
111
|
+
doc : str
|
|
112
|
+
The documentation of the encoder (readonly).
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
def __new__(cls, name: str):
|
|
116
|
+
"""Initialise and create the class.
|
|
117
|
+
|
|
118
|
+
Parameters
|
|
119
|
+
----------
|
|
120
|
+
name : str
|
|
121
|
+
The name of the encoder.
|
|
122
|
+
"""
|
|
123
|
+
assert isinstance(name, str), name.__class__.__name__
|
|
124
|
+
assert name in AllEncoders().set, f"{name} encoder is not in {AllEncoders().set}"
|
|
125
|
+
encoder = super().__new__(cls, name, "w")
|
|
126
|
+
return encoder
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def doc(self) -> str:
|
|
130
|
+
"""Return the documentation of the encoder.
|
|
131
|
+
|
|
132
|
+
Based on ffmpeg, it parse ``ffmpeg -h encoder=...``.
|
|
133
|
+
|
|
134
|
+
Examples
|
|
135
|
+
--------
|
|
136
|
+
>>> from cutcutcodec.core.classes.encoder import Encoder
|
|
137
|
+
>>> print(Encoder("opus").doc) # doctest: +ELLIPSIS
|
|
138
|
+
Encoder opus [Opus]:
|
|
139
|
+
...
|
|
140
|
+
Threading capabilities: none
|
|
141
|
+
Supported sample rates: 48000
|
|
142
|
+
Supported sample formats: fltp
|
|
143
|
+
Supported channel layouts: mono stereo
|
|
144
|
+
Opus encoder AVOptions:
|
|
145
|
+
...
|
|
146
|
+
>>>
|
|
147
|
+
"""
|
|
148
|
+
doc = subprocess.run(
|
|
149
|
+
["ffmpeg", "-v", "error", "-h", f"encoder={self.name}"],
|
|
150
|
+
capture_output=True, check=True,
|
|
151
|
+
).stdout.decode().strip()
|
|
152
|
+
return doc
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""It's a node that acts on streams."""
|
|
4
|
+
|
|
5
|
+
import typing
|
|
6
|
+
|
|
7
|
+
from cutcutcodec.core.classes.container import ContainerInput, ContainerOutput
|
|
8
|
+
from cutcutcodec.core.classes.node import Node
|
|
9
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Filter(Node):
|
|
13
|
+
"""Filter that applies to several streams.
|
|
14
|
+
|
|
15
|
+
A filter can be empty, i.e. have no input and no output streams.
|
|
16
|
+
On the other hand, it cannot have an input stream but no output stream,
|
|
17
|
+
or an output stream but no input stream.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(
|
|
21
|
+
self,
|
|
22
|
+
in_streams: typing.Union[list[Stream], tuple[Stream]],
|
|
23
|
+
out_streams: typing.Union[list[Stream], tuple[Stream]],
|
|
24
|
+
):
|
|
25
|
+
Node.__init__(self, in_streams, out_streams)
|
|
26
|
+
assert (
|
|
27
|
+
len(self.in_streams) != 0 or len(self.out_streams) == 0
|
|
28
|
+
or isinstance(self, ContainerInput)
|
|
29
|
+
), "an effect with no input flow, must have no output flow"
|
|
30
|
+
assert (
|
|
31
|
+
len(self.in_streams) == 0 or len(self.out_streams) != 0
|
|
32
|
+
or isinstance(self, ContainerOutput)
|
|
33
|
+
), "an effect with at least one input stream, must have at least one output stream"
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure of a base frame, inerit from torch array."""
|
|
4
|
+
|
|
5
|
+
import abc
|
|
6
|
+
import logging
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
import torch
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Frame(torch.Tensor):
|
|
14
|
+
"""A General Frame.
|
|
15
|
+
|
|
16
|
+
Attributes
|
|
17
|
+
----------
|
|
18
|
+
context : object
|
|
19
|
+
Any information to throw during the transformations.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
def __new__(
|
|
23
|
+
cls,
|
|
24
|
+
data: typing.Union[torch.Tensor, np.ndarray, typing.Container],
|
|
25
|
+
context: object = None,
|
|
26
|
+
**kwargs,
|
|
27
|
+
):
|
|
28
|
+
"""Initialise and create the class.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
context : object
|
|
33
|
+
Any value to throw between the tensor operations.
|
|
34
|
+
data : arraylike
|
|
35
|
+
The data to use for this array. Do not copy if it is possible
|
|
36
|
+
**kwargs : dict
|
|
37
|
+
Transmitted to the `torch.Tensor` initialisator.
|
|
38
|
+
"""
|
|
39
|
+
if isinstance(data, torch.Tensor):
|
|
40
|
+
frame = super().__new__(cls, data, **kwargs) # no copy
|
|
41
|
+
frame.context = context
|
|
42
|
+
return frame
|
|
43
|
+
if isinstance(data, np.ndarray):
|
|
44
|
+
return Frame.__new__(cls, torch.from_numpy(data), context=context, **kwargs) # no copy
|
|
45
|
+
logging.warning("please only intitialize a frame from a torch tensor or a numpy ndarray")
|
|
46
|
+
return Frame.__new__(cls, torch.tensor(data), context=context, **kwargs) # copy
|
|
47
|
+
|
|
48
|
+
def __repr__(self):
|
|
49
|
+
"""Allow to add context to the display.
|
|
50
|
+
|
|
51
|
+
Examples
|
|
52
|
+
--------
|
|
53
|
+
>>> from cutcutcodec.core.classes.frame import Frame
|
|
54
|
+
>>> Frame([0.0, 1.0, 2.0], context="context_value")
|
|
55
|
+
Frame([0., 1., 2.], context='context_value')
|
|
56
|
+
>>>
|
|
57
|
+
"""
|
|
58
|
+
base = super().__repr__()
|
|
59
|
+
return f"{base[:-1]}, context={repr(self.context)})"
|
|
60
|
+
|
|
61
|
+
@classmethod
|
|
62
|
+
def __torch_function__(cls, func, types, args=(), kwargs=None):
|
|
63
|
+
"""Enable to throw `context` into the new generations.
|
|
64
|
+
|
|
65
|
+
Examples
|
|
66
|
+
--------
|
|
67
|
+
>>> import torch
|
|
68
|
+
>>> from cutcutcodec.core.classes.frame import Frame
|
|
69
|
+
>>> class Frame_(Frame):
|
|
70
|
+
... def check_state(self):
|
|
71
|
+
... assert self.item() # just for the example
|
|
72
|
+
...
|
|
73
|
+
>>>
|
|
74
|
+
>>> # transmission context
|
|
75
|
+
>>> (frame := Frame_([.5], context="context_value"))
|
|
76
|
+
Frame_([0.5000], context='context_value')
|
|
77
|
+
>>> frame.clone() # deep copy
|
|
78
|
+
Frame_([0.5000], context='context_value')
|
|
79
|
+
>>> torch.sin(frame) # external call
|
|
80
|
+
Frame_([0.4794], context='context_value')
|
|
81
|
+
>>> frame / 2 # internal method
|
|
82
|
+
Frame_([0.2500], context='context_value')
|
|
83
|
+
>>> frame.numpy() # cast in an other type
|
|
84
|
+
array([0.5], dtype=float32)
|
|
85
|
+
>>> frame *= 2 # inplace
|
|
86
|
+
>>> frame
|
|
87
|
+
Frame_([1.], context='context_value')
|
|
88
|
+
>>>
|
|
89
|
+
>>> # cast if state not correct
|
|
90
|
+
>>> torch.concatenate([frame, frame], axis=0) #
|
|
91
|
+
tensor([1., 1.])
|
|
92
|
+
>>> frame * 0 # no correct because has to be != 0
|
|
93
|
+
tensor([0.])
|
|
94
|
+
>>> frame *= 0
|
|
95
|
+
>>> frame
|
|
96
|
+
tensor([0.])
|
|
97
|
+
>>>
|
|
98
|
+
"""
|
|
99
|
+
if kwargs is None:
|
|
100
|
+
kwargs = {}
|
|
101
|
+
result = super().__torch_function__(func, types, args, kwargs)
|
|
102
|
+
if isinstance(result, cls):
|
|
103
|
+
if isinstance(args[0], cls): # args[0] is self
|
|
104
|
+
result.context = args[0].context # args[0] is self
|
|
105
|
+
try:
|
|
106
|
+
result.check_state()
|
|
107
|
+
except AssertionError:
|
|
108
|
+
return torch.Tensor(result)
|
|
109
|
+
else:
|
|
110
|
+
return torch.Tensor(result)
|
|
111
|
+
return result
|
|
112
|
+
|
|
113
|
+
@abc.abstractmethod
|
|
114
|
+
def check_state(self) -> None:
|
|
115
|
+
"""Apply verifications.
|
|
116
|
+
|
|
117
|
+
Raises
|
|
118
|
+
------
|
|
119
|
+
AssertionError
|
|
120
|
+
If something wrong in this frame.
|
|
121
|
+
"""
|
|
122
|
+
raise NotImplementedError
|
|
123
|
+
|
|
124
|
+
@property
|
|
125
|
+
def shape(self) -> tuple[int, ...]:
|
|
126
|
+
"""Solve pylint error E1136: Value 'self.shape' is unsubscriptable."""
|
|
127
|
+
return tuple(super().shape)
|