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,331 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to combine overlapping streams."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import typing
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
12
|
+
from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
13
|
+
from cutcutcodec.core.classes.node import Node
|
|
14
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
15
|
+
from cutcutcodec.core.classes.stream_video import StreamVideo
|
|
16
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
17
|
+
from cutcutcodec.core.filters.mix.video_cast import to_bgr, to_bgr_alpha
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class FilterVideoAdd(Filter):
|
|
21
|
+
"""Combine the stream in once by additing the overlapping slices.
|
|
22
|
+
|
|
23
|
+
Examples
|
|
24
|
+
--------
|
|
25
|
+
>>> from cutcutcodec.core.filters.video.add import FilterVideoAdd
|
|
26
|
+
>>> from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
27
|
+
>>> from cutcutcodec.core.generation.video.equation import GeneratorVideoEquation
|
|
28
|
+
>>>
|
|
29
|
+
>>> (s_video_0,) = GeneratorVideoEquation("i", "1/2").out_streams
|
|
30
|
+
>>> (s_video_1,) = FilterVideoDelay(
|
|
31
|
+
... GeneratorVideoEquation("j", "1/2").out_streams, 10
|
|
32
|
+
... ).out_streams
|
|
33
|
+
>>> (s_add_video,) = FilterVideoAdd([s_video_0, s_video_1]).out_streams
|
|
34
|
+
>>>
|
|
35
|
+
>>> s_video_0.snapshot(10, (2, 2))
|
|
36
|
+
FrameVideo(10, [[[ 0, 128],
|
|
37
|
+
[ 0, 128]],
|
|
38
|
+
<BLANKLINE>
|
|
39
|
+
[[255, 128],
|
|
40
|
+
[255, 128]]])
|
|
41
|
+
>>> s_video_1.snapshot(10, (2, 2))
|
|
42
|
+
FrameVideo(10, [[[ 0, 128],
|
|
43
|
+
[255, 128]],
|
|
44
|
+
<BLANKLINE>
|
|
45
|
+
[[ 0, 128],
|
|
46
|
+
[255, 128]]])
|
|
47
|
+
>>> s_add_video.snapshot(10, (2, 2))
|
|
48
|
+
FrameVideo(10, [[[ 0, 191],
|
|
49
|
+
[ 85, 191]],
|
|
50
|
+
<BLANKLINE>
|
|
51
|
+
[[170, 191],
|
|
52
|
+
[255, 191]]])
|
|
53
|
+
>>>
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def __init__(self, in_streams: typing.Iterable[Stream]):
|
|
57
|
+
"""Initialise and create the class.
|
|
58
|
+
|
|
59
|
+
Parameters
|
|
60
|
+
----------
|
|
61
|
+
in_streams : typing.Iterable[Stream]
|
|
62
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
63
|
+
About the overlaping portions, if the stream is an audio stream,
|
|
64
|
+
a simple addition is performed but if the stream is a video stream,
|
|
65
|
+
the frames are combined like a superposition of semi-transparent windows.
|
|
66
|
+
"""
|
|
67
|
+
super().__init__(in_streams, in_streams)
|
|
68
|
+
if not self.in_streams:
|
|
69
|
+
return
|
|
70
|
+
super().__init__(self.in_streams, [_StreamVideoAdd(self)])
|
|
71
|
+
|
|
72
|
+
def _getstate(self) -> dict:
|
|
73
|
+
return {}
|
|
74
|
+
|
|
75
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
76
|
+
assert state == {}
|
|
77
|
+
FilterVideoAdd.__init__(self, in_streams)
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def default(cls):
|
|
81
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
82
|
+
return cls([])
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class _StreamVideoAdd(StreamVideo):
|
|
86
|
+
"""Concatenate and mix the video streams."""
|
|
87
|
+
|
|
88
|
+
def __init__(self, node: Node):
|
|
89
|
+
"""Initialise and create the class.
|
|
90
|
+
|
|
91
|
+
Parameters
|
|
92
|
+
----------
|
|
93
|
+
node : cutcutcodec.core.filters.video.add.FilterVideoAdd
|
|
94
|
+
The node containing the StreamVideo to mix.
|
|
95
|
+
"""
|
|
96
|
+
assert isinstance(node, FilterVideoAdd), node.__class__.__name__
|
|
97
|
+
assert node.in_streams, "requires at least 1 video stream to add"
|
|
98
|
+
super().__init__(node)
|
|
99
|
+
|
|
100
|
+
@staticmethod
|
|
101
|
+
def _add_2_with_1(ref: torch.Tensor, other: torch.Tensor) -> torch.Tensor:
|
|
102
|
+
"""Add a gray frame (``other``) to the gray alpha reference frame (``ref``).
|
|
103
|
+
|
|
104
|
+
No verifications are performed for performance reason.
|
|
105
|
+
``other`` remains unchanged but ``ref`` is changed inplace.
|
|
106
|
+
|
|
107
|
+
alpha final = 1
|
|
108
|
+
color final = c_r*a_r + c_o*(1-a_r)
|
|
109
|
+
|
|
110
|
+
Examples
|
|
111
|
+
--------
|
|
112
|
+
>>> import torch
|
|
113
|
+
>>> from cutcutcodec.core.filters.video.add import _StreamVideoAdd
|
|
114
|
+
>>> ref = torch.empty(3, 3, 2, dtype=torch.float32) # 3x3 gray alpha
|
|
115
|
+
>>> ref[..., 1] = torch.tensor([0.0, 0.5, 1.0]) # set alpha transparent to blind
|
|
116
|
+
>>> ref[..., 1]
|
|
117
|
+
tensor([[0.0000, 0.5000, 1.0000],
|
|
118
|
+
[0.0000, 0.5000, 1.0000],
|
|
119
|
+
[0.0000, 0.5000, 1.0000]])
|
|
120
|
+
>>> ref[..., 0] = torch.tensor([[0.0], [0.5], [1.0]]) # set different gray scale
|
|
121
|
+
>>> ref[..., 0]
|
|
122
|
+
tensor([[0.0000, 0.0000, 0.0000],
|
|
123
|
+
[0.5000, 0.5000, 0.5000],
|
|
124
|
+
[1.0000, 1.0000, 1.0000]])
|
|
125
|
+
>>> other_black = torch.full((3, 3, 1), 0.0, dtype=torch.float32)
|
|
126
|
+
>>> other_gray = torch.full((3, 3, 1), 0.5, dtype=torch.float32)
|
|
127
|
+
>>> other_white = torch.full((3, 3, 1), 1.0, dtype=torch.float32)
|
|
128
|
+
>>>
|
|
129
|
+
>>> _StreamVideoAdd._add_2_with_1(ref.clone(), other_black)[..., 0]
|
|
130
|
+
tensor([[0.0000, 0.0000, 0.0000],
|
|
131
|
+
[0.0000, 0.2500, 0.5000],
|
|
132
|
+
[0.0000, 0.5000, 1.0000]])
|
|
133
|
+
>>> _StreamVideoAdd._add_2_with_1(ref.clone(), other_gray)[..., 0]
|
|
134
|
+
tensor([[0.5000, 0.2500, 0.0000],
|
|
135
|
+
[0.5000, 0.5000, 0.5000],
|
|
136
|
+
[0.5000, 0.7500, 1.0000]])
|
|
137
|
+
>>> _StreamVideoAdd._add_2_with_1(ref.clone(), other_white)[..., 0]
|
|
138
|
+
tensor([[1.0000, 0.5000, 0.0000],
|
|
139
|
+
[1.0000, 0.7500, 0.5000],
|
|
140
|
+
[1.0000, 1.0000, 1.0000]])
|
|
141
|
+
>>>
|
|
142
|
+
"""
|
|
143
|
+
a_r = ref[..., 1] # a_r
|
|
144
|
+
color = ref[..., 0] # c_r
|
|
145
|
+
c_o = other[..., 0] # c_o
|
|
146
|
+
color -= c_o # c_r - c_o
|
|
147
|
+
color *= a_r # a_r * (c_r-c_o)
|
|
148
|
+
color += c_o # a_r * (c_r - c_o) + c_o = c_r*a_r + c_o*(1-a_r)
|
|
149
|
+
color = torch.unsqueeze(color, 2) # shape (height, width, 1)
|
|
150
|
+
return color
|
|
151
|
+
|
|
152
|
+
@staticmethod
|
|
153
|
+
def _add_2_with_2(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
154
|
+
"""Add a gray alpha frame (``other``) to the gray alpha reference frame (``ref``).
|
|
155
|
+
|
|
156
|
+
No verifications are performed for performance reason.
|
|
157
|
+
``other`` remains unchanged but ``ref`` is changed inplace.
|
|
158
|
+
Returns a pointer of ``ref``.
|
|
159
|
+
|
|
160
|
+
alpha final = 1 - (1-a_r)*(1-a_o)
|
|
161
|
+
color final = (c_r*a_r + c_o*a_o*(1-a_r)) / (a_r+a_o-a_r*a_o)
|
|
162
|
+
|
|
163
|
+
Examples
|
|
164
|
+
--------
|
|
165
|
+
>>> import torch
|
|
166
|
+
>>> from cutcutcodec.core.filters.video.add import _StreamVideoAdd
|
|
167
|
+
>>> ref = torch.empty(3, 3, 2, dtype=torch.float32) # 3x3 gray alpha
|
|
168
|
+
>>> ref[..., 1] = torch.tensor([0.0, 0.5, 1.0]) # set alpha transparent to blind
|
|
169
|
+
>>> ref[..., 1] # a_r
|
|
170
|
+
tensor([[0.0000, 0.5000, 1.0000],
|
|
171
|
+
[0.0000, 0.5000, 1.0000],
|
|
172
|
+
[0.0000, 0.5000, 1.0000]])
|
|
173
|
+
>>> ref[..., 0] = torch.tensor([[0.0], [0.5], [1.0]]) # set different gray scale
|
|
174
|
+
>>> ref[..., 0] # c_r and a_o
|
|
175
|
+
tensor([[0.0000, 0.0000, 0.0000],
|
|
176
|
+
[0.5000, 0.5000, 0.5000],
|
|
177
|
+
[1.0000, 1.0000, 1.0000]])
|
|
178
|
+
>>> other_black = torch.full((3, 3, 2), 0.0, dtype=torch.float32)
|
|
179
|
+
>>> other_black[..., 1] = torch.tensor([[0.0], [0.5], [1.0]]) # alpha transparent to blind
|
|
180
|
+
>>> other_gray = torch.full((3, 3, 2), 0.5, dtype=torch.float32)
|
|
181
|
+
>>> other_gray[..., 1] = torch.tensor([[0.0], [0.5], [1.0]])
|
|
182
|
+
>>> other_white = torch.full((3, 3, 2), 1.0, dtype=torch.float32)
|
|
183
|
+
>>> other_white[..., 1] = torch.tensor([[0.0], [0.5], [1.0]])
|
|
184
|
+
>>>
|
|
185
|
+
>>> _StreamVideoAdd._add_2_with_2(ref.clone(), other_black)[..., 1] # alpha
|
|
186
|
+
tensor([[0.0000, 0.5000, 1.0000],
|
|
187
|
+
[0.5000, 0.7500, 1.0000],
|
|
188
|
+
[1.0000, 1.0000, 1.0000]])
|
|
189
|
+
>>> _StreamVideoAdd._add_2_with_2(ref.clone(), other_black)[..., 0] # doctest: +ELLIPSIS
|
|
190
|
+
tensor([[ ..., 0.0000, 0.0000],
|
|
191
|
+
[0.0000, 0.3333, 0.5000],
|
|
192
|
+
[0.0000, 0.5000, 1.0000]])
|
|
193
|
+
>>> _StreamVideoAdd._add_2_with_2(ref.clone(), other_gray)[..., 0] # doctest: +ELLIPSIS
|
|
194
|
+
tensor([[ ..., 0.0000, 0.0000],
|
|
195
|
+
[0.5000, 0.5000, 0.5000],
|
|
196
|
+
[0.5000, 0.7500, 1.0000]])
|
|
197
|
+
>>> _StreamVideoAdd._add_2_with_2(ref.clone(), other_white)[..., 0] # doctest: +ELLIPSIS
|
|
198
|
+
tensor([[ ..., 0.0000, 0.0000],
|
|
199
|
+
[1.0000, 0.6667, 0.5000],
|
|
200
|
+
[1.0000, 1.0000, 1.0000]])
|
|
201
|
+
>>>
|
|
202
|
+
"""
|
|
203
|
+
a_r = ref[..., 1] # a_r
|
|
204
|
+
a_o = other[..., 1] # a_o
|
|
205
|
+
c_r = ref[..., 0] # c_r
|
|
206
|
+
c_o = other[..., 0] # c_r
|
|
207
|
+
|
|
208
|
+
alpha = a_r * a_o # a_r*a_o
|
|
209
|
+
alpha = torch.neg(alpha, out=alpha) # -a_r*a_o
|
|
210
|
+
alpha += a_o # a_o - a_r*a_o = a_o * (1-a_r)
|
|
211
|
+
color = c_o * alpha # c_o * a_o * (1-a_r)
|
|
212
|
+
color += c_r * a_r # (c_r * a_r) + (c_o * a_o * (1-a_r))
|
|
213
|
+
alpha += a_r # a_r + a_o - a_r*a_o
|
|
214
|
+
color /= alpha # (c_r*a_r+c_o*a_o*(1-a_r)) / (a_r+a_o-a_r*a_o)
|
|
215
|
+
|
|
216
|
+
ref[..., 0] = color
|
|
217
|
+
ref[..., 1] = alpha
|
|
218
|
+
return ref
|
|
219
|
+
|
|
220
|
+
@staticmethod
|
|
221
|
+
def _add_2_with_3(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
222
|
+
"""Pseudo alias to ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_4_with_3``."""
|
|
223
|
+
return _StreamVideoAdd._add_4_with_3(to_bgr_alpha(ref), other)
|
|
224
|
+
|
|
225
|
+
@staticmethod
|
|
226
|
+
def _add_2_with_4(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
227
|
+
"""Pseudo alias to ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_4_with_4``."""
|
|
228
|
+
return _StreamVideoAdd._add_4_with_4(to_bgr_alpha(ref), other)
|
|
229
|
+
|
|
230
|
+
@staticmethod
|
|
231
|
+
def _add_4_with_1(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
232
|
+
"""Pseudo alias to ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_4_with_3``."""
|
|
233
|
+
return _StreamVideoAdd._add_4_with_3(ref, to_bgr(other))
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
def _add_4_with_2(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
237
|
+
"""Pseudo alias to ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_4_with_4``."""
|
|
238
|
+
return _StreamVideoAdd._add_4_with_3(ref, to_bgr(other))
|
|
239
|
+
|
|
240
|
+
@staticmethod
|
|
241
|
+
def _add_4_with_3(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
242
|
+
"""Add a bgr frame to the bgr alpha frame_ref.
|
|
243
|
+
|
|
244
|
+
Like ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_2_with_1`` with 3 channels.
|
|
245
|
+
"""
|
|
246
|
+
a_r = ref[..., 3] # a_r
|
|
247
|
+
a_r = torch.unsqueeze(a_r, 2)
|
|
248
|
+
color = ref[..., :3] # c_r
|
|
249
|
+
c_o = other[..., :3] # c_o
|
|
250
|
+
color -= c_o # c_r - c_o
|
|
251
|
+
color *= a_r # a_r * (c_r-c_o)
|
|
252
|
+
color += c_o # a_r * (c_r - c_o) + c_o = c_r*a_r + c_o*(1-a_r)
|
|
253
|
+
return color
|
|
254
|
+
|
|
255
|
+
@staticmethod
|
|
256
|
+
def _add_4_with_4(ref: FrameVideo, other: FrameVideo) -> FrameVideo:
|
|
257
|
+
"""Add a bgr alpha frame to the bgr alpha frame_ref.
|
|
258
|
+
|
|
259
|
+
Like ``cutcutcodec.core.filters.video.add._StreamVideoAdd._add_2_with_2`` with 4 channels.
|
|
260
|
+
"""
|
|
261
|
+
a_r = ref[..., 3] # a_r
|
|
262
|
+
a_r = torch.unsqueeze(a_r, 2)
|
|
263
|
+
a_o = other[..., 3] # o_r
|
|
264
|
+
a_o = torch.unsqueeze(a_o, 2)
|
|
265
|
+
c_r = ref[..., :3] # c_r
|
|
266
|
+
c_o = other[..., :3] # c_o
|
|
267
|
+
|
|
268
|
+
alpha = a_r * a_o # a_r*a_o
|
|
269
|
+
alpha = torch.neg(alpha, out=alpha) # -a_r*a_o
|
|
270
|
+
alpha += a_o # a_o - a_r*a_o = a_o * (1-a_r)
|
|
271
|
+
color = c_o * alpha # c_o * a_o * (1-a_r)
|
|
272
|
+
color += c_r * a_r # (c_r * a_r) + (c_o * a_o * (1-a_r))
|
|
273
|
+
alpha += a_r # a_r + a_o - a_r*a_o
|
|
274
|
+
color /= alpha # (c_r*a_r+c_o*a_o*(1-a_r)) / (a_r+a_o-a_r*a_o)
|
|
275
|
+
|
|
276
|
+
ref[..., :3] = color
|
|
277
|
+
ref[..., 3] = torch.squeeze(alpha, 2)
|
|
278
|
+
return ref
|
|
279
|
+
|
|
280
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
281
|
+
# selection of the concerned streams
|
|
282
|
+
if not (
|
|
283
|
+
streams := [
|
|
284
|
+
s for s in self.node.in_streams if s.beginning <= timestamp < s.beginning+s.duration
|
|
285
|
+
]
|
|
286
|
+
):
|
|
287
|
+
if timestamp < self.beginning or timestamp >= self.beginning + self.duration:
|
|
288
|
+
raise OutOfTimeRange(
|
|
289
|
+
f"stream start {self.beginning} and end {self.beginning + self.duration}, "
|
|
290
|
+
f"no stream at timestamp {timestamp}"
|
|
291
|
+
)
|
|
292
|
+
return FrameVideo(
|
|
293
|
+
timestamp, torch.zeros((*mask.shape, 2), dtype=torch.uint8)
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
# general combinaison of the frames
|
|
297
|
+
frame_ref = self._frame_to_float(streams.pop(0)._snapshot(timestamp, mask))
|
|
298
|
+
for stream in streams:
|
|
299
|
+
# verif for avoid useless computing
|
|
300
|
+
if frame_ref.shape[2] in {1, 3}: # if no alpha channel
|
|
301
|
+
return frame_ref
|
|
302
|
+
if np.ma.allequal(frame_ref.numpy(force=True), 255):
|
|
303
|
+
return frame_ref.convert(frame_ref.shape[2]-1)
|
|
304
|
+
# combination
|
|
305
|
+
other = self._frame_to_float(stream._snapshot(timestamp, mask))
|
|
306
|
+
func_add = getattr(_StreamVideoAdd, f"_add_{frame_ref.shape[2]}_with_{other.shape[2]}")
|
|
307
|
+
frame_ref = func_add(frame_ref, other)
|
|
308
|
+
return frame_ref
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def beginning(self) -> Fraction:
|
|
312
|
+
return min(s.beginning for s in self.node.in_streams)
|
|
313
|
+
|
|
314
|
+
@property
|
|
315
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
316
|
+
end = max(s.beginning + s.duration for s in self.node.in_streams)
|
|
317
|
+
return end - self.beginning
|
|
318
|
+
|
|
319
|
+
@property
|
|
320
|
+
def is_space_continuous(self) -> bool:
|
|
321
|
+
"""Return True if the data is continuous in the spacial domain, False if it is discrete."""
|
|
322
|
+
if len(val := {s.is_space_continuous for s in self.node.in_streams}) != 1:
|
|
323
|
+
raise AttributeError("combined streams are both space continuous and discrete")
|
|
324
|
+
return val.pop()
|
|
325
|
+
|
|
326
|
+
@property
|
|
327
|
+
def is_time_continuous(self) -> bool:
|
|
328
|
+
"""Return True if the data is continuous in the time domain, False if it is discrete."""
|
|
329
|
+
if len(val := {s.is_time_continuous for s in self.node.in_streams}) != 1:
|
|
330
|
+
raise AttributeError("combined streams are both time continuous and discrete")
|
|
331
|
+
return val.pop()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to temporarily concatenate several video streams."""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import math
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
from cutcutcodec.core.classes.meta_filter import MetaFilter
|
|
10
|
+
from cutcutcodec.core.classes.node import Node
|
|
11
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
12
|
+
from cutcutcodec.core.filters.video.add import FilterVideoAdd
|
|
13
|
+
from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FilterVideoCat(MetaFilter):
|
|
17
|
+
"""Concatenate the streams end-to-end.
|
|
18
|
+
|
|
19
|
+
Examples
|
|
20
|
+
--------
|
|
21
|
+
>>> import torch
|
|
22
|
+
>>> from cutcutcodec.core.filters.video.cat import FilterVideoCat
|
|
23
|
+
>>> from cutcutcodec.core.filters.video.subclip import FilterVideoSubclip
|
|
24
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
25
|
+
>>>
|
|
26
|
+
>>> (s_video_0,) = FilterVideoSubclip(GeneratorVideoNoise(0).out_streams, 0, 10).out_streams
|
|
27
|
+
>>> (s_video_1,) = GeneratorVideoNoise(.5).out_streams
|
|
28
|
+
>>> (s_chain_video,) = FilterVideoCat([s_video_0, s_video_1]).out_streams
|
|
29
|
+
>>>
|
|
30
|
+
>>> (s_video_0.snapshot(0, (2, 2)) == s_chain_video.snapshot(0, (2, 2))).all()
|
|
31
|
+
tensor(True)
|
|
32
|
+
>>> (s_video_1.snapshot(0, (2, 2)) == s_chain_video.snapshot(10, (2, 2))).all()
|
|
33
|
+
tensor(True)
|
|
34
|
+
>>> (s_video_1.snapshot(10, (2, 2)) == s_chain_video.snapshot(20, (2, 2))).all()
|
|
35
|
+
tensor(True)
|
|
36
|
+
>>>
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
def _compile(self, in_streams: tuple[Stream]) -> Node:
|
|
40
|
+
streams = [in_streams[0]] # can not raise IndexError because none empty
|
|
41
|
+
pos = streams[0].beginning + streams[0].duration
|
|
42
|
+
for i, stream in enumerate(in_streams[1:]):
|
|
43
|
+
if pos == math.inf:
|
|
44
|
+
logging.warning("the stream video %i is infinite, can not chain an other after", i)
|
|
45
|
+
break
|
|
46
|
+
streams.append(FilterVideoDelay([stream], pos-stream.beginning).out_streams[0])
|
|
47
|
+
pos += stream.duration
|
|
48
|
+
return FilterVideoAdd(streams)
|
|
49
|
+
|
|
50
|
+
def _getstate(self) -> dict:
|
|
51
|
+
return {}
|
|
52
|
+
|
|
53
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
54
|
+
assert state == {}
|
|
55
|
+
FilterVideoCat.__init__(self, in_streams)
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def default(cls):
|
|
59
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
60
|
+
return cls([])
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Split a stream in several slices."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import numbers
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
12
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
13
|
+
from cutcutcodec.core.classes.stream_video import StreamVideoWrapper
|
|
14
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
15
|
+
from cutcutcodec.core.filters.cut import FilterCut
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class FilterVideoCut(FilterCut, Filter):
|
|
19
|
+
"""Splits the video stream at the given positions.
|
|
20
|
+
|
|
21
|
+
Examples
|
|
22
|
+
--------
|
|
23
|
+
>>> from cutcutcodec.core.filters.video.cut import FilterVideoCut
|
|
24
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
25
|
+
>>>
|
|
26
|
+
>>> (stream_a,) = GeneratorVideoNoise(0).out_streams
|
|
27
|
+
>>> (stream_b,) = GeneratorVideoNoise(0).out_streams
|
|
28
|
+
>>> a_0, b_0, a_1, b_1, a_2, b_2 = FilterVideoCut([stream_a, stream_b], 10, 20).out_streams
|
|
29
|
+
>>>
|
|
30
|
+
>>> a_0.beginning, a_0.duration
|
|
31
|
+
(Fraction(0, 1), Fraction(10, 1))
|
|
32
|
+
>>> a_2.beginning, a_2.duration
|
|
33
|
+
(Fraction(20, 1), inf)
|
|
34
|
+
>>> b_1.beginning, b_1.duration
|
|
35
|
+
(Fraction(10, 1), Fraction(10, 1))
|
|
36
|
+
>>> b_2.beginning, b_2.duration
|
|
37
|
+
(Fraction(20, 1), inf)
|
|
38
|
+
>>>
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
def __init__(self, in_streams: typing.Iterable[Stream], *limits: numbers.Real):
|
|
42
|
+
"""Initialise and create the class.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
in_streams : typing.Iterable[Stream]
|
|
47
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
48
|
+
limits : numbers.Real
|
|
49
|
+
Transmitted to ``cutcutcodec.core.filters.cut.FilterCut.init``.
|
|
50
|
+
"""
|
|
51
|
+
super().__init__(in_streams, in_streams)
|
|
52
|
+
self._limits, out_streams = self.init(in_streams, _StreamVideoCut, *limits)
|
|
53
|
+
super().__init__(in_streams, out_streams)
|
|
54
|
+
|
|
55
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
56
|
+
assert state.keys() == {"limits"}, set(state)
|
|
57
|
+
limits = map(Fraction, state["limits"])
|
|
58
|
+
FilterVideoCut.__init__(self, in_streams, *limits)
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def default(cls):
|
|
62
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
63
|
+
return cls([])
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class _StreamVideoCut(StreamVideoWrapper):
|
|
67
|
+
"""Select a slice of a video stream."""
|
|
68
|
+
|
|
69
|
+
def __init__(
|
|
70
|
+
self,
|
|
71
|
+
node: FilterVideoCut,
|
|
72
|
+
index: numbers.Integral,
|
|
73
|
+
l_min: numbers.Real,
|
|
74
|
+
l_max: numbers.Real,
|
|
75
|
+
):
|
|
76
|
+
"""Initialise and create the class.
|
|
77
|
+
|
|
78
|
+
Parameters
|
|
79
|
+
----------
|
|
80
|
+
node : cutcutcodec.core.classes.node.Node
|
|
81
|
+
The parent node.
|
|
82
|
+
filter : cutcutcodec.core.filters.video.cut.FilterVideoCut
|
|
83
|
+
Transmitted to ``cutcutcodec.core.classes.stream_video.StreamVideoWrapper``.
|
|
84
|
+
index : numbers.Integral
|
|
85
|
+
Transmitted to ``cutcutcodec.core.classes.stream_video.StreamVideoWrapper``.
|
|
86
|
+
l_min : numbers.Real
|
|
87
|
+
The low absolute limit.
|
|
88
|
+
l_max : numbers.Real
|
|
89
|
+
The high absolute limit.
|
|
90
|
+
"""
|
|
91
|
+
assert isinstance(node, FilterVideoCut), node.__class__.__name__
|
|
92
|
+
assert isinstance(l_min, numbers.Real), l_min.__class__.__name__
|
|
93
|
+
assert isinstance(l_max, numbers.Real), l_max.__class__.__name__
|
|
94
|
+
super().__init__(node, index)
|
|
95
|
+
self.l_min, self.l_max = l_min, l_max
|
|
96
|
+
|
|
97
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
98
|
+
if timestamp >= self.l_max or timestamp < self.l_min:
|
|
99
|
+
raise OutOfTimeRange(
|
|
100
|
+
f"the stream has been truncated under "
|
|
101
|
+
f"{self.beginning} and over {self.beginning+self.duration} seconds, "
|
|
102
|
+
f"evaluation at {timestamp} seconds"
|
|
103
|
+
)
|
|
104
|
+
return self.stream._snapshot(timestamp, mask)
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def beginning(self) -> Fraction:
|
|
108
|
+
return max(min(self.l_min, self.l_max), self.stream.beginning)
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
112
|
+
end = min(max(self.l_min, self.l_max), self.stream.beginning+self.stream.duration)
|
|
113
|
+
return end - self.beginning
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to temporarily translate a video sequence."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import numbers
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
import torch
|
|
10
|
+
|
|
11
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
12
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
13
|
+
from cutcutcodec.core.classes.stream_video import StreamVideoWrapper
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FilterVideoDelay(Filter):
|
|
17
|
+
"""Change the beginning time of a stream.
|
|
18
|
+
|
|
19
|
+
Attributes
|
|
20
|
+
----------
|
|
21
|
+
delay : Fraction
|
|
22
|
+
The delay append to the original beginning time of the stream (readonly).
|
|
23
|
+
a positive value indicates that the output flow is later than the input flow.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
28
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
29
|
+
>>>
|
|
30
|
+
>>> (s_base_video,) = GeneratorVideoNoise(0).out_streams
|
|
31
|
+
>>> (s_trans_video,) = FilterVideoDelay([s_base_video], 10).out_streams
|
|
32
|
+
>>>
|
|
33
|
+
>>> (s_base_video.snapshot(0, (1, 1)) == s_trans_video.snapshot(10, (1, 1))).all()
|
|
34
|
+
tensor(True)
|
|
35
|
+
>>> (s_base_video.snapshot(10, (1, 1)) == s_trans_video.snapshot(10, (1, 1))).all()
|
|
36
|
+
tensor(False)
|
|
37
|
+
>>>
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, in_streams: typing.Iterable[Stream], delay: numbers.Real):
|
|
41
|
+
"""Initialise and create the class.
|
|
42
|
+
|
|
43
|
+
Parameters
|
|
44
|
+
----------
|
|
45
|
+
in_streams : typing.Iterable[Stream]
|
|
46
|
+
Transmitted to ``cutcutcodec.core.classes.filter.Filter``.
|
|
47
|
+
delay : numbers.Real
|
|
48
|
+
The temporal translation value to apply at the output video stream.
|
|
49
|
+
"""
|
|
50
|
+
assert isinstance(delay, numbers.Real), delay.__class__.__name__
|
|
51
|
+
|
|
52
|
+
self._delay = Fraction(delay)
|
|
53
|
+
super().__init__(in_streams, in_streams)
|
|
54
|
+
super().__init__(
|
|
55
|
+
in_streams, [_StreamVideoTranslate(self, index) for index in range(len(in_streams))]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def _getstate(self) -> dict:
|
|
59
|
+
return {"delay": str(self.delay)}
|
|
60
|
+
|
|
61
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
62
|
+
assert state.keys() == {"delay"}, set(state)
|
|
63
|
+
FilterVideoDelay.__init__(self, in_streams, Fraction(state["delay"]))
|
|
64
|
+
|
|
65
|
+
@classmethod
|
|
66
|
+
def default(cls):
|
|
67
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
68
|
+
return cls([], 0)
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def delay(self) -> Fraction:
|
|
72
|
+
"""Return the delay append to the original beginning time of the stream."""
|
|
73
|
+
return self._delay
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class _StreamVideoTranslate(StreamVideoWrapper):
|
|
77
|
+
"""Translate a video stream from a certain delay."""
|
|
78
|
+
|
|
79
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
80
|
+
return self.stream._snapshot(timestamp - self.node.delay, mask)
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def beginning(self) -> Fraction:
|
|
84
|
+
return self.stream.beginning + self.node.delay
|