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,734 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Allow to choose a format and codecs.
|
|
4
|
+
|
|
5
|
+
The information collected here concerns the encoding and not the decoding.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from fractions import Fraction
|
|
9
|
+
import contextlib
|
|
10
|
+
import io
|
|
11
|
+
import itertools
|
|
12
|
+
import multiprocessing
|
|
13
|
+
import os
|
|
14
|
+
import typing
|
|
15
|
+
|
|
16
|
+
import av
|
|
17
|
+
import numpy as np
|
|
18
|
+
import tqdm
|
|
19
|
+
|
|
20
|
+
from cutcutcodec.core.classes.encoder import AllEncoders, Encoder
|
|
21
|
+
from cutcutcodec.core.classes.muxer import AllMuxers
|
|
22
|
+
from cutcutcodec.core.exceptions import DecodeError, EncodeError, IncompatibleSettings
|
|
23
|
+
from cutcutcodec.core.opti.cache.singleton import MetaSingleton
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _decode(file: typing.Union[str, io.BytesIO], muxer: typing.Optional[str] = None) -> dict[str]:
|
|
27
|
+
"""Read and extracts the informations of the stream 0.
|
|
28
|
+
|
|
29
|
+
Extract only the mains informations. It uses pyav in background.
|
|
30
|
+
Decode the informations of the first stream only.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
file : str
|
|
35
|
+
The full path a the file to read or the io.BytesIO filelike, already seek to 0.
|
|
36
|
+
muxer : str, optional
|
|
37
|
+
The muxer name used for encode.
|
|
38
|
+
|
|
39
|
+
Returns
|
|
40
|
+
-------
|
|
41
|
+
properties : dict[str, str]
|
|
42
|
+
* `codec`: str # The name of the codec found.
|
|
43
|
+
* `layout`: str or None # The audio channel organisation.
|
|
44
|
+
* `muxer`: str # The decoded muxer name.
|
|
45
|
+
* `profile`: str # The name of the binary format of the data.
|
|
46
|
+
* `rate`: int or Fraction # The framerate or the samplerate.
|
|
47
|
+
* `shape`: tuple[int, int] or None # The shape of the frames.
|
|
48
|
+
* `type`: str # The type of stream.
|
|
49
|
+
|
|
50
|
+
Raises
|
|
51
|
+
------
|
|
52
|
+
DecodeError
|
|
53
|
+
If reading failed.
|
|
54
|
+
|
|
55
|
+
Notes
|
|
56
|
+
-----
|
|
57
|
+
No verifications are performed because it is a subfunction.
|
|
58
|
+
"""
|
|
59
|
+
properties = {}
|
|
60
|
+
|
|
61
|
+
try:
|
|
62
|
+
with av.open(file, mode="r", format=muxer) as container:
|
|
63
|
+
stream = container.streams[0]
|
|
64
|
+
properties["codec"] = stream.codec_context.codec.name
|
|
65
|
+
properties["layout"] = None
|
|
66
|
+
properties["muxer"] = container.format.name
|
|
67
|
+
properties["profile"] = stream.codec_context.format.name
|
|
68
|
+
properties["rate"] = None
|
|
69
|
+
properties["shape"] = None
|
|
70
|
+
properties["type"] = stream.type
|
|
71
|
+
if properties["type"] == "audio":
|
|
72
|
+
properties["layout"] = stream.codec_context.layout.name
|
|
73
|
+
properties["rate"] = stream.rate
|
|
74
|
+
elif properties["type"] == "video":
|
|
75
|
+
properties["rate"] = stream.average_rate
|
|
76
|
+
properties["shape"] = (stream.height, stream.width)
|
|
77
|
+
list(container.decode(stream)) # try to decode
|
|
78
|
+
|
|
79
|
+
except (av.error.FFmpegError, IndexError, AttributeError) as err:
|
|
80
|
+
raise DecodeError(f"failed to decode {file}") from err
|
|
81
|
+
|
|
82
|
+
return properties
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _encode_audio(
|
|
86
|
+
file: typing.Union[str, io.BytesIO],
|
|
87
|
+
encodec: str,
|
|
88
|
+
muxer: str,
|
|
89
|
+
**kwargs,
|
|
90
|
+
) -> None:
|
|
91
|
+
"""Test the encoder capability with the null muxer in a virtual file.
|
|
92
|
+
|
|
93
|
+
Parameters
|
|
94
|
+
----------
|
|
95
|
+
file : str
|
|
96
|
+
The full path a the file to write or the io.BytesIO filelike.
|
|
97
|
+
encodec : str
|
|
98
|
+
The codec or the encoder name.
|
|
99
|
+
muxer : str
|
|
100
|
+
The format name.
|
|
101
|
+
layout : str
|
|
102
|
+
The name of the audio layout, ex "stereo"
|
|
103
|
+
rate : int, optional
|
|
104
|
+
The samplerate of the audio in all channels.
|
|
105
|
+
profile : str, optional
|
|
106
|
+
The name of the binary format of the data ex "flt".
|
|
107
|
+
|
|
108
|
+
Raises
|
|
109
|
+
------
|
|
110
|
+
EncodeError
|
|
111
|
+
If reading failed.
|
|
112
|
+
|
|
113
|
+
Notes
|
|
114
|
+
-----
|
|
115
|
+
No verifications are performed because it is a subfunction.
|
|
116
|
+
"""
|
|
117
|
+
layout, rate, profile = kwargs["layout"], kwargs.get("rate", None), kwargs.get("profile", None)
|
|
118
|
+
os.environ["PYAV_LOGGING"] = "off"
|
|
119
|
+
try:
|
|
120
|
+
with av.open(file, mode="w", format=muxer) as container:
|
|
121
|
+
stream = container.add_stream(encodec, rate=rate, layout=layout)
|
|
122
|
+
stream.options = {"strict": "experimental"}
|
|
123
|
+
if profile is not None:
|
|
124
|
+
stream.format = profile
|
|
125
|
+
format_to_use = (
|
|
126
|
+
stream.format.name
|
|
127
|
+
if stream.format.name in av.audio.frame.format_dtypes
|
|
128
|
+
else "flt"
|
|
129
|
+
)
|
|
130
|
+
frame = av.audio.frame.AudioFrame.from_ndarray(
|
|
131
|
+
np.zeros( # zeros encoding time faster than empty
|
|
132
|
+
(len(av.audio.layout.AudioLayout(layout).channels), 4800),
|
|
133
|
+
dtype=av.audio.frame.format_dtypes[format_to_use],
|
|
134
|
+
),
|
|
135
|
+
format=format_to_use,
|
|
136
|
+
layout=layout,
|
|
137
|
+
)
|
|
138
|
+
frame.rate = rate or min(av.Codec(encodec, "w").audio_rates or {48000})
|
|
139
|
+
frame.time_base = Fraction(1, frame.rate)
|
|
140
|
+
frame.pts = 0
|
|
141
|
+
container.mux(stream.encode(frame))
|
|
142
|
+
container.mux(stream.encode(None)) # flush buffer
|
|
143
|
+
except (av.error.FFmpegError, ValueError, AttributeError) as err:
|
|
144
|
+
raise EncodeError(f"failed to encode {file}") from err
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _encode_video(
|
|
148
|
+
file: typing.Union[str, io.BytesIO],
|
|
149
|
+
encodec: str,
|
|
150
|
+
muxer: str,
|
|
151
|
+
**kwargs,
|
|
152
|
+
) -> None:
|
|
153
|
+
"""Test the encoder capability with the null muxer in a virtual file.
|
|
154
|
+
|
|
155
|
+
Parameters
|
|
156
|
+
----------
|
|
157
|
+
file : str
|
|
158
|
+
The full path a the file to write or the io.BytesIO filelike.
|
|
159
|
+
encodec : str
|
|
160
|
+
The codec or the encoder name.
|
|
161
|
+
muxer : str
|
|
162
|
+
The format name.
|
|
163
|
+
shape : tuple[int, int]
|
|
164
|
+
The shape of the frames of the encoded video.
|
|
165
|
+
rate : Fraction, optional
|
|
166
|
+
The frame rate.
|
|
167
|
+
pix_fmt : str, optional
|
|
168
|
+
The name of the pixel format used.
|
|
169
|
+
|
|
170
|
+
Raises
|
|
171
|
+
------
|
|
172
|
+
EncodeError
|
|
173
|
+
If reading failed.
|
|
174
|
+
|
|
175
|
+
Notes
|
|
176
|
+
-----
|
|
177
|
+
No verifications are performed because it is a subfunction.
|
|
178
|
+
"""
|
|
179
|
+
shape, rate, pix_fmt = kwargs["shape"], kwargs.get("rate", None), kwargs.get("pix_fmt", None)
|
|
180
|
+
os.environ["PYAV_LOGGING"] = "off"
|
|
181
|
+
try:
|
|
182
|
+
with av.open(file, mode="w", format=muxer) as container:
|
|
183
|
+
stream = container.add_stream(encodec, rate=rate, height=shape[0], width=shape[1])
|
|
184
|
+
stream.options = {
|
|
185
|
+
"strict": "experimental", # to allow new codecs
|
|
186
|
+
"x265-params": "log_level=none", # to make libx265 quiet
|
|
187
|
+
}
|
|
188
|
+
if encodec == "libsvtav1":
|
|
189
|
+
os.environ["SVT_LOG"] = "1" # to make libsvtav1 quiet
|
|
190
|
+
stream.pix_fmt = (
|
|
191
|
+
pix_fmt or max(
|
|
192
|
+
(av.Codec(encodec, "w").video_formats or (av.VideoFormat("yuv420p"),)),
|
|
193
|
+
key=lambda f: f.bits_per_pixel
|
|
194
|
+
).name
|
|
195
|
+
)
|
|
196
|
+
for i in range(3): # nbr frames
|
|
197
|
+
frame = av.video.frame.VideoFrame.from_ndarray(
|
|
198
|
+
np.zeros((*shape, 3), dtype=np.uint8), format="bgr24"
|
|
199
|
+
)
|
|
200
|
+
frame.time_base = Fraction(1, 300300) # ppcm 1001, 1000, 25, 30, 60
|
|
201
|
+
frame.pts = round(
|
|
202
|
+
(i / (rate or stream.average_rate or Fraction(30000, 1001)))
|
|
203
|
+
/ frame.time_base
|
|
204
|
+
)
|
|
205
|
+
container.mux(stream.encode(frame))
|
|
206
|
+
container.mux(stream.encode(None)) # flush buffer
|
|
207
|
+
except (av.error.FFmpegError, ValueError, AttributeError) as err:
|
|
208
|
+
raise EncodeError(f"failed to encode {file}") from err
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def audio_encodec_compatibility(
|
|
212
|
+
encodec: str,
|
|
213
|
+
muxer: str,
|
|
214
|
+
layout: str = "mono",
|
|
215
|
+
rate: typing.Optional[int] = None,
|
|
216
|
+
profile: typing.Optional[str] = None,
|
|
217
|
+
) -> str:
|
|
218
|
+
"""Test throw av the compatibility of the encoding audio parameters.
|
|
219
|
+
|
|
220
|
+
Parameters
|
|
221
|
+
----------
|
|
222
|
+
encodec : str
|
|
223
|
+
The codec or the encoder name.
|
|
224
|
+
muxer : str
|
|
225
|
+
The format name.
|
|
226
|
+
layout : str, default="mono"
|
|
227
|
+
The name of the audio layout, ex "stereo"
|
|
228
|
+
rate : int, optional
|
|
229
|
+
The samplerate of the audio in all channels.
|
|
230
|
+
profile : str, optional
|
|
231
|
+
The name of the binary format of the data ex "flt".
|
|
232
|
+
|
|
233
|
+
Returns
|
|
234
|
+
-------
|
|
235
|
+
codec : str
|
|
236
|
+
The name of the codec found.
|
|
237
|
+
|
|
238
|
+
Raises
|
|
239
|
+
------
|
|
240
|
+
IncompatibleSettings
|
|
241
|
+
If it fails to encode or if the decoded parameters don't matched.
|
|
242
|
+
|
|
243
|
+
Examples
|
|
244
|
+
--------
|
|
245
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import audio_encodec_compatibility
|
|
246
|
+
>>> audio_encodec_compatibility("libvorbis", "ogg")
|
|
247
|
+
'vorbis'
|
|
248
|
+
>>>
|
|
249
|
+
"""
|
|
250
|
+
assert isinstance(muxer, str), muxer.__class__.__name__
|
|
251
|
+
assert isinstance(encodec, str), encodec.__class__.__name__
|
|
252
|
+
assert isinstance(layout, str), layout.__class__.__name__
|
|
253
|
+
assert rate is None or isinstance(rate, int), rate.__class__.__name__
|
|
254
|
+
assert profile is None or isinstance(profile, str), profile.__class__.__name__
|
|
255
|
+
|
|
256
|
+
# theorical verifications
|
|
257
|
+
codec_av = av.Codec(encodec, "w")
|
|
258
|
+
if codec_av.type != "audio":
|
|
259
|
+
raise IncompatibleSettings(f"the codec {encodec} is {codec_av.type}, not audio")
|
|
260
|
+
if (
|
|
261
|
+
rate is not None and codec_av.audio_rates is not None
|
|
262
|
+
and rate not in codec_av.audio_rates
|
|
263
|
+
):
|
|
264
|
+
raise IncompatibleSettings(
|
|
265
|
+
f"the codec {encodec} dose not support {rate} Hz, only {codec_av.audio_rates}"
|
|
266
|
+
)
|
|
267
|
+
if (
|
|
268
|
+
profile is not None and codec_av.audio_formats is not None
|
|
269
|
+
and profile not in {p.name for p in codec_av.audio_formats}
|
|
270
|
+
):
|
|
271
|
+
raise IncompatibleSettings(f"the codec {encodec} dose not support {profile} profile")
|
|
272
|
+
|
|
273
|
+
# prepare context
|
|
274
|
+
properties = {}
|
|
275
|
+
|
|
276
|
+
try:
|
|
277
|
+
with io.BytesIO() as file:
|
|
278
|
+
file.name = os.devnull
|
|
279
|
+
_encode_audio(file, encodec, muxer, layout=layout, rate=rate, profile=profile)
|
|
280
|
+
file.seek(0)
|
|
281
|
+
properties = _decode(file, muxer)
|
|
282
|
+
except (EncodeError, DecodeError) as err:
|
|
283
|
+
raise IncompatibleSettings("failed to encode or decode") from err
|
|
284
|
+
for ref_name, ref_val in [
|
|
285
|
+
("type", "audio"),
|
|
286
|
+
("muxer", muxer),
|
|
287
|
+
("layout", layout),
|
|
288
|
+
("rate", rate),
|
|
289
|
+
("profile", profile),
|
|
290
|
+
]:
|
|
291
|
+
if ref_val is not None and ref_val != properties[ref_name]:
|
|
292
|
+
raise IncompatibleSettings(
|
|
293
|
+
f"encoded {ref_name} {ref_val} but decoded with {properties[ref_name]}"
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
return properties["codec"]
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def video_encodec_compatibility(
|
|
300
|
+
encodec: str,
|
|
301
|
+
muxer: str,
|
|
302
|
+
shape: typing.Optional[tuple[int, int]] = None,
|
|
303
|
+
rate: typing.Optional[Fraction] = None,
|
|
304
|
+
pix_fmt: typing.Optional[str] = None,
|
|
305
|
+
) -> str:
|
|
306
|
+
"""Test throw av the compatibility of the encoding video parameters.
|
|
307
|
+
|
|
308
|
+
Parameters
|
|
309
|
+
----------
|
|
310
|
+
encodec : str
|
|
311
|
+
The codec or the encoder name.
|
|
312
|
+
muxer : str
|
|
313
|
+
The format name.
|
|
314
|
+
shape : tuple[int, int], optional
|
|
315
|
+
The shape of the frames of the encoded video.
|
|
316
|
+
rate : Fraction, optional
|
|
317
|
+
The frame rate.
|
|
318
|
+
pix_fmt : str, optional
|
|
319
|
+
The name of the pixel format used.
|
|
320
|
+
|
|
321
|
+
Returns
|
|
322
|
+
-------
|
|
323
|
+
codec : str
|
|
324
|
+
The name of the codec found.
|
|
325
|
+
|
|
326
|
+
Raises
|
|
327
|
+
------
|
|
328
|
+
IncompatibleSettings
|
|
329
|
+
If it fails to encode or if the decoded parameters don't matched.
|
|
330
|
+
|
|
331
|
+
Examples
|
|
332
|
+
--------
|
|
333
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import video_encodec_compatibility
|
|
334
|
+
>>> video_encodec_compatibility("libx264", "mp4")
|
|
335
|
+
'h264'
|
|
336
|
+
>>>
|
|
337
|
+
"""
|
|
338
|
+
assert isinstance(muxer, str), muxer.__class__.__name__
|
|
339
|
+
assert isinstance(encodec, str), encodec.__class__.__name__
|
|
340
|
+
shape = shape or (64, 64)
|
|
341
|
+
assert isinstance(shape, tuple), shape.__class__.__name__
|
|
342
|
+
assert len(shape) == 2, shape
|
|
343
|
+
assert isinstance(shape[0], int), shape[0].__class__.__name__
|
|
344
|
+
assert isinstance(shape[1], int), shape[1].__class__.__name__
|
|
345
|
+
assert rate is None or isinstance(rate, Fraction), rate.__class__.__name__
|
|
346
|
+
assert pix_fmt is None or isinstance(pix_fmt, str), pix_fmt.__class__.__name__
|
|
347
|
+
|
|
348
|
+
# theorical verifications
|
|
349
|
+
codec_av = av.Codec(encodec, "w")
|
|
350
|
+
if codec_av.type != "video":
|
|
351
|
+
raise IncompatibleSettings(f"the codec {encodec} is {codec_av.type}, not video")
|
|
352
|
+
try:
|
|
353
|
+
if (
|
|
354
|
+
rate is not None and codec_av.frame_rates is not None
|
|
355
|
+
and rate not in codec_av.frame_rates
|
|
356
|
+
):
|
|
357
|
+
raise IncompatibleSettings(
|
|
358
|
+
f"the codec {encodec} dose not support {rate} fps, only {codec_av.frame_rates}"
|
|
359
|
+
)
|
|
360
|
+
except AttributeError: # failed sometimes in ``codec_av.frame_rates``
|
|
361
|
+
pass
|
|
362
|
+
if (
|
|
363
|
+
pix_fmt is not None and codec_av.video_formats is not None
|
|
364
|
+
and pix_fmt not in {f.name for f in codec_av.video_formats}
|
|
365
|
+
):
|
|
366
|
+
raise IncompatibleSettings(f"the codec {encodec} dose not support {pix_fmt} pixel format")
|
|
367
|
+
|
|
368
|
+
# prepare context
|
|
369
|
+
properties = {}
|
|
370
|
+
|
|
371
|
+
try:
|
|
372
|
+
with io.BytesIO() as file:
|
|
373
|
+
file.name = os.devnull
|
|
374
|
+
_encode_video(file, encodec, muxer, shape=shape, rate=rate, pix_fmt=pix_fmt)
|
|
375
|
+
file.seek(0)
|
|
376
|
+
properties = _decode(file, muxer)
|
|
377
|
+
except (EncodeError, DecodeError) as err:
|
|
378
|
+
raise IncompatibleSettings("failed to encode") from err
|
|
379
|
+
for ref_name, ref_val in [
|
|
380
|
+
("type", "video"),
|
|
381
|
+
("muxer", muxer),
|
|
382
|
+
("profile", pix_fmt),
|
|
383
|
+
("rate", rate),
|
|
384
|
+
("shape", shape),
|
|
385
|
+
]:
|
|
386
|
+
if ref_val is not None and ref_val != properties[ref_name]:
|
|
387
|
+
raise IncompatibleSettings(
|
|
388
|
+
f"encoded {ref_name} {ref_val} but decoded with {properties[ref_name]}"
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
return properties["codec"]
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
class Compatibilities(metaclass=MetaSingleton):
|
|
395
|
+
"""Link the muxers and the encoders."""
|
|
396
|
+
|
|
397
|
+
def __init__(self):
|
|
398
|
+
self._compatibilites = {}
|
|
399
|
+
|
|
400
|
+
@staticmethod
|
|
401
|
+
def _check_mono(enc_mux_spec: tuple[str, str, tuple[tuple[str, ...], tuple]]) -> str:
|
|
402
|
+
"""Test if the encodec is compatible with the given specifications.
|
|
403
|
+
|
|
404
|
+
It is process and thread safe.
|
|
405
|
+
"""
|
|
406
|
+
encoder, muxer, specifications = enc_mux_spec
|
|
407
|
+
kwargs = dict(zip(*specifications))
|
|
408
|
+
kind: str = Encoder(encoder).type
|
|
409
|
+
if (checker := {
|
|
410
|
+
"audio": audio_encodec_compatibility,
|
|
411
|
+
"video": video_encodec_compatibility,
|
|
412
|
+
}.get(kind, None)) is None:
|
|
413
|
+
raise NotImplementedError(f"only available for audio and video, not for {kind}")
|
|
414
|
+
with contextlib.redirect_stdout(None), contextlib.redirect_stderr(None): # quiet
|
|
415
|
+
try:
|
|
416
|
+
codec: str = checker(encoder, muxer, **kwargs)
|
|
417
|
+
except IncompatibleSettings:
|
|
418
|
+
return ""
|
|
419
|
+
return codec
|
|
420
|
+
|
|
421
|
+
def check(self, encoders: list[str], muxers: list[str], **kwargs) -> np.ndarray[str]:
|
|
422
|
+
"""Check all the couples encoder/muxer (cartesian product).
|
|
423
|
+
|
|
424
|
+
Parameters
|
|
425
|
+
----------
|
|
426
|
+
encoders : list[str]
|
|
427
|
+
The encoder names.
|
|
428
|
+
muxers : list[str]
|
|
429
|
+
The muxer (format) names.
|
|
430
|
+
**kwargs : dict
|
|
431
|
+
The optionals named parameters of
|
|
432
|
+
``cutcutcodec.core.compilation.export.compatibility.audio_encodec_compatibility``
|
|
433
|
+
and ``cutcutcodec.core.compilation.export.compatibility.video_encodec_compatibility``.
|
|
434
|
+
|
|
435
|
+
Returns
|
|
436
|
+
-------
|
|
437
|
+
compatibility_matrix : np.ndarray[str]
|
|
438
|
+
The 2d boolean compatibility matrix.
|
|
439
|
+
Item (i, j) contains the codec name of the encoder[i] with the muxer[j].
|
|
440
|
+
|
|
441
|
+
Examples
|
|
442
|
+
--------
|
|
443
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
444
|
+
>>> Compatibilities().check(["libx264", "libaom-av1", "libvorbis"], ["mp4", "ogg"])
|
|
445
|
+
array([['h264', ''],
|
|
446
|
+
['libdav1d', ''],
|
|
447
|
+
['vorbis', 'vorbis']], dtype='<U8')
|
|
448
|
+
>>> Compatibilities().check([], [])
|
|
449
|
+
array([], shape=(1, 0), dtype='<U1')
|
|
450
|
+
>>> Compatibilities().check(["libx264"], [])
|
|
451
|
+
array([], shape=(1, 0), dtype='<U1')
|
|
452
|
+
>>> Compatibilities().check([], ["mp4"])
|
|
453
|
+
array([], shape=(1, 0), dtype='<U1')
|
|
454
|
+
>>>
|
|
455
|
+
"""
|
|
456
|
+
assert isinstance(encoders, list), encoders.__class__.__name__
|
|
457
|
+
assert all(isinstance(ec, str) for ec in encoders), encoders
|
|
458
|
+
assert set(encoders).issubset(AllEncoders().set), set(encoders)-AllEncoders().set
|
|
459
|
+
assert isinstance(muxers, list), muxers.__class__.__name__
|
|
460
|
+
assert all(isinstance(f, str) for f in muxers), muxers
|
|
461
|
+
assert set(muxers).issubset(AllMuxers().set), set(muxers)-AllMuxers().set
|
|
462
|
+
|
|
463
|
+
# case empty:
|
|
464
|
+
if len(encoders) == 0 or len(muxers) == 0:
|
|
465
|
+
return np.asarray([[]], dtype=str) # oblige for keep 2d array homogeneous
|
|
466
|
+
|
|
467
|
+
# makes checks
|
|
468
|
+
signature = tuple(sorted(kwargs))
|
|
469
|
+
signature = (signature, tuple(kwargs[k] for k in signature))
|
|
470
|
+
if (all_enc_mux_spec := [ # iter over encoder first, muxer second (same aim as shuffle)
|
|
471
|
+
(me[1], me[0], signature) for me in itertools.product(muxers, encoders)
|
|
472
|
+
if (me[1], me[0], signature) not in self._compatibilites
|
|
473
|
+
]): # reduce the number of tests to the minimum for optimisation
|
|
474
|
+
# maxtasksperchild != None for memory leak and != 1 for fork efficiency (granularity)
|
|
475
|
+
with multiprocessing.Pool(maxtasksperchild=64) as pool:
|
|
476
|
+
for enc_mux_spec, is_compatible in tqdm.tqdm(
|
|
477
|
+
zip(
|
|
478
|
+
all_enc_mux_spec,
|
|
479
|
+
pool.imap(
|
|
480
|
+
Compatibilities._check_mono,
|
|
481
|
+
all_enc_mux_spec,
|
|
482
|
+
chunksize=4,
|
|
483
|
+
),
|
|
484
|
+
# map(Compatibilities._check_mono, all_enc_mux_spec), # for debug only
|
|
485
|
+
),
|
|
486
|
+
total=len(all_enc_mux_spec),
|
|
487
|
+
desc="Testing encoder/muxer",
|
|
488
|
+
dynamic_ncols=True,
|
|
489
|
+
disable=(len(all_enc_mux_spec) <= 4*os.cpu_count()),
|
|
490
|
+
smoothing=0.1,
|
|
491
|
+
unit="comb",
|
|
492
|
+
):
|
|
493
|
+
self._compatibilites[enc_mux_spec] = is_compatible
|
|
494
|
+
|
|
495
|
+
# create matrix
|
|
496
|
+
return np.asarray(
|
|
497
|
+
[
|
|
498
|
+
[self._compatibilites[(encoder, muxer, signature)] for muxer in muxers]
|
|
499
|
+
for encoder in encoders
|
|
500
|
+
],
|
|
501
|
+
dtype=str,
|
|
502
|
+
)
|
|
503
|
+
|
|
504
|
+
def codecs_audio(
|
|
505
|
+
self, muxers: typing.Optional[list[str]] = None, **kwargs
|
|
506
|
+
) -> dict[str, list[tuple[str, str]]]:
|
|
507
|
+
"""Search all the compatibles audio codecs.
|
|
508
|
+
|
|
509
|
+
Parameters
|
|
510
|
+
----------
|
|
511
|
+
muxers : list[str]
|
|
512
|
+
The muxer (format) names.
|
|
513
|
+
**kwargs : dict
|
|
514
|
+
The optionals named parameters of
|
|
515
|
+
``cutcutcodec.core.compilation.export.compatibility.audio_encodec_compatibility``.
|
|
516
|
+
|
|
517
|
+
Returns
|
|
518
|
+
-------
|
|
519
|
+
codecs : dict[str, list[tuple[str, str]]]
|
|
520
|
+
For all audio codec, associate the encoder/muxer pairs.
|
|
521
|
+
|
|
522
|
+
Examples
|
|
523
|
+
--------
|
|
524
|
+
>>> from pprint import pprint
|
|
525
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
526
|
+
>>> pprint(Compatibilities().codecs_audio(layout="5.1")) # doctest: +ELLIPSIS
|
|
527
|
+
{'aac': [('aac', '3g2'),
|
|
528
|
+
('aac', '3gp'),
|
|
529
|
+
('aac', 'adts'),
|
|
530
|
+
...
|
|
531
|
+
('aac', 'w64'),
|
|
532
|
+
('aac', 'wav'),
|
|
533
|
+
('aac', 'wtv')],
|
|
534
|
+
...
|
|
535
|
+
'wavpack': [('wavpack', 'matroska'),
|
|
536
|
+
...
|
|
537
|
+
('wavpack', 'wv')]}
|
|
538
|
+
>>>
|
|
539
|
+
"""
|
|
540
|
+
encoders = sorted(AllEncoders().audio) # sorted, not list because dict is sorted
|
|
541
|
+
if muxers is None:
|
|
542
|
+
muxers = sorted(AllMuxers().set) # sorted, not list because dict is sorted
|
|
543
|
+
else:
|
|
544
|
+
assert isinstance(muxers, list), muxers.__class__.__name__
|
|
545
|
+
assert all(isinstance(m, str) for m in muxers), muxers
|
|
546
|
+
comp = self.check(encoders, muxers, **kwargs)
|
|
547
|
+
codecs = {}
|
|
548
|
+
for encoder, decoded_codecs in zip(encoders, comp):
|
|
549
|
+
for muxer, codec in zip(muxers, decoded_codecs):
|
|
550
|
+
if codec:
|
|
551
|
+
codecs[codec] = codecs.get(codec, [])
|
|
552
|
+
codecs[codec].append((encoder, muxer))
|
|
553
|
+
return codecs
|
|
554
|
+
|
|
555
|
+
def codecs_video(
|
|
556
|
+
self, muxers: typing.Optional[list[str]] = None, **kwargs
|
|
557
|
+
) -> dict[str, list[tuple[str, str]]]:
|
|
558
|
+
"""Search all the compatibles video codecs.
|
|
559
|
+
|
|
560
|
+
Parameters
|
|
561
|
+
----------
|
|
562
|
+
muxers : list[str]
|
|
563
|
+
The muxer (format) names.
|
|
564
|
+
**kwargs : dict
|
|
565
|
+
The optionals named parameters of
|
|
566
|
+
``cutcutcodec.core.compilation.export.compatibility.video_encodec_compatibility``.
|
|
567
|
+
|
|
568
|
+
Returns
|
|
569
|
+
-------
|
|
570
|
+
codecs : dict[str, list[tuple[str, str]]]
|
|
571
|
+
For all video codec, associate the encoder/muxer pairs.
|
|
572
|
+
|
|
573
|
+
Examples
|
|
574
|
+
--------
|
|
575
|
+
>>> from fractions import Fraction
|
|
576
|
+
>>> from pprint import pprint
|
|
577
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
578
|
+
>>> pprint(
|
|
579
|
+
... Compatibilities().codecs_video(pix_fmt="yuv444p12le", rate=Fraction(120))
|
|
580
|
+
... ) # doctest: +ELLIPSIS
|
|
581
|
+
{'dirac': [('vc2', 'avi'),
|
|
582
|
+
...
|
|
583
|
+
('vc2', 'wtv')],
|
|
584
|
+
...
|
|
585
|
+
'vp9': [('libvpx-vp9', 'avi'),
|
|
586
|
+
...
|
|
587
|
+
('libvpx-vp9', 'webm')]}
|
|
588
|
+
>>>
|
|
589
|
+
"""
|
|
590
|
+
encoders = sorted(AllEncoders().video) # sorted, not list because dict is sorted
|
|
591
|
+
if muxers is None:
|
|
592
|
+
muxers = sorted(AllMuxers().set) # sorted, not list because dict is sorted
|
|
593
|
+
else:
|
|
594
|
+
assert isinstance(muxers, list), muxers.__class__.__name__
|
|
595
|
+
assert all(isinstance(m, str) for m in muxers), muxers
|
|
596
|
+
comp = self.check(encoders, muxers, **kwargs)
|
|
597
|
+
codecs = {}
|
|
598
|
+
for encoder, decoded_codecs in zip(encoders, comp):
|
|
599
|
+
for muxer, codec in zip(muxers, decoded_codecs):
|
|
600
|
+
if codec:
|
|
601
|
+
codecs[codec] = codecs.get(codec, [])
|
|
602
|
+
codecs[codec].append((encoder, muxer))
|
|
603
|
+
return codecs
|
|
604
|
+
|
|
605
|
+
def encoders_audio(
|
|
606
|
+
self, codec: str, muxers: typing.Optional[list[str]] = None, **kwargs
|
|
607
|
+
) -> dict[str, set[str]]:
|
|
608
|
+
"""Search all the compatible audio encoders.
|
|
609
|
+
|
|
610
|
+
Parameters
|
|
611
|
+
----------
|
|
612
|
+
codec : str
|
|
613
|
+
The audio codec name.
|
|
614
|
+
muxers : list[str]
|
|
615
|
+
The muxer (format) names.
|
|
616
|
+
**kwargs : dict
|
|
617
|
+
The optionals named parameters of
|
|
618
|
+
``cutcutcodec.core.compilation.export.compatibility.audio_encodec_compatibility``.
|
|
619
|
+
|
|
620
|
+
Returns
|
|
621
|
+
-------
|
|
622
|
+
encoders : dict[str, set[str]]
|
|
623
|
+
For all audio encoder, associate the available muxers.
|
|
624
|
+
|
|
625
|
+
Examples
|
|
626
|
+
--------
|
|
627
|
+
>>> from pprint import pprint
|
|
628
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
629
|
+
>>> pprint(Compatibilities().encoders_audio("vorbis", layout="5.1")) # doctest: +ELLIPSIS
|
|
630
|
+
{'libvorbis': {'asf',
|
|
631
|
+
...
|
|
632
|
+
'wtv'}}
|
|
633
|
+
>>>
|
|
634
|
+
"""
|
|
635
|
+
assert isinstance(codec, str), codec.__class__.__name__
|
|
636
|
+
if muxers is None:
|
|
637
|
+
muxers = sorted(AllMuxers().set) # sorted, not list because dict is sorted
|
|
638
|
+
else:
|
|
639
|
+
assert isinstance(muxers, list), muxers.__class__.__name__
|
|
640
|
+
assert all(isinstance(m, str) for m in muxers), muxers
|
|
641
|
+
encoders = sorted(AllEncoders().audio) # sorted, not list because dict is sorted
|
|
642
|
+
comp = self.check(encoders, muxers, **kwargs)
|
|
643
|
+
compatible_encoders = {}
|
|
644
|
+
for encoder, decoded_codecs in zip(encoders, comp):
|
|
645
|
+
for muxer, decoded_codec in zip(muxers, decoded_codecs):
|
|
646
|
+
if decoded_codec == codec:
|
|
647
|
+
compatible_encoders[encoder] = compatible_encoders.get(encoder, set())
|
|
648
|
+
compatible_encoders[encoder].add(muxer)
|
|
649
|
+
return compatible_encoders
|
|
650
|
+
|
|
651
|
+
def encoders_video(
|
|
652
|
+
self, codec: str, muxers: typing.Optional[list[str]] = None, **kwargs
|
|
653
|
+
) -> dict[str, set[str]]:
|
|
654
|
+
"""Search all the compatible video encoders.
|
|
655
|
+
|
|
656
|
+
Parameters
|
|
657
|
+
----------
|
|
658
|
+
codec : str
|
|
659
|
+
The video codec name.
|
|
660
|
+
muxers : list[str]
|
|
661
|
+
The muxer (format) names.
|
|
662
|
+
**kwargs : dict
|
|
663
|
+
The optionals named parameters of
|
|
664
|
+
``cutcutcodec.core.compilation.export.compatibility.video_encodec_compatibility``.
|
|
665
|
+
|
|
666
|
+
Returns
|
|
667
|
+
-------
|
|
668
|
+
encoders : dict[str, set[str]]
|
|
669
|
+
For all video encoder, associate the available muxers.
|
|
670
|
+
|
|
671
|
+
Examples
|
|
672
|
+
--------
|
|
673
|
+
>>> from pprint import pprint
|
|
674
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
675
|
+
>>> pprint(
|
|
676
|
+
... Compatibilities().encoders_video("jpeg2000", pix_fmt="yuv420p")
|
|
677
|
+
... ) # doctest: +ELLIPSIS
|
|
678
|
+
{'jpeg2000': {'asf',
|
|
679
|
+
...
|
|
680
|
+
'wtv'},
|
|
681
|
+
'libopenjpeg': {'asf',
|
|
682
|
+
...
|
|
683
|
+
'wtv'}}
|
|
684
|
+
>>>
|
|
685
|
+
"""
|
|
686
|
+
assert isinstance(codec, str), codec.__class__.__name__
|
|
687
|
+
if muxers is None:
|
|
688
|
+
muxers = sorted(AllMuxers().set) # sorted, not list because dict is sorted
|
|
689
|
+
else:
|
|
690
|
+
assert isinstance(muxers, list), muxers.__class__.__name__
|
|
691
|
+
assert all(isinstance(m, str) for m in muxers), muxers
|
|
692
|
+
encoders = sorted(AllEncoders().video) # sorted, not list because dict is sorted
|
|
693
|
+
comp = self.check(encoders, muxers, **kwargs)
|
|
694
|
+
compatible_encoders = {}
|
|
695
|
+
for encoder, decoded_codecs in zip(encoders, comp):
|
|
696
|
+
for muxer, decoded_codec in zip(muxers, decoded_codecs):
|
|
697
|
+
if decoded_codec == codec:
|
|
698
|
+
compatible_encoders[encoder] = compatible_encoders.get(encoder, set())
|
|
699
|
+
compatible_encoders[encoder].add(muxer)
|
|
700
|
+
return compatible_encoders
|
|
701
|
+
|
|
702
|
+
def muxers(self, encoder: str, **kwargs) -> frozenset[str]:
|
|
703
|
+
"""Search all the compatibles muxers.
|
|
704
|
+
|
|
705
|
+
Parameters
|
|
706
|
+
----------
|
|
707
|
+
encoder : str
|
|
708
|
+
The encoder name.
|
|
709
|
+
**kwargs : dict
|
|
710
|
+
The optionals named parameters of
|
|
711
|
+
``cutcutcodec.core.compilation.export.compatibility.Compatibilities.check``.
|
|
712
|
+
|
|
713
|
+
Returns
|
|
714
|
+
-------
|
|
715
|
+
available_muxers : frozenset[str]
|
|
716
|
+
All the available muxers for the given encoder.
|
|
717
|
+
|
|
718
|
+
Examples
|
|
719
|
+
--------
|
|
720
|
+
>>> from pprint import pprint
|
|
721
|
+
>>> from cutcutcodec.core.compilation.export.compatibility import Compatibilities
|
|
722
|
+
>>> pprint(Compatibilities().muxers("libx264")) # doctest: +ELLIPSIS
|
|
723
|
+
frozenset({'3g2',
|
|
724
|
+
'3gp',
|
|
725
|
+
...
|
|
726
|
+
'vob',
|
|
727
|
+
'wtv'})
|
|
728
|
+
>>>
|
|
729
|
+
"""
|
|
730
|
+
assert isinstance(encoder, str), encoder.__class__.__name__
|
|
731
|
+
muxers = sorted(AllMuxers().set) # sorted for repetability
|
|
732
|
+
comp = self.check([encoder], muxers, **kwargs)
|
|
733
|
+
available_muxers = frozenset(m for m, a in zip(muxers, comp[0]) if a)
|
|
734
|
+
return available_muxers
|