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,145 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Decode the svg vectorial images based on `cairosvg` lib."""
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from fractions import Fraction
|
|
7
|
+
import math
|
|
8
|
+
import pathlib
|
|
9
|
+
import typing
|
|
10
|
+
|
|
11
|
+
import cairosvg
|
|
12
|
+
import cv2
|
|
13
|
+
import numpy as np
|
|
14
|
+
import torch
|
|
15
|
+
|
|
16
|
+
from cutcutcodec.core.classes.container import ContainerInput
|
|
17
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
18
|
+
from cutcutcodec.core.classes.stream_video import StreamVideo
|
|
19
|
+
from cutcutcodec.core.exceptions import OutOfTimeRange
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ContainerInputSVG(ContainerInput):
|
|
23
|
+
"""Decode an svg image to a matricial image of any dimension.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> from cutcutcodec.core.io.read_svg import ContainerInputSVG
|
|
28
|
+
>>> (stream,) = ContainerInputSVG.default().out_streams
|
|
29
|
+
>>> stream.snapshot(0, (12, 12))[..., 3]
|
|
30
|
+
tensor([[ 0, 0, 7, 110, 200, 244, 244, 200, 109, 7, 0, 0],
|
|
31
|
+
[ 0, 27, 208, 255, 255, 255, 255, 255, 255, 207, 27, 0],
|
|
32
|
+
[ 7, 208, 255, 255, 255, 255, 255, 255, 255, 255, 207, 7],
|
|
33
|
+
[110, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 108],
|
|
34
|
+
[201, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 199],
|
|
35
|
+
[243, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 243],
|
|
36
|
+
[243, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 241],
|
|
37
|
+
[201, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 199],
|
|
38
|
+
[109, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 108],
|
|
39
|
+
[ 7, 207, 255, 255, 255, 255, 255, 255, 255, 255, 207, 6],
|
|
40
|
+
[ 0, 27, 207, 255, 255, 255, 255, 255, 255, 207, 27, 0],
|
|
41
|
+
[ 0, 0, 6, 108, 199, 243, 243, 198, 108, 6, 0, 0]],
|
|
42
|
+
dtype=torch.uint8)
|
|
43
|
+
>>>
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(self, bytestring=None, *, url=None, unsafe=False):
|
|
47
|
+
"""All parameters are transmitted to ``cairosvg.svg2png``."""
|
|
48
|
+
if url is not None and pathlib.Path(url).is_file():
|
|
49
|
+
with open(url, "rb") as file:
|
|
50
|
+
bytestring, url = file.read(), None
|
|
51
|
+
self.bytestring = bytestring
|
|
52
|
+
self.url = url
|
|
53
|
+
self.unsafe = unsafe
|
|
54
|
+
|
|
55
|
+
super().__init__([_StreamVideoSVG(self)])
|
|
56
|
+
|
|
57
|
+
def _getstate(self) -> dict:
|
|
58
|
+
return {
|
|
59
|
+
"bytestring": (
|
|
60
|
+
self.bytestring.decode("utf-8") if self.bytestring is not None else None
|
|
61
|
+
),
|
|
62
|
+
"url": (str(self.url) if self.url is not None else None),
|
|
63
|
+
"unsafe": self.unsafe,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
def _setstate(self, in_streams: typing.Iterable[Stream], state: dict) -> None:
|
|
67
|
+
keys = {"bytestring", "url", "unsafe"}
|
|
68
|
+
assert state.keys() == keys, set(state)-keys
|
|
69
|
+
bytestring = (
|
|
70
|
+
state["bytestring"] if state["bytestring"] is None
|
|
71
|
+
else state["bytestring"].encode("utf8")
|
|
72
|
+
)
|
|
73
|
+
ContainerInputSVG.__init__(self, bytestring, url=state["url"], unsafe=state["unsafe"])
|
|
74
|
+
|
|
75
|
+
@classmethod
|
|
76
|
+
def default(cls):
|
|
77
|
+
"""Provide a minimalist example of an instance of this node."""
|
|
78
|
+
return cls(url="cutcutcodec/examples/logo.svg")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class _StreamVideoSVG(StreamVideo):
|
|
82
|
+
"""Read SVG as a video stream.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
height : int
|
|
87
|
+
The preconised dimension i (vertical) of the picture in pxl (readonly).
|
|
88
|
+
width : int
|
|
89
|
+
The preconised dimension j (horizontal) of the picture in pxl (readonly).
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
is_space_continuous = True
|
|
93
|
+
is_time_continuous = True
|
|
94
|
+
|
|
95
|
+
def __init__(self, node: ContainerInputSVG):
|
|
96
|
+
assert isinstance(node, ContainerInputSVG), node.__class__.__name__
|
|
97
|
+
super().__init__(node)
|
|
98
|
+
self._height, self._width = None, None
|
|
99
|
+
self._img = None
|
|
100
|
+
|
|
101
|
+
def _get_img(self, shape: tuple[int, int]) -> torch.Tensor:
|
|
102
|
+
"""Cache the image."""
|
|
103
|
+
if self._img is None or self._img[0] != shape:
|
|
104
|
+
self._img = (
|
|
105
|
+
shape,
|
|
106
|
+
torch.from_numpy(
|
|
107
|
+
cv2.imdecode(
|
|
108
|
+
np.frombuffer(
|
|
109
|
+
cairosvg.svg2png(
|
|
110
|
+
self.node.bytestring,
|
|
111
|
+
url=self.node.url,
|
|
112
|
+
unsafe=self.node.unsafe,
|
|
113
|
+
output_height=shape[0],
|
|
114
|
+
output_width=shape[1],
|
|
115
|
+
),
|
|
116
|
+
np.uint8,
|
|
117
|
+
),
|
|
118
|
+
cv2.IMREAD_UNCHANGED,
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
)
|
|
122
|
+
return self._img[1]
|
|
123
|
+
|
|
124
|
+
def _snapshot(self, timestamp: Fraction, mask: torch.Tensor) -> torch.Tensor:
|
|
125
|
+
if timestamp < 0:
|
|
126
|
+
raise OutOfTimeRange(f"there is no audio frame at timestamp {timestamp} (need >= 0)")
|
|
127
|
+
return self._get_img(mask.shape)
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def beginning(self) -> Fraction:
|
|
131
|
+
return Fraction(0)
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def duration(self) -> typing.Union[Fraction, float]:
|
|
135
|
+
return math.inf
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def height(self) -> int:
|
|
139
|
+
"""Return the preconised dimension i (vertical) of the picture in pxl."""
|
|
140
|
+
raise NotImplementedError
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def width(self) -> int:
|
|
144
|
+
"""Return the preconised dimension j (horizontal) of the picture in pxl."""
|
|
145
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Combine several stream to yield frame in monotonic order.
|
|
4
|
+
|
|
5
|
+
It is helpfull for writing and muxing.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from fractions import Fraction
|
|
9
|
+
import functools
|
|
10
|
+
import itertools
|
|
11
|
+
import logging
|
|
12
|
+
import math
|
|
13
|
+
import typing
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
import torch
|
|
17
|
+
|
|
18
|
+
from cutcutcodec.core.classes.frame import Frame
|
|
19
|
+
from cutcutcodec.core.classes.frame_audio import FrameAudio
|
|
20
|
+
from cutcutcodec.core.classes.frame_video import FrameVideo
|
|
21
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
22
|
+
from cutcutcodec.core.classes.stream_audio import StreamAudio
|
|
23
|
+
from cutcutcodec.core.classes.stream_video import StreamVideo
|
|
24
|
+
from cutcutcodec.core.exceptions import MissingStreamError, OutOfTimeRange
|
|
25
|
+
from cutcutcodec.core.opti.parallel.buffer import imap, starimap
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _raise_missing_stream_error(gen: typing.Iterable) -> typing.Iterable:
|
|
29
|
+
"""Decorate for throwing MissingStreamError if the gen yields nothing."""
|
|
30
|
+
@functools.wraps(gen)
|
|
31
|
+
def generator(*args, **kwargs):
|
|
32
|
+
empty = True
|
|
33
|
+
for res in gen(*args, **kwargs):
|
|
34
|
+
empty = False
|
|
35
|
+
yield res
|
|
36
|
+
if empty:
|
|
37
|
+
raise MissingStreamError("no frame is present in any of the streams")
|
|
38
|
+
return generator
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _snapshot_audio_frames_async(arg):
|
|
42
|
+
"""Help audio_frames_async.
|
|
43
|
+
|
|
44
|
+
Picklable version
|
|
45
|
+
"""
|
|
46
|
+
stream, timestamp, rate, samples = arg
|
|
47
|
+
# extraction
|
|
48
|
+
try:
|
|
49
|
+
frame = stream.snapshot(timestamp, rate, samples)
|
|
50
|
+
except OutOfTimeRange as err: # end is near
|
|
51
|
+
end = stream.beginning + stream.duration
|
|
52
|
+
samples_frac = (end - timestamp) * rate
|
|
53
|
+
if (samples := math.floor(samples_frac)) <= 0:
|
|
54
|
+
raise err
|
|
55
|
+
frame = stream.snapshot(timestamp, rate, samples)
|
|
56
|
+
|
|
57
|
+
# verification
|
|
58
|
+
min_val, max_val = torch.aminmax(frame)
|
|
59
|
+
if min_val.item() < -1 or max_val.item() > 1:
|
|
60
|
+
logging.warning(
|
|
61
|
+
"saturated samples detected min %f max %f", min_val.item(), max_val.item()
|
|
62
|
+
)
|
|
63
|
+
return frame
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def audio_frames_async(
|
|
67
|
+
stream: StreamAudio,
|
|
68
|
+
rate: typing.Union[Fraction, int],
|
|
69
|
+
start_time: Fraction,
|
|
70
|
+
samples: typing.Optional[int] = None,
|
|
71
|
+
**_
|
|
72
|
+
) -> typing.Iterable[FrameAudio]:
|
|
73
|
+
"""Decode the audio frames in an over thread for performance.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
stream : cutcutcodec.core.classes.stream_audio.StreamAudio
|
|
78
|
+
The audio stream for extract the frames.
|
|
79
|
+
rate : int
|
|
80
|
+
The time frequency between each samples to catch.
|
|
81
|
+
start_time : fraction.Fraction
|
|
82
|
+
The frame with start time < start_time are ignored.
|
|
83
|
+
samples : int, optional
|
|
84
|
+
The maximum number of samples in a frame. The last frame
|
|
85
|
+
can to contains less samples in order to reach the end.
|
|
86
|
+
The special default value None means to choose automaticaly the
|
|
87
|
+
optimal number of samples in accordance to the sample rate.
|
|
88
|
+
By default, the samples are choose for a duration of 100 ms.
|
|
89
|
+
|
|
90
|
+
Yields
|
|
91
|
+
------
|
|
92
|
+
cutcutcodec.core.classes.frame_audio.FrameAudio
|
|
93
|
+
The frame audio such as create the complete signal if we concatenate her.
|
|
94
|
+
|
|
95
|
+
Examples
|
|
96
|
+
--------
|
|
97
|
+
>>> from fractions import Fraction
|
|
98
|
+
>>> from cutcutcodec.core.filters.audio.subclip import FilterAudioSubclip
|
|
99
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
100
|
+
>>> from cutcutcodec.core.io.scheduler import audio_frames_async
|
|
101
|
+
>>>
|
|
102
|
+
>>> (stream,) = FilterAudioSubclip(GeneratorAudioNoise(0).out_streams, 0, 1).out_streams
|
|
103
|
+
>>> for frame in audio_frames_async(stream, 1000, Fraction(10, 1001), samples=200):
|
|
104
|
+
... frame.time, frame.samples
|
|
105
|
+
...
|
|
106
|
+
(Fraction(1, 100), 200)
|
|
107
|
+
(Fraction(21, 100), 200)
|
|
108
|
+
(Fraction(41, 100), 200)
|
|
109
|
+
(Fraction(61, 100), 200)
|
|
110
|
+
(Fraction(81, 100), 190)
|
|
111
|
+
>>>
|
|
112
|
+
"""
|
|
113
|
+
assert isinstance(stream, StreamAudio), stream.__class__.__name__
|
|
114
|
+
if isinstance(rate, Fraction):
|
|
115
|
+
assert rate.denominator == 1, f"{rate} has to be integer"
|
|
116
|
+
rate = int(rate)
|
|
117
|
+
assert isinstance(rate, int), rate.__class__.__name__
|
|
118
|
+
assert rate > 0, rate # avoid stationnary 0 and backward
|
|
119
|
+
assert isinstance(start_time, Fraction), start_time.__class__.__name__
|
|
120
|
+
if samples is None:
|
|
121
|
+
samples = 2**round(math.log(max(1, rate*100e-3), 2)) # approx 100 ms
|
|
122
|
+
assert isinstance(samples, int), samples.__class__.__name__
|
|
123
|
+
assert samples >= 1, samples
|
|
124
|
+
|
|
125
|
+
start_time = max(start_time, stream.beginning) # avoid OutOfTimeRange for t < beginning
|
|
126
|
+
if rest := start_time % Fraction(1, rate):
|
|
127
|
+
start_time += Fraction(1, rate) - rest # start_time = k*(1/sr), k integer
|
|
128
|
+
interval = Fraction(samples, rate)
|
|
129
|
+
|
|
130
|
+
try:
|
|
131
|
+
yield from imap(
|
|
132
|
+
_snapshot_audio_frames_async,
|
|
133
|
+
((stream, start_time + i*interval, rate, samples) for i in itertools.count())
|
|
134
|
+
)
|
|
135
|
+
except OutOfTimeRange:
|
|
136
|
+
pass
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def video_frames_async(
|
|
140
|
+
stream: StreamVideo, out_fps: Fraction, start_time: Fraction, shape: tuple[int, int], **_
|
|
141
|
+
) -> typing.Iterable[FrameVideo]:
|
|
142
|
+
"""Decode the video frames in an over thread for performance.
|
|
143
|
+
|
|
144
|
+
Parameters
|
|
145
|
+
----------
|
|
146
|
+
stream : cutcutcodec.core.classes.stream_video.StreamVideo
|
|
147
|
+
The video stream for extract the frames.
|
|
148
|
+
out_fps : Fraction
|
|
149
|
+
The 1/step interval for each frame timestamp request.
|
|
150
|
+
start_time : Fraction
|
|
151
|
+
The frame with timestamp < start_time are ignored.
|
|
152
|
+
shape : tuple[int, int]
|
|
153
|
+
Transmitted to ``mocia.core.classes.stream_video.snapshot``.
|
|
154
|
+
|
|
155
|
+
Yields
|
|
156
|
+
------
|
|
157
|
+
cutcutcodec.core.classes.frame_video.FrameVideo
|
|
158
|
+
The frame videos in monotonic (non strict) order.
|
|
159
|
+
|
|
160
|
+
Examples
|
|
161
|
+
--------
|
|
162
|
+
>>> from fractions import Fraction
|
|
163
|
+
>>> from cutcutcodec.core.filters.video.subclip import FilterVideoSubclip
|
|
164
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
165
|
+
>>> from cutcutcodec.core.io.scheduler import video_frames_async
|
|
166
|
+
>>>
|
|
167
|
+
>>> (stream,) = FilterVideoSubclip(GeneratorVideoNoise(0).out_streams, 0, 1).out_streams
|
|
168
|
+
>>> for frame in video_frames_async(stream, Fraction(10, 1), Fraction(99, 200), shape=(1, 1)):
|
|
169
|
+
... frame.time
|
|
170
|
+
...
|
|
171
|
+
Fraction(1, 2)
|
|
172
|
+
Fraction(3, 5)
|
|
173
|
+
Fraction(7, 10)
|
|
174
|
+
Fraction(4, 5)
|
|
175
|
+
Fraction(9, 10)
|
|
176
|
+
>>>
|
|
177
|
+
"""
|
|
178
|
+
assert isinstance(stream, StreamVideo), stream.__class__.__name__
|
|
179
|
+
assert isinstance(out_fps, Fraction), out_fps.__class__.__name__
|
|
180
|
+
assert out_fps > 0, out_fps # avoid division by 0 and backward
|
|
181
|
+
assert isinstance(start_time, Fraction), start_time.__class__.__name__
|
|
182
|
+
assert isinstance(shape, tuple), shape.__class__.__name__
|
|
183
|
+
assert len(shape) == 2, len(shape)
|
|
184
|
+
assert all(isinstance(s, int) and s >= 1 for s in shape), shape
|
|
185
|
+
|
|
186
|
+
start_time = max(start_time, stream.beginning) # avoid OutOfTimeRange for t < beginning
|
|
187
|
+
if rest := start_time % (1/out_fps):
|
|
188
|
+
start_time += 1/out_fps - rest # start_time = k*(1/fps), k integer
|
|
189
|
+
|
|
190
|
+
try:
|
|
191
|
+
yield from starimap(
|
|
192
|
+
stream.snapshot, ((start_time + i/out_fps, shape) for i in itertools.count())
|
|
193
|
+
)
|
|
194
|
+
except OutOfTimeRange:
|
|
195
|
+
pass
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@_raise_missing_stream_error
|
|
199
|
+
def scheduler(
|
|
200
|
+
streams: list[Stream],
|
|
201
|
+
rates: list[typing.Union[Fraction, int]],
|
|
202
|
+
start_time: Fraction = Fraction(0),
|
|
203
|
+
shapes: typing.Union[None, tuple[int, int], list[typing.Union[None, tuple[int, int]]]] = None,
|
|
204
|
+
**kwargs,
|
|
205
|
+
) -> typing.Iterable[tuple[int, Frame]]:
|
|
206
|
+
"""Extract in chronological order the frames of all flows.
|
|
207
|
+
|
|
208
|
+
Gives up frames until all streams have raised the OutOfTimeRange exception.
|
|
209
|
+
|
|
210
|
+
Parameters
|
|
211
|
+
----------
|
|
212
|
+
streams : list[cutcutcodec.core.classes.stream.Stream]
|
|
213
|
+
Audio or video streams to exract the frames.
|
|
214
|
+
rates : list[Fraction]
|
|
215
|
+
The frame rate for video streams and the sample rate for audio streams.
|
|
216
|
+
start_time : Fraction, default=0
|
|
217
|
+
The position of the first frame yielded. The frame before are ignored.
|
|
218
|
+
shapes : tuple[int, int] or list[tuple[int, int]], optional
|
|
219
|
+
For video only, ignore if there is no video stream.
|
|
220
|
+
Each shape are transmitted to the stream. If the list is not provided,
|
|
221
|
+
the same shape is transmitted to all video streams.
|
|
222
|
+
**kwargs : dict
|
|
223
|
+
Transmitted to the functions ``cutcutcodec.core.io.scheduler.audio_frames_async``
|
|
224
|
+
and ``cutcutcodec.core.io.scheduler.video_frames_async``.
|
|
225
|
+
|
|
226
|
+
Yields
|
|
227
|
+
------
|
|
228
|
+
index : int
|
|
229
|
+
The index of the concerned stream in the order of the provided list.
|
|
230
|
+
frame : cutcutcodec.core.classes.frame.Frame
|
|
231
|
+
The future frame of the stream considered.
|
|
232
|
+
The ``time`` attribute is guaranteed to be monotonic.
|
|
233
|
+
|
|
234
|
+
Raises
|
|
235
|
+
------
|
|
236
|
+
cutcutcodec.core.exceptions.MissingStreamError
|
|
237
|
+
If no frame are yielded.
|
|
238
|
+
|
|
239
|
+
Examples
|
|
240
|
+
--------
|
|
241
|
+
>>> from fractions import Fraction
|
|
242
|
+
>>> from cutcutcodec.core.filters.audio.subclip import FilterAudioSubclip
|
|
243
|
+
>>> from cutcutcodec.core.filters.video.subclip import FilterVideoSubclip
|
|
244
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
245
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
246
|
+
>>> from cutcutcodec.core.io.scheduler import scheduler
|
|
247
|
+
>>>
|
|
248
|
+
>>> s_1 = (
|
|
249
|
+
... FilterVideoSubclip(GeneratorVideoNoise(0).out_streams, 0, Fraction(1, 10)).out_streams
|
|
250
|
+
... )
|
|
251
|
+
>>> s_2 = (
|
|
252
|
+
... FilterVideoSubclip(GeneratorVideoNoise(0).out_streams, 0, Fraction(1, 4)).out_streams
|
|
253
|
+
... )
|
|
254
|
+
>>> streams_video = [s_1[0], s_2[0]]
|
|
255
|
+
>>> rates_video = [Fraction(30), Fraction(24)]
|
|
256
|
+
>>> s_3 = (
|
|
257
|
+
... FilterAudioSubclip(GeneratorAudioNoise(0).out_streams, 0, Fraction(1, 10)).out_streams
|
|
258
|
+
... )
|
|
259
|
+
>>> s_4 = (
|
|
260
|
+
... FilterAudioSubclip(GeneratorAudioNoise(0).out_streams, 0, Fraction(1, 4)).out_streams
|
|
261
|
+
... )
|
|
262
|
+
>>> streams_audio = [s_3[0], s_4[0]]
|
|
263
|
+
>>> rates_audio = [96000, 48000]
|
|
264
|
+
>>>
|
|
265
|
+
>>> # test audio only
|
|
266
|
+
>>> for index, frame in scheduler(streams_audio, rates_audio):
|
|
267
|
+
... index, frame.time
|
|
268
|
+
...
|
|
269
|
+
(0, Fraction(0, 1))
|
|
270
|
+
(1, Fraction(0, 1))
|
|
271
|
+
(0, Fraction(32, 375))
|
|
272
|
+
(1, Fraction(32, 375))
|
|
273
|
+
(1, Fraction(64, 375))
|
|
274
|
+
>>> for index, frame in scheduler(streams_audio, rates_audio, start_time=Fraction(1, 10)):
|
|
275
|
+
... index, frame.time
|
|
276
|
+
...
|
|
277
|
+
(1, Fraction(1, 10))
|
|
278
|
+
(1, Fraction(139, 750))
|
|
279
|
+
>>>
|
|
280
|
+
>>> # test video only
|
|
281
|
+
>>> for index, frame in scheduler(streams_video, rates_video, shape=(1, 1)):
|
|
282
|
+
... index, frame.time
|
|
283
|
+
...
|
|
284
|
+
(0, Fraction(0, 1))
|
|
285
|
+
(1, Fraction(0, 1))
|
|
286
|
+
(0, Fraction(1, 30))
|
|
287
|
+
(1, Fraction(1, 24))
|
|
288
|
+
(0, Fraction(1, 15))
|
|
289
|
+
(1, Fraction(1, 12))
|
|
290
|
+
(1, Fraction(1, 8))
|
|
291
|
+
(1, Fraction(1, 6))
|
|
292
|
+
(1, Fraction(5, 24))
|
|
293
|
+
>>> for index, frame in scheduler(streams_video, rates_video, Fraction(1, 10), shape=(1, 1)):
|
|
294
|
+
... index, frame.time
|
|
295
|
+
...
|
|
296
|
+
(1, Fraction(1, 8))
|
|
297
|
+
(1, Fraction(1, 6))
|
|
298
|
+
(1, Fraction(5, 24))
|
|
299
|
+
>>>
|
|
300
|
+
>>> # test audio and video
|
|
301
|
+
>>> for index, frame in scheduler(
|
|
302
|
+
... streams_audio+streams_video, rates_audio+rates_video, shape=(1, 1), samples=4096
|
|
303
|
+
... ):
|
|
304
|
+
... index, frame.time
|
|
305
|
+
...
|
|
306
|
+
(0, Fraction(0, 1))
|
|
307
|
+
(1, Fraction(0, 1))
|
|
308
|
+
(2, Fraction(0, 1))
|
|
309
|
+
(3, Fraction(0, 1))
|
|
310
|
+
(2, Fraction(1, 30))
|
|
311
|
+
(3, Fraction(1, 24))
|
|
312
|
+
(0, Fraction(16, 375))
|
|
313
|
+
(2, Fraction(1, 15))
|
|
314
|
+
(3, Fraction(1, 12))
|
|
315
|
+
(0, Fraction(32, 375))
|
|
316
|
+
(1, Fraction(32, 375))
|
|
317
|
+
(3, Fraction(1, 8))
|
|
318
|
+
(3, Fraction(1, 6))
|
|
319
|
+
(1, Fraction(64, 375))
|
|
320
|
+
(3, Fraction(5, 24))
|
|
321
|
+
>>>
|
|
322
|
+
"""
|
|
323
|
+
assert isinstance(streams, list), streams.__class__.__name__
|
|
324
|
+
assert all(isinstance(s, Stream) for s in streams), streams
|
|
325
|
+
assert isinstance(rates, list), rates.__class__.__name__
|
|
326
|
+
assert len(streams) == len(rates)
|
|
327
|
+
if shapes is None:
|
|
328
|
+
shapes = [None for _ in streams]
|
|
329
|
+
elif isinstance(shapes, tuple):
|
|
330
|
+
shapes = [shapes for _ in streams]
|
|
331
|
+
else:
|
|
332
|
+
assert isinstance(shapes, list), shapes.__class__.__name__
|
|
333
|
+
assert len(streams) == len(shapes)
|
|
334
|
+
|
|
335
|
+
buffer = [None for _ in range(len(streams))] # buffered frame for each stream
|
|
336
|
+
queues = [
|
|
337
|
+
iter(
|
|
338
|
+
{"audio": audio_frames_async, "video": video_frames_async}[stream.type]
|
|
339
|
+
(stream, rate, start_time, **{"shape": shape, **kwargs})
|
|
340
|
+
)
|
|
341
|
+
for stream, rate, shape in zip(streams, rates, shapes)
|
|
342
|
+
] # asynchroneous decoder of frame for each stream, None when exausted
|
|
343
|
+
|
|
344
|
+
while any(q is not None for q in queues):
|
|
345
|
+
index = [j for j in (i for i, q in enumerate(queues) if q is not None) if buffer[j] is None]
|
|
346
|
+
try:
|
|
347
|
+
index = index.pop() # search position of empty stream
|
|
348
|
+
except IndexError: # in case we have to yield a frame
|
|
349
|
+
index = np.argmin([f.time if f is not None else math.inf for f in buffer])
|
|
350
|
+
yield index, buffer[index]
|
|
351
|
+
buffer[index] = None
|
|
352
|
+
else: # in case we need to recover a new frame
|
|
353
|
+
try:
|
|
354
|
+
buffer[index] = next(queues[index])
|
|
355
|
+
except StopIteration:
|
|
356
|
+
buffer[index] = queues[index] = None
|