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,182 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure of an abstract multimedia stream."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import abc
|
|
7
|
+
import numbers
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Stream(abc.ABC):
|
|
12
|
+
"""A General multimedia stream.
|
|
13
|
+
|
|
14
|
+
Attributes
|
|
15
|
+
----------
|
|
16
|
+
beginning : Fraction
|
|
17
|
+
The stream beginning instant in second (readonly).
|
|
18
|
+
duration : Fraction or inf
|
|
19
|
+
The duration of the flow in seconds, it can be infinite (readonly).
|
|
20
|
+
This value needs to be accurate.
|
|
21
|
+
index : int
|
|
22
|
+
The absolute stream index from the parent node (0 to n-1) (readonly).
|
|
23
|
+
is_time_continuous : boolean
|
|
24
|
+
True if the data is continuous in the time domain, False if it is discrete (readonly).
|
|
25
|
+
node : cutcutcodec.core.classes.node.Node
|
|
26
|
+
The node where this stream comes from (readonly).
|
|
27
|
+
Allows back propagation in the assembly graph.
|
|
28
|
+
node_main : cutcutcodec.core.classes.node.Node
|
|
29
|
+
The node used for the compilation. This node has the same output_streams
|
|
30
|
+
as ``node`` but not nescessary the same input_streams and te same properties.
|
|
31
|
+
It can be used for factorisation (read and write).
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self, node):
|
|
35
|
+
"""Initialise and create the class.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
node : cutcutcodec.core.classes.node.Node
|
|
40
|
+
The node where this stream comes from.
|
|
41
|
+
The audit must be conducted in the children's classes.
|
|
42
|
+
It is not done here in order to avoid cyclic imports.
|
|
43
|
+
node_main : cutcutcodec.core.classes.node.Node
|
|
44
|
+
In the case this streams comes from ``cutcutcodec.core.filters.meta_filter.MetaFilter``,
|
|
45
|
+
`node_main` is the meta filter while `node` is the subgraph of the meta-filter.
|
|
46
|
+
"""
|
|
47
|
+
self._node = node
|
|
48
|
+
self._node_main = node
|
|
49
|
+
|
|
50
|
+
def __eq__(self, other) -> bool:
|
|
51
|
+
"""2 streams are equivalent if there parent nodes are similar."""
|
|
52
|
+
if self.__class__ != other.__class__:
|
|
53
|
+
return False
|
|
54
|
+
if self.index != other.index:
|
|
55
|
+
return False
|
|
56
|
+
if self.node != other.node:
|
|
57
|
+
return False
|
|
58
|
+
return True
|
|
59
|
+
|
|
60
|
+
def __reduce__(self):
|
|
61
|
+
"""Allow ``pickle`` to serialize efficiently.
|
|
62
|
+
|
|
63
|
+
You can't just use ``__getstate__`` and ``__setstate__``
|
|
64
|
+
because we don't want to duplicate the stream.
|
|
65
|
+
This allows to retrieve the equivalent stream generated in the parent node.
|
|
66
|
+
"""
|
|
67
|
+
return Stream._stream_from_parent_node, (self.node, self.index)
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def _stream_from_parent_node(node, index):
|
|
71
|
+
"""Return the equivalent stream contained in the parent node."""
|
|
72
|
+
return node.out_streams[index]
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
@abc.abstractmethod
|
|
76
|
+
def beginning(self) -> Fraction:
|
|
77
|
+
"""Return the stream beginning instant in second."""
|
|
78
|
+
raise NotImplementedError
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
@abc.abstractmethod
|
|
82
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
83
|
+
"""Return the duration of the flow in seconds, positive fraction or infinite."""
|
|
84
|
+
raise NotImplementedError
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def index(self) -> int:
|
|
88
|
+
"""Return the stream index from the parent node (0 to n-1)."""
|
|
89
|
+
return self._node.out_index(self)
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
@abc.abstractmethod
|
|
93
|
+
def is_time_continuous(self) -> bool:
|
|
94
|
+
"""Return True if the data is continuous in the time domain, False if it is discrete."""
|
|
95
|
+
raise NotImplementedError
|
|
96
|
+
|
|
97
|
+
@property
|
|
98
|
+
def node(self):
|
|
99
|
+
"""Return the node where this stream comes from."""
|
|
100
|
+
return self._node
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def node_main(self):
|
|
104
|
+
"""Return the global node, can be an alias to the classic node."""
|
|
105
|
+
return self._node_main
|
|
106
|
+
|
|
107
|
+
@node_main.setter
|
|
108
|
+
def node_main(self, new_node):
|
|
109
|
+
"""Change the node if this stream is already present in the new node at the same place."""
|
|
110
|
+
for i, stream in enumerate(new_node.out_streams):
|
|
111
|
+
if stream is self:
|
|
112
|
+
if self.index != i:
|
|
113
|
+
raise AttributeError(
|
|
114
|
+
f"the index of the stream {self} in the node {self.node} is {self.index}, "
|
|
115
|
+
f"but it is {i} in the node {new_node}"
|
|
116
|
+
)
|
|
117
|
+
self._node_main = new_node
|
|
118
|
+
return
|
|
119
|
+
raise AttributeError(f"the stream {self} is not in the node {new_node}")
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
@abc.abstractmethod
|
|
123
|
+
def type(self) -> str:
|
|
124
|
+
"""Return the type of stream, 'audio', 'subtitle' or 'video'."""
|
|
125
|
+
raise NotImplementedError
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class StreamWrapper(Stream):
|
|
129
|
+
"""Allow to dynamically transfer the methods of an instanced stream.
|
|
130
|
+
|
|
131
|
+
Attribute
|
|
132
|
+
---------
|
|
133
|
+
stream : cutcutcodec.core.classes.stream.Stream
|
|
134
|
+
The stream containing the properties to be transferred (readonly).
|
|
135
|
+
This stream is one of the input streams of the parent node.
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def __init__(self, node, index: numbers.Integral):
|
|
139
|
+
"""Initialise and create the class.
|
|
140
|
+
|
|
141
|
+
Parameters
|
|
142
|
+
----------
|
|
143
|
+
node : cutcutcodec.core.classes.node.Node
|
|
144
|
+
The parent node, transmitted to ``cutcutcodec.core.classes.stream.Stream``.
|
|
145
|
+
index : number.Integral
|
|
146
|
+
The index of the stream among all the input streams of the ``node``.
|
|
147
|
+
0 for the first, 1 for the second ...
|
|
148
|
+
"""
|
|
149
|
+
super().__init__(node)
|
|
150
|
+
assert isinstance(index, numbers.Integral) and index >= 0, index
|
|
151
|
+
assert len(node.in_streams) > index, f"only {len(node.in_streams)} streams, no {index}"
|
|
152
|
+
self._index = int(index)
|
|
153
|
+
|
|
154
|
+
@property
|
|
155
|
+
def beginning(self) -> Fraction:
|
|
156
|
+
"""Return the stream beginning instant in second."""
|
|
157
|
+
return self.stream.beginning
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
161
|
+
"""Return the duration of the flow in seconds, positive fraction or infinite."""
|
|
162
|
+
return self.stream.duration
|
|
163
|
+
|
|
164
|
+
@property
|
|
165
|
+
def index(self) -> int:
|
|
166
|
+
"""Return the stream index from the parent node (0 to n-1)."""
|
|
167
|
+
return self._index
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def is_time_continuous(self) -> bool:
|
|
171
|
+
"""Return True if the data is continuous in the time domain, False if it is discrete."""
|
|
172
|
+
return self.stream.is_time_continuous
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def stream(self) -> Stream:
|
|
176
|
+
"""Return the audio stream containing the properties to be transferred."""
|
|
177
|
+
return self.node.in_streams[self.index]
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def type(self) -> str:
|
|
181
|
+
"""Implement ``cutcutcodec.core.classes.stream.Stream.type``."""
|
|
182
|
+
return self.stream.type
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure of an abstract audio stream."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import abc
|
|
7
|
+
import numbers
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
11
|
+
from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
12
|
+
from cutcutcodec.core.classes.layout import Layout
|
|
13
|
+
from cutcutcodec.core.classes.stream import Stream, StreamWrapper
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class StreamAudio(Stream):
|
|
17
|
+
"""Representation of any audio stream.
|
|
18
|
+
|
|
19
|
+
Attributes
|
|
20
|
+
----------
|
|
21
|
+
layout : cutcutcodec.core.classes.layout.Layout
|
|
22
|
+
The signification of each channels (readonly).
|
|
23
|
+
The number of channels is ``len(self.layout.channels)``.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
@abc.abstractmethod
|
|
27
|
+
def _snapshot(self, timestamp: Fraction, rate: int, samples: int) -> FrameAudio:
|
|
28
|
+
raise NotImplementedError
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
@abc.abstractmethod
|
|
32
|
+
def layout(self) -> Layout:
|
|
33
|
+
"""Return the signification of each channels."""
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
def snapshot(
|
|
37
|
+
self,
|
|
38
|
+
timestamp: numbers.Real,
|
|
39
|
+
rate: typing.Optional[numbers.Integral] = None,
|
|
40
|
+
samples: numbers.Integral = 1,
|
|
41
|
+
) -> FrameAudio:
|
|
42
|
+
"""Extract the closest values to the requested date.
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
timestamp : numbers.Real
|
|
47
|
+
The absolute time expressed in seconds, not relative to the beginning of the audio.
|
|
48
|
+
Is the instant of the first sample of the returned frame.
|
|
49
|
+
For avoid the inacuracies of round, it is recomended to use fractional number.
|
|
50
|
+
rate : numbers.Integral, optional
|
|
51
|
+
If samples == 1, this argument is ignored. Otherwise is the samplerate of the frame.
|
|
52
|
+
If provide and samples != 1, allows to deduce the timestamps of the non 0 samples.
|
|
53
|
+
If non provide and samples != 1, try to call the `rate` attribute of the stream.
|
|
54
|
+
samples : numbers.Integral, default=1
|
|
55
|
+
The number of audio samples per channels to catch.
|
|
56
|
+
|
|
57
|
+
Returns
|
|
58
|
+
-------
|
|
59
|
+
samples : FrameAudio
|
|
60
|
+
Audio samples corresponding to the times provided.
|
|
61
|
+
This vector is of shape (nbr_channels, *timestamp_shape).
|
|
62
|
+
The values are between -1 and 1.
|
|
63
|
+
|
|
64
|
+
Raises
|
|
65
|
+
------
|
|
66
|
+
cutcutcodec.core.exception.OutOfTimeRange
|
|
67
|
+
If we try to get a frame out of the definition range.
|
|
68
|
+
The valid range is [self.beginning, self.beginning+self.duration].
|
|
69
|
+
The range taken is [timestamp, timestamp + samples/rate[.
|
|
70
|
+
AttributeError
|
|
71
|
+
If the `rate` attribute has to be defined but is not provides or deductable.
|
|
72
|
+
"""
|
|
73
|
+
# verifications on input
|
|
74
|
+
assert isinstance(samples, numbers.Integral), samples.__class__.__name__
|
|
75
|
+
samples = int(samples)
|
|
76
|
+
assert samples > 0, samples
|
|
77
|
+
if rate is None:
|
|
78
|
+
if samples != 1:
|
|
79
|
+
if (rate := getattr(self, "rate", None)) is None:
|
|
80
|
+
raise ValueError("rate attribute has to be provide")
|
|
81
|
+
else:
|
|
82
|
+
rate = 1 # ignore default unused stupid value
|
|
83
|
+
assert isinstance(rate, numbers.Integral), rate.__class__.__name__
|
|
84
|
+
rate = int(rate)
|
|
85
|
+
assert rate > 0, rate
|
|
86
|
+
assert isinstance(timestamp, numbers.Real), timestamp.__class__.__name__
|
|
87
|
+
timestamp = Fraction(timestamp)
|
|
88
|
+
|
|
89
|
+
# extract samples
|
|
90
|
+
frame = self._snapshot(timestamp, rate, samples)
|
|
91
|
+
|
|
92
|
+
# result verification
|
|
93
|
+
assert isinstance(frame, FrameAudio), frame.__class__.__name__
|
|
94
|
+
return frame
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def type(self) -> str:
|
|
98
|
+
"""Implement ``cutcutcodec.core.classes.stream.Stream.type``."""
|
|
99
|
+
return "audio"
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class StreamAudioWrapper(StreamWrapper, StreamAudio):
|
|
103
|
+
"""Allow to dynamically transfer the methods of an instanced audio stream.
|
|
104
|
+
|
|
105
|
+
This can be very useful for implementing filters.
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
def __init__(self, node: Filter, index: numbers.Integral):
|
|
109
|
+
"""Initialise and create the class.
|
|
110
|
+
|
|
111
|
+
Parameters
|
|
112
|
+
----------
|
|
113
|
+
node : cutcutcodec.core.classes.filter.Filter
|
|
114
|
+
The parent node, transmitted to ``cutcutcodec.core.classes.stream.Stream``.
|
|
115
|
+
index : number.Integral
|
|
116
|
+
The index of the audio stream among all the input streams of the ``node``.
|
|
117
|
+
0 for the first, 1 for the second ...
|
|
118
|
+
"""
|
|
119
|
+
assert isinstance(node, Filter), node.__class__.__name__
|
|
120
|
+
assert len(node.in_streams) > index, f"only {len(node.in_streams)} streams, no {index}"
|
|
121
|
+
assert isinstance(node.in_streams[index], StreamAudio), "the stream must be audio type"
|
|
122
|
+
super().__init__(node, index)
|
|
123
|
+
|
|
124
|
+
def _snapshot(self, timestamp: Fraction, rate: int, samples: int) -> FrameAudio:
|
|
125
|
+
return self.stream._snapshot(timestamp, rate, samples) # pylint: disable=W0613
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def layout(self) -> Layout:
|
|
129
|
+
"""Return the signification of each channels."""
|
|
130
|
+
return self.stream.layout
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Defines the structure of an abstract video stream."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import abc
|
|
7
|
+
import math
|
|
8
|
+
import numbers
|
|
9
|
+
import typing
|
|
10
|
+
|
|
11
|
+
import torch
|
|
12
|
+
|
|
13
|
+
from cutcutcodec.core.classes.filter import Filter
|
|
14
|
+
from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
15
|
+
from cutcutcodec.core.classes.stream import Stream, StreamWrapper
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class StreamVideo(Stream):
|
|
19
|
+
"""Representation of any video stream.
|
|
20
|
+
|
|
21
|
+
Attributes
|
|
22
|
+
----------
|
|
23
|
+
is_space_continuous : boolean
|
|
24
|
+
True if the data is continuous in the spacial domain, False if it is discrete (readonly).
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(self, node):
|
|
28
|
+
super().__init__(node)
|
|
29
|
+
self._mask = None # for cache speedup
|
|
30
|
+
|
|
31
|
+
@staticmethod
|
|
32
|
+
def _frame_to_float(frame: torch.Tensor) -> torch.Tensor:
|
|
33
|
+
"""Convert a video frame or a tensor into float32.
|
|
34
|
+
|
|
35
|
+
Warning, avoid copy as much as possible.
|
|
36
|
+
"""
|
|
37
|
+
if frame.dtype.is_floating_point:
|
|
38
|
+
return frame
|
|
39
|
+
frame = frame.to(dtype=torch.float32)
|
|
40
|
+
return torch.mul(frame, 1/255, out=frame)
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def _frame_to_uint8(frame: torch.Tensor) -> torch.Tensor:
|
|
44
|
+
"""Convert a video frame into an uint8 tensor.
|
|
45
|
+
|
|
46
|
+
Warning, avoid copy as much as possible.
|
|
47
|
+
"""
|
|
48
|
+
if frame.dtype == torch.uint8:
|
|
49
|
+
return frame
|
|
50
|
+
frame = torch.mul(frame, 255.0, out=frame)
|
|
51
|
+
frame = torch.clip(frame, 0.0, 255.0, out=frame)
|
|
52
|
+
frame = torch.round(frame, out=frame)
|
|
53
|
+
frame = frame.to(dtype=torch.uint8)
|
|
54
|
+
return frame
|
|
55
|
+
|
|
56
|
+
def _from_masked_items(self, flat_frame: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
|
|
57
|
+
"""Return a new frame with the initialised values at the position given by the mask.
|
|
58
|
+
|
|
59
|
+
A copy is made only if needed.
|
|
60
|
+
It is the complementary method of
|
|
61
|
+
``cutcutcodec.core.classes.stream_video.StreamVideo._to_masked_items``.
|
|
62
|
+
"""
|
|
63
|
+
if mask is self._mask:
|
|
64
|
+
return torch.reshape(flat_frame, (*mask.shape, 1))
|
|
65
|
+
frame = torch.empty(*mask.shape, dtype=flat_frame.dtype, device=flat_frame.device)
|
|
66
|
+
frame[mask] = flat_frame
|
|
67
|
+
frame = torch.unsqueeze(frame, 2)
|
|
68
|
+
return frame
|
|
69
|
+
|
|
70
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
71
|
+
"""Abstract help for ``snapshot``.
|
|
72
|
+
|
|
73
|
+
Parameters
|
|
74
|
+
----------
|
|
75
|
+
timestamp : fractions.Fraction
|
|
76
|
+
The absolute time expressed in seconds
|
|
77
|
+
mask : torch.Tensor[boolean]
|
|
78
|
+
The 2d boolean matrix of the interested pixels.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
torch.Tensor[numbers.Real]
|
|
83
|
+
A floting point matrix of pixel between 0 and 1.
|
|
84
|
+
"""
|
|
85
|
+
raise NotImplementedError
|
|
86
|
+
|
|
87
|
+
def _to_masked_items(self, frame: torch.Tensor, mask: torch.Tensor) -> torch.Tensor:
|
|
88
|
+
"""Return a contiguous flattened tensor equivalent to `frame[mask]`.
|
|
89
|
+
|
|
90
|
+
A copy is made only if needed.
|
|
91
|
+
It is the complementary method of
|
|
92
|
+
``cutcutcodec.core.classes.stream_video.StreamVideo._from_masked_items``.
|
|
93
|
+
"""
|
|
94
|
+
if mask is self._mask:
|
|
95
|
+
return torch.ravel(frame)
|
|
96
|
+
return torch.ravel(torch.masked_select(frame, mask).contiguous())
|
|
97
|
+
|
|
98
|
+
@property
|
|
99
|
+
@abc.abstractmethod
|
|
100
|
+
def is_space_continuous(self) -> bool:
|
|
101
|
+
"""Return True if the data is continuous in the spacial domain, False if it is discrete."""
|
|
102
|
+
raise NotImplementedError
|
|
103
|
+
|
|
104
|
+
def snapshot(
|
|
105
|
+
self,
|
|
106
|
+
timestamp: numbers.Real,
|
|
107
|
+
shape: typing.Union[tuple[numbers.Integral, numbers.Integral], list[numbers.Integral]],
|
|
108
|
+
*, channels=None
|
|
109
|
+
) -> FrameVideo:
|
|
110
|
+
"""Extract the closest frame to the requested date.
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
timestamp : numbers.Real
|
|
115
|
+
The absolute time expressed in seconds, not relative to the beginning of the video.
|
|
116
|
+
For avoid the inacuracies of round, it is recomended to use fractional number.
|
|
117
|
+
shape : tuple[int, int] or list[int, int]
|
|
118
|
+
The pixel dimensions of the returned frame.
|
|
119
|
+
The convention adopted is the numpy convention (height, width).
|
|
120
|
+
channels : int, optional
|
|
121
|
+
Impose the numbers of channels, apply convertion if nescessary.
|
|
122
|
+
For the interpretation of the layers,
|
|
123
|
+
see ``cutcutcodec.core.classes.frame_video.FrameVideo``.
|
|
124
|
+
|
|
125
|
+
Returns
|
|
126
|
+
-------
|
|
127
|
+
frame : cutcutcodec.core.classes.frame_video.FrameVideo
|
|
128
|
+
Video frame with metadata.
|
|
129
|
+
|
|
130
|
+
Raises
|
|
131
|
+
------
|
|
132
|
+
cutcutcodec.core.exception.OutOfTimeRange
|
|
133
|
+
If we try to get a frame out of the definition range.
|
|
134
|
+
The valid range is [self.beginning, self.beginning+self.duration[.
|
|
135
|
+
"""
|
|
136
|
+
assert isinstance(timestamp, numbers.Real), timestamp.__class__.__name__
|
|
137
|
+
assert isinstance(shape, (tuple, list)), shape.__class__.__name__
|
|
138
|
+
assert len(shape) == 2, len(shape)
|
|
139
|
+
assert all(isinstance(s, numbers.Integral) and s >= 1 for s in shape), shape
|
|
140
|
+
shape = (int(shape[0]), int(shape[1]))
|
|
141
|
+
if math.isnan(timestamp): # default transparent video frame
|
|
142
|
+
frame = FrameVideo(0, torch.zeros((*shape, 2), dtype=torch.uint8))
|
|
143
|
+
else:
|
|
144
|
+
if self._mask is None or self._mask.shape != shape:
|
|
145
|
+
self._mask = torch.full(shape, True, dtype=bool)
|
|
146
|
+
frame = self._snapshot(Fraction(timestamp), self._mask)
|
|
147
|
+
frame = self._frame_to_uint8(frame)
|
|
148
|
+
frame = FrameVideo(timestamp, frame)
|
|
149
|
+
if channels is not None:
|
|
150
|
+
frame = frame.convert(channels)
|
|
151
|
+
return frame
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def type(self) -> str:
|
|
155
|
+
"""Implement ``cutcutcodec.core.classes.stream.Stream.type``."""
|
|
156
|
+
return "video"
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
class StreamVideoWrapper(StreamWrapper, StreamVideo):
|
|
160
|
+
"""Allow to dynamically transfer the methods of an instanced video stream.
|
|
161
|
+
|
|
162
|
+
This can be very useful for implementing filters.
|
|
163
|
+
|
|
164
|
+
Attribute
|
|
165
|
+
---------
|
|
166
|
+
stream : cutcutcodec.core.classes.stream_video.StreamVideo
|
|
167
|
+
The video stream containing the properties to be transferred (readonly).
|
|
168
|
+
This stream is one of the input streams of the parent node.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
def __init__(self, node: Filter, index: numbers.Integral):
|
|
172
|
+
"""Initialise and create the class.
|
|
173
|
+
|
|
174
|
+
Parameters
|
|
175
|
+
----------
|
|
176
|
+
node : cutcutcodec.core.classes.filter.Filter
|
|
177
|
+
The parent node, transmitted to ``cutcutcodec.core.classes.stream.Stream``.
|
|
178
|
+
index : number.Integral
|
|
179
|
+
The index of the video stream among all the input streams of the ``node``.
|
|
180
|
+
0 for the first, 1 for the second ...
|
|
181
|
+
"""
|
|
182
|
+
assert isinstance(node, Filter), node.__class__.__name__
|
|
183
|
+
assert len(node.in_streams) > index, f"only {len(node.in_streams)} streams, no {index}"
|
|
184
|
+
assert isinstance(node.in_streams[index], StreamVideo), "the stream must be video type"
|
|
185
|
+
super().__init__(node, index)
|
|
186
|
+
|
|
187
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
188
|
+
return self.stream._snapshot(timestamp, mask)
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def is_space_continuous(self) -> bool:
|
|
192
|
+
"""Return True if the data is continuous in the spacial domain, False if it is discrete."""
|
|
193
|
+
return self.stream.is_space_continuous
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Export the ast tree into an excecutable python file."""
|
|
4
|
+
|
|
5
|
+
import ast
|
|
6
|
+
import pathlib
|
|
7
|
+
import stat
|
|
8
|
+
import typing
|
|
9
|
+
|
|
10
|
+
import black
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def ast_to_file(module: ast.Module, filename: typing.Union[str, bytes, pathlib.Path]):
|
|
14
|
+
'''Write the module into an excecutable python file.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
module : ast.Module
|
|
19
|
+
The pre compiled graph, could be the output of the function
|
|
20
|
+
``cutcutcodec.core.compilation.graph_to_ast.graph_to_ast``.
|
|
21
|
+
filename : pathlib.Path
|
|
22
|
+
The name of the targeted file.
|
|
23
|
+
|
|
24
|
+
Examples
|
|
25
|
+
--------
|
|
26
|
+
>>> import os
|
|
27
|
+
>>> from cutcutcodec.core.compilation.ast_to_file import ast_to_file
|
|
28
|
+
>>> from cutcutcodec.core.compilation.graph_to_ast import graph_to_ast
|
|
29
|
+
>>> from cutcutcodec.core.compilation.tree_to_graph import tree_to_graph
|
|
30
|
+
>>> from cutcutcodec.core.io.write import ContainerOutputFFMPEG
|
|
31
|
+
>>> tree = ContainerOutputFFMPEG.default()
|
|
32
|
+
>>> filename = tree.filename.with_suffix(".py")
|
|
33
|
+
>>> module = graph_to_ast(tree_to_graph(tree))
|
|
34
|
+
>>> ast_to_file(module, filename)
|
|
35
|
+
>>> with open(filename, "r", encoding="utf-8") as raw:
|
|
36
|
+
... print(raw.read()) # doctest: +ELLIPSIS
|
|
37
|
+
...
|
|
38
|
+
#!/usr/bin/env python3
|
|
39
|
+
<BLANKLINE>
|
|
40
|
+
"""Autogenerated project exportation script.
|
|
41
|
+
<BLANKLINE>
|
|
42
|
+
Creation: ...
|
|
43
|
+
Graph: MultiDiGraph with 3 nodes and 2 edges
|
|
44
|
+
"""
|
|
45
|
+
from cutcutcodec.core.classes.node import Node
|
|
46
|
+
from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
47
|
+
from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
48
|
+
from cutcutcodec.core.io.write import ContainerOutputFFMPEG
|
|
49
|
+
<BLANKLINE>
|
|
50
|
+
<BLANKLINE>
|
|
51
|
+
def get_container_output_ffmpeg_1(
|
|
52
|
+
generator_audio_noise_1: Node, generator_video_noise_1: Node
|
|
53
|
+
) -> ContainerOutputFFMPEG:
|
|
54
|
+
"""Create the node 'container_output_ffmpeg_1'."""
|
|
55
|
+
container_output_ffmpeg_1 = ContainerOutputFFMPEG.__new__(ContainerOutputFFMPEG)
|
|
56
|
+
container_output_ffmpeg_1.setstate(
|
|
57
|
+
[
|
|
58
|
+
generator_audio_noise_1.out_streams[0],
|
|
59
|
+
generator_video_noise_1.out_streams[0],
|
|
60
|
+
],
|
|
61
|
+
state={
|
|
62
|
+
"filename": "/tmp/....mkv",
|
|
63
|
+
"streams_settings": [
|
|
64
|
+
{"encodec": "libopus", "rate": "8000", "options": {}, "bitrate": None},
|
|
65
|
+
{
|
|
66
|
+
"encodec": "libx264",
|
|
67
|
+
"rate": "12",
|
|
68
|
+
"shape": (2, 2),
|
|
69
|
+
"options": {},
|
|
70
|
+
"bitrate": None,
|
|
71
|
+
"pix_fmt": None,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
"container_settings": {
|
|
75
|
+
"format": None,
|
|
76
|
+
"options": {},
|
|
77
|
+
"container_options": {},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
return container_output_ffmpeg_1
|
|
82
|
+
<BLANKLINE>
|
|
83
|
+
<BLANKLINE>
|
|
84
|
+
def get_generator_audio_noise_1() -> GeneratorAudioNoise:
|
|
85
|
+
"""Create the node 'generator_audio_noise_1'."""
|
|
86
|
+
generator_audio_noise_1 = GeneratorAudioNoise.__new__(GeneratorAudioNoise)
|
|
87
|
+
generator_audio_noise_1.setstate([], state={"seed": 0.0, "layout": "stereo"})
|
|
88
|
+
return generator_audio_noise_1
|
|
89
|
+
<BLANKLINE>
|
|
90
|
+
<BLANKLINE>
|
|
91
|
+
def get_generator_video_noise_1() -> GeneratorVideoNoise:
|
|
92
|
+
"""Create the node 'generator_video_noise_1'."""
|
|
93
|
+
generator_video_noise_1 = GeneratorVideoNoise.__new__(GeneratorVideoNoise)
|
|
94
|
+
generator_video_noise_1.setstate([], state={"seed": 0.0})
|
|
95
|
+
return generator_video_noise_1
|
|
96
|
+
<BLANKLINE>
|
|
97
|
+
<BLANKLINE>
|
|
98
|
+
def get_complete_tree() -> ContainerOutputFFMPEG:
|
|
99
|
+
"""Retrive the complete assembly graph."""
|
|
100
|
+
generator_audio_noise_1 = get_generator_audio_noise_1()
|
|
101
|
+
generator_video_noise_1 = get_generator_video_noise_1()
|
|
102
|
+
container_output_ffmpeg_1 = get_container_output_ffmpeg_1(
|
|
103
|
+
generator_audio_noise_1, generator_video_noise_1
|
|
104
|
+
)
|
|
105
|
+
return container_output_ffmpeg_1
|
|
106
|
+
<BLANKLINE>
|
|
107
|
+
<BLANKLINE>
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
get_complete_tree().write()
|
|
110
|
+
<BLANKLINE>
|
|
111
|
+
>>> os.remove(filename)
|
|
112
|
+
>>>
|
|
113
|
+
'''
|
|
114
|
+
assert isinstance(module, ast.Module), module.__class__.__name__
|
|
115
|
+
filename = pathlib.Path(filename)
|
|
116
|
+
assert filename.suffix == ".py", filename
|
|
117
|
+
|
|
118
|
+
code = ast.unparse(module)
|
|
119
|
+
code = "#!/usr/bin/env python3\n\n" + code
|
|
120
|
+
code = black.format_str(code, mode=black.Mode())
|
|
121
|
+
|
|
122
|
+
# write file and give execution permission
|
|
123
|
+
with open(filename, "w", encoding="utf-8") as code_file:
|
|
124
|
+
code_file.write(code)
|
|
125
|
+
filename.chmod(filename.stat().st_mode | stat.S_IEXEC)
|