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,183 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Backpropagation of the time interval in a node."""
|
|
4
|
+
|
|
5
|
+
from fractions import Fraction
|
|
6
|
+
import math
|
|
7
|
+
import typing
|
|
8
|
+
|
|
9
|
+
from cutcutcodec.core.classes.stream import Stream
|
|
10
|
+
from cutcutcodec.core.filters.audio.add import FilterAudioAdd
|
|
11
|
+
from cutcutcodec.core.filters.audio.delay import FilterAudioDelay
|
|
12
|
+
from cutcutcodec.core.filters.video.add import FilterVideoAdd
|
|
13
|
+
from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
SLICE_ESTIMATORS = {} # to each node stream class, associate the func to find the time translation
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _add_estimator(node_cls: type) -> callable:
|
|
20
|
+
def _add_func(func) -> callable:
|
|
21
|
+
SLICE_ESTIMATORS[node_cls] = func
|
|
22
|
+
return func
|
|
23
|
+
return _add_func
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@_add_estimator(FilterAudioAdd)
|
|
27
|
+
def _slice_filter_audio_add(
|
|
28
|
+
stream: Stream, t_min: Fraction, t_max: typing.Union[Fraction, float]
|
|
29
|
+
) -> tuple[Stream, tuple[Fraction, typing.Union[Fraction, float]]]:
|
|
30
|
+
"""Detect the time propagation into a FilterAudioAdd stream.
|
|
31
|
+
|
|
32
|
+
Examples
|
|
33
|
+
--------
|
|
34
|
+
>>> from fractions import Fraction
|
|
35
|
+
>>> from cutcutcodec.core.analysis.stream.time_backprop import time_backprop
|
|
36
|
+
>>> from cutcutcodec.core.filters.audio.add import FilterAudioAdd
|
|
37
|
+
>>> from cutcutcodec.core.filters.audio.delay import FilterAudioDelay
|
|
38
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
39
|
+
>>>
|
|
40
|
+
>>> (s_audio_0,) = GeneratorAudioNoise(0).out_streams
|
|
41
|
+
>>> (s_audio_1,) = FilterAudioDelay(GeneratorAudioNoise(0).out_streams, 10).out_streams
|
|
42
|
+
>>> (s_add_audio,) = FilterAudioAdd([s_audio_0, s_audio_1]).out_streams
|
|
43
|
+
>>>
|
|
44
|
+
>>> for _, t_min, t_max in time_backprop(s_add_audio, Fraction(5), Fraction(15)):
|
|
45
|
+
... t_min, t_max
|
|
46
|
+
...
|
|
47
|
+
(Fraction(5, 1), Fraction(15, 1))
|
|
48
|
+
(Fraction(10, 1), Fraction(15, 1))
|
|
49
|
+
>>>
|
|
50
|
+
"""
|
|
51
|
+
assert isinstance(stream.node, FilterAudioAdd), stream.node.__class__.__name__
|
|
52
|
+
for in_stream in stream.node.in_streams:
|
|
53
|
+
new_t_min = max(in_stream.beginning, t_min)
|
|
54
|
+
new_t_max = min(in_stream.beginning+in_stream.duration, t_max)
|
|
55
|
+
yield in_stream, new_t_min, new_t_max
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@_add_estimator(FilterVideoAdd)
|
|
59
|
+
def _slice_filter_video_add(
|
|
60
|
+
stream: Stream, t_min: Fraction, t_max: typing.Union[Fraction, float]
|
|
61
|
+
) -> tuple[Stream, tuple[Fraction, typing.Union[Fraction, float]]]:
|
|
62
|
+
"""Detect the time propagation into a FilterVideoAdd stream.
|
|
63
|
+
|
|
64
|
+
Examples
|
|
65
|
+
--------
|
|
66
|
+
>>> from fractions import Fraction
|
|
67
|
+
>>> from cutcutcodec.core.analysis.stream.time_backprop import time_backprop
|
|
68
|
+
>>> from cutcutcodec.core.filters.video.add import FilterVideoAdd
|
|
69
|
+
>>> from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
70
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
71
|
+
>>>
|
|
72
|
+
>>> (s_video_0,) = GeneratorVideoNoise(0).out_streams
|
|
73
|
+
>>> (s_video_1,) = FilterVideoDelay(GeneratorVideoNoise(0).out_streams, 10).out_streams
|
|
74
|
+
>>> (s_add_video,) = FilterVideoAdd([s_video_0, s_video_1]).out_streams
|
|
75
|
+
>>>
|
|
76
|
+
>>> for _, t_min, t_max in time_backprop(s_add_video, Fraction(5), Fraction(15)):
|
|
77
|
+
... t_min, t_max
|
|
78
|
+
...
|
|
79
|
+
(Fraction(5, 1), Fraction(15, 1))
|
|
80
|
+
(Fraction(10, 1), Fraction(15, 1))
|
|
81
|
+
>>>
|
|
82
|
+
"""
|
|
83
|
+
assert isinstance(stream.node, FilterVideoAdd), stream.node.__class__.__name__
|
|
84
|
+
for in_stream in stream.node.in_streams:
|
|
85
|
+
new_t_min = max(in_stream.beginning, t_min)
|
|
86
|
+
new_t_max = min(in_stream.beginning+in_stream.duration, t_max)
|
|
87
|
+
yield in_stream, new_t_min, new_t_max
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@_add_estimator(FilterAudioDelay)
|
|
91
|
+
def _slice_filter_audio_delay(
|
|
92
|
+
stream: Stream, t_min: Fraction, t_max: typing.Union[Fraction, float]
|
|
93
|
+
) -> tuple[Stream, tuple[Fraction, typing.Union[Fraction, float]]]:
|
|
94
|
+
"""Detect the time propagation into a FilterAudioDelay stream.
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
>>> from fractions import Fraction
|
|
99
|
+
>>> from cutcutcodec.core.analysis.stream.time_backprop import time_backprop
|
|
100
|
+
>>> from cutcutcodec.core.filters.audio.delay import FilterAudioDelay
|
|
101
|
+
>>> from cutcutcodec.core.generation.audio.noise import GeneratorAudioNoise
|
|
102
|
+
>>> stream = GeneratorAudioNoise().out_streams[0]
|
|
103
|
+
>>> (s_a,) = FilterAudioDelay([stream], 10).out_streams
|
|
104
|
+
>>> ((stream, t_min, t_max),) = time_backprop(s_a, Fraction(20), Fraction(40))
|
|
105
|
+
>>> stream.type
|
|
106
|
+
'audio'
|
|
107
|
+
>>> t_min
|
|
108
|
+
Fraction(10, 1)
|
|
109
|
+
>>> t_max
|
|
110
|
+
Fraction(30, 1)
|
|
111
|
+
>>>
|
|
112
|
+
"""
|
|
113
|
+
assert isinstance(stream.node, FilterAudioDelay), stream.node.__class__.__name__
|
|
114
|
+
node = stream.node
|
|
115
|
+
yield node.in_streams[stream.index], t_min-node.delay, t_max-node.delay
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@_add_estimator(FilterVideoDelay)
|
|
119
|
+
def _slice_filter_video_delay(
|
|
120
|
+
stream: Stream, t_min: Fraction, t_max: typing.Union[Fraction, float]
|
|
121
|
+
) -> tuple[Stream, tuple[Fraction, typing.Union[Fraction, float]]]:
|
|
122
|
+
"""Detect the time propagation into a FilterVideoDelay stream.
|
|
123
|
+
|
|
124
|
+
Examples
|
|
125
|
+
--------
|
|
126
|
+
>>> from fractions import Fraction
|
|
127
|
+
>>> from cutcutcodec.core.analysis.stream.time_backprop import time_backprop
|
|
128
|
+
>>> from cutcutcodec.core.filters.video.delay import FilterVideoDelay
|
|
129
|
+
>>> from cutcutcodec.core.generation.video.noise import GeneratorVideoNoise
|
|
130
|
+
>>> stream = GeneratorVideoNoise().out_streams[0]
|
|
131
|
+
>>> (s_v,) = FilterVideoDelay([stream], 10).out_streams
|
|
132
|
+
>>> ((stream, t_min, t_max),) = time_backprop(s_v, Fraction(20), Fraction(40))
|
|
133
|
+
>>> stream.type
|
|
134
|
+
'video'
|
|
135
|
+
>>> t_min
|
|
136
|
+
Fraction(10, 1)
|
|
137
|
+
>>> t_max
|
|
138
|
+
Fraction(30, 1)
|
|
139
|
+
>>>
|
|
140
|
+
"""
|
|
141
|
+
assert isinstance(stream.node, FilterVideoDelay), stream.node.__class__.__name__
|
|
142
|
+
node = stream.node
|
|
143
|
+
yield node.in_streams[stream.index], t_min-node.delay, t_max-node.delay
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def time_backprop(
|
|
147
|
+
stream: Stream, t_min: Fraction, t_max: typing.Union[Fraction, float]
|
|
148
|
+
) -> tuple[Stream, tuple[Fraction, typing.Union[Fraction, float]]]:
|
|
149
|
+
"""Match the time slice to the input streams of a node.
|
|
150
|
+
|
|
151
|
+
Helper for ``cutcutcodec.core.compilation.export.time_slice.time_backprop``.
|
|
152
|
+
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
stream : cutcutcodec.core.classes.stream.Stream
|
|
156
|
+
One of the output stream of the node. It can be a stream of any type.
|
|
157
|
+
t_min : Fraction
|
|
158
|
+
The starting included time of decoding the data of the given stream.
|
|
159
|
+
t_max : frctions.Fraction or inf
|
|
160
|
+
The final excluded time of decoding the data of the given stream.
|
|
161
|
+
|
|
162
|
+
Yields
|
|
163
|
+
------
|
|
164
|
+
in_stream : cutcutcodec.core.classes.stream.Stream
|
|
165
|
+
Turn by turn, the input stream of the node given by the stream in argument.
|
|
166
|
+
If the node is a generator, no stream are yields.
|
|
167
|
+
new_t_min : Fraction
|
|
168
|
+
The start time of this slice matching with the given time slice.
|
|
169
|
+
new_t_max : Fraction or inf
|
|
170
|
+
The final time of this slice matching with the given time slice.
|
|
171
|
+
"""
|
|
172
|
+
assert isinstance(stream, Stream), stream.__class__.__name__
|
|
173
|
+
assert isinstance(t_min, Fraction), t_min.__class__.__name__
|
|
174
|
+
assert t_max == math.inf or isinstance(t_max, Fraction), t_max
|
|
175
|
+
|
|
176
|
+
if (estimator := SLICE_ESTIMATORS.get(stream.node.__class__, None)) is not None:
|
|
177
|
+
for in_stream, t_min_, t_max_ in estimator(stream, t_min, t_max):
|
|
178
|
+
if t_min_ < t_max_:
|
|
179
|
+
yield in_stream, t_min_, t_max_
|
|
180
|
+
else:
|
|
181
|
+
if t_min < t_max:
|
|
182
|
+
for in_stream in stream.node.in_streams:
|
|
183
|
+
yield in_stream, t_min, t_max
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Find the duration of a video stream.
|
|
4
|
+
|
|
5
|
+
This allows not only the characteristics of the files but also the tags if there are any.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from fractions import Fraction
|
|
9
|
+
import collections
|
|
10
|
+
import pathlib
|
|
11
|
+
import typing
|
|
12
|
+
|
|
13
|
+
import cv2 # pip install opencv-contrib-python-headless
|
|
14
|
+
|
|
15
|
+
from cutcutcodec.core.analysis._helper_properties import _check_pathexists_index, _mix_and_check
|
|
16
|
+
from cutcutcodec.core.analysis.ffprobe import (_decode_duration_ffmpeg, _estimate_duration_ffmpeg,
|
|
17
|
+
_map_index_rel_to_abs)
|
|
18
|
+
from cutcutcodec.core.exceptions import MissingStreamError, MissingInformation
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _decode_duration_cv2(filename: str, index: int) -> Fraction:
|
|
22
|
+
"""Extract the duration by the complete decoding of the stream.
|
|
23
|
+
|
|
24
|
+
Slow but 100% accurate method.
|
|
25
|
+
|
|
26
|
+
Examples
|
|
27
|
+
--------
|
|
28
|
+
>>> from cutcutcodec.core.analysis.video.properties.duration import _decode_duration_cv2
|
|
29
|
+
>>> _decode_duration_cv2("cutcutcodec/examples/video.mp4", 0)
|
|
30
|
+
Fraction(16, 1)
|
|
31
|
+
>>>
|
|
32
|
+
"""
|
|
33
|
+
cap = cv2.VideoCapture(filename, index)
|
|
34
|
+
if not cap.isOpened():
|
|
35
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
36
|
+
if (fps := Fraction(cap.get(cv2.CAP_PROP_FPS)).limit_denominator(1001)) <= 0:
|
|
37
|
+
one_over_fps = 0
|
|
38
|
+
else:
|
|
39
|
+
one_over_fps = 1 / fps
|
|
40
|
+
duration = Fraction(0)
|
|
41
|
+
while True:
|
|
42
|
+
duration = (
|
|
43
|
+
Fraction(round(cap.get(cv2.CAP_PROP_POS_MSEC))) / 1000
|
|
44
|
+
or duration + one_over_fps
|
|
45
|
+
)
|
|
46
|
+
if not cap.read()[0]:
|
|
47
|
+
break
|
|
48
|
+
cap.release()
|
|
49
|
+
if not duration:
|
|
50
|
+
raise MissingStreamError(f"'cv2' did not find duration '{filename}' stream {index}")
|
|
51
|
+
return duration + one_over_fps
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _estimate_duration_cv2(filename: str, index: int) -> Fraction:
|
|
55
|
+
"""Extract the duration from the metadata.
|
|
56
|
+
|
|
57
|
+
Very fast method but inaccurate. It doesn't work all the time.
|
|
58
|
+
|
|
59
|
+
Examples
|
|
60
|
+
--------
|
|
61
|
+
>>> from cutcutcodec.core.analysis.video.properties.duration import _estimate_duration_cv2
|
|
62
|
+
>>> _estimate_duration_cv2("cutcutcodec/examples/video.mp4", 0)
|
|
63
|
+
Fraction(16, 1)
|
|
64
|
+
>>>
|
|
65
|
+
"""
|
|
66
|
+
cap = cv2.VideoCapture(filename, index)
|
|
67
|
+
if not cap.isOpened():
|
|
68
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
69
|
+
frames = round(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
70
|
+
fps = Fraction(cap.get(cv2.CAP_PROP_FPS)).limit_denominator(1001)
|
|
71
|
+
duration = frames / fps if fps and frames else 0
|
|
72
|
+
cap.release()
|
|
73
|
+
if duration <= 0:
|
|
74
|
+
raise MissingInformation(
|
|
75
|
+
f"'cv2' does not detect any duration in '{filename}' stream {index}"
|
|
76
|
+
)
|
|
77
|
+
return duration
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def get_duration_video(
|
|
81
|
+
filename: typing.Union[str, bytes, pathlib.Path],
|
|
82
|
+
index: int = 0,
|
|
83
|
+
*,
|
|
84
|
+
backend: typing.Union[None, str] = None,
|
|
85
|
+
accurate: bool = False,
|
|
86
|
+
) -> Fraction:
|
|
87
|
+
"""Recovers the total duration of a video stream.
|
|
88
|
+
|
|
89
|
+
The duration includes the display time o the last frame.
|
|
90
|
+
|
|
91
|
+
Parameters
|
|
92
|
+
----------
|
|
93
|
+
filename : pathlike
|
|
94
|
+
The pathlike of the file containing a video stream.
|
|
95
|
+
index : int
|
|
96
|
+
The relative index of the video stream being considered,
|
|
97
|
+
by default the first video stream encountered is selected.
|
|
98
|
+
backend : str, optional
|
|
99
|
+
- None (default) : Try to read the stream by trying differents backends.
|
|
100
|
+
- 'ffmpeg' : Uses the modules ``pip3 install ffmpeg-python``
|
|
101
|
+
which are using the ``ffmpeg`` program in the background.
|
|
102
|
+
- 'cv2' : Uses the module ``pip3 install opencv-contrib-python-headless``.
|
|
103
|
+
accurate : boolean, default=False
|
|
104
|
+
If True, recovers the duration by fully decoding all the frames in the video.
|
|
105
|
+
It is very accurate but very slow. If False (default),
|
|
106
|
+
first tries to get the duration from the file metadata.
|
|
107
|
+
It's not accurate but very fast.
|
|
108
|
+
|
|
109
|
+
Returns
|
|
110
|
+
-------
|
|
111
|
+
duration : Fraction
|
|
112
|
+
The total duration of the considerated video stream.
|
|
113
|
+
|
|
114
|
+
Raises
|
|
115
|
+
------
|
|
116
|
+
MissingStreamError
|
|
117
|
+
If the file does not contain a playable video stream.
|
|
118
|
+
MissingInformation
|
|
119
|
+
If the information is unavailable.
|
|
120
|
+
|
|
121
|
+
Examples
|
|
122
|
+
--------
|
|
123
|
+
>>> from cutcutcodec.core.analysis.video.properties.duration import get_duration_video
|
|
124
|
+
>>> get_duration_video("cutcutcodec/examples/video.mp4")
|
|
125
|
+
Fraction(16, 1)
|
|
126
|
+
>>> get_duration_video("cutcutcodec/examples/intro.webm")
|
|
127
|
+
Fraction(9809, 1000)
|
|
128
|
+
>>>
|
|
129
|
+
"""
|
|
130
|
+
_check_pathexists_index(filename, index)
|
|
131
|
+
|
|
132
|
+
return _mix_and_check(
|
|
133
|
+
backend, accurate, (str(pathlib.Path(filename)), index),
|
|
134
|
+
collections.OrderedDict([
|
|
135
|
+
(
|
|
136
|
+
(
|
|
137
|
+
lambda filename, index: _estimate_duration_ffmpeg(
|
|
138
|
+
filename, _map_index_rel_to_abs(filename, index, "video")
|
|
139
|
+
)
|
|
140
|
+
),
|
|
141
|
+
{"accurate": False, "backend": "ffmpeg"},
|
|
142
|
+
),
|
|
143
|
+
(
|
|
144
|
+
(
|
|
145
|
+
lambda filename, index: _decode_duration_ffmpeg(
|
|
146
|
+
filename, _map_index_rel_to_abs(filename, index, "video"), accurate=False
|
|
147
|
+
)
|
|
148
|
+
),
|
|
149
|
+
{"accurate": False, "backend": "ffmpeg"},
|
|
150
|
+
),
|
|
151
|
+
(_estimate_duration_cv2, {"accurate": False, "backend": "cv2"}),
|
|
152
|
+
(
|
|
153
|
+
(
|
|
154
|
+
lambda filename, index: _decode_duration_ffmpeg(
|
|
155
|
+
filename, _map_index_rel_to_abs(filename, index, "video"), accurate=True
|
|
156
|
+
)
|
|
157
|
+
),
|
|
158
|
+
{"accurate": True, "backend": "ffmpeg"},
|
|
159
|
+
),
|
|
160
|
+
(_decode_duration_cv2, {"accurate": True, "backend": "cv2"}),
|
|
161
|
+
])
|
|
162
|
+
)
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Recover the number of frames in a video stream.
|
|
4
|
+
|
|
5
|
+
This allows not only the characteristics of the files but also the tags if there are any.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import collections
|
|
9
|
+
import pathlib
|
|
10
|
+
import typing
|
|
11
|
+
|
|
12
|
+
import cv2 # pip install opencv-contrib-python-headless
|
|
13
|
+
|
|
14
|
+
from cutcutcodec.core.analysis._helper_properties import _check_pathexists_index, _mix_and_check
|
|
15
|
+
from cutcutcodec.core.analysis.ffprobe import (_estimate_len_ffmpeg, _map_index_rel_to_abs,
|
|
16
|
+
get_slices_metadata)
|
|
17
|
+
from cutcutcodec.core.exceptions import MissingStreamError, MissingInformation
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _count_frames_ffmpeg(filename: str, index: int) -> int:
|
|
21
|
+
"""Count the number of frames with the ffmpeg decoder.
|
|
22
|
+
|
|
23
|
+
Slow but 100% accurate method.
|
|
24
|
+
|
|
25
|
+
Examples
|
|
26
|
+
--------
|
|
27
|
+
>>> from cutcutcodec.core.analysis.video.properties.nb_frames import _count_frames_ffmpeg
|
|
28
|
+
>>> _count_frames_ffmpeg("cutcutcodec/examples/video.mp4", 0)
|
|
29
|
+
400
|
|
30
|
+
>>>
|
|
31
|
+
"""
|
|
32
|
+
_, infos = get_slices_metadata(filename, slice_type="frame")
|
|
33
|
+
if index >= len(infos):
|
|
34
|
+
raise MissingInformation(f"'ffmpeg' did not decode '{filename}' stream {index}")
|
|
35
|
+
frames = infos[index].shape[0]
|
|
36
|
+
return frames
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _count_frames_cv2(filename: str, index: int) -> int:
|
|
40
|
+
"""Count the number of frames with the cv2 decoder.
|
|
41
|
+
|
|
42
|
+
Slow but 100% accurate method.
|
|
43
|
+
|
|
44
|
+
Examples
|
|
45
|
+
--------
|
|
46
|
+
>>> from cutcutcodec.core.analysis.video.properties.nb_frames import _count_frames_cv2
|
|
47
|
+
>>> _count_frames_cv2("cutcutcodec/examples/video.mp4", 0)
|
|
48
|
+
400
|
|
49
|
+
>>>
|
|
50
|
+
"""
|
|
51
|
+
cap = cv2.VideoCapture(filename, index)
|
|
52
|
+
if not cap.isOpened():
|
|
53
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
54
|
+
frames = 0
|
|
55
|
+
while True:
|
|
56
|
+
if not cap.read()[0]:
|
|
57
|
+
break
|
|
58
|
+
frames += 1
|
|
59
|
+
cap.release()
|
|
60
|
+
if not frames:
|
|
61
|
+
raise MissingStreamError(f"'cv2' did not find any frames '{filename}' stream {index}")
|
|
62
|
+
return frames
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _estimate_frames_cv2(filename: str, index: int) -> int:
|
|
66
|
+
"""Extract the number of frames from the metadata.
|
|
67
|
+
|
|
68
|
+
Very fast method but inaccurate. It doesn't work all the time.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
>>> from cutcutcodec.core.analysis.video.properties.nb_frames import _estimate_frames_cv2
|
|
73
|
+
>>> _estimate_frames_cv2("cutcutcodec/examples/video.mp4", 0)
|
|
74
|
+
400
|
|
75
|
+
>>>
|
|
76
|
+
"""
|
|
77
|
+
cap = cv2.VideoCapture(filename, index)
|
|
78
|
+
if not cap.isOpened():
|
|
79
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
80
|
+
frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
81
|
+
cap.release()
|
|
82
|
+
if frames <= 0: # we saw a case at -553402322211286528
|
|
83
|
+
raise MissingInformation(f"'cv2' does not detect any frame in '{filename}' stream {index}")
|
|
84
|
+
return frames
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def get_nb_frames(
|
|
88
|
+
filename: typing.Union[str, bytes, pathlib.Path],
|
|
89
|
+
index: int = 0,
|
|
90
|
+
*,
|
|
91
|
+
backend: typing.Union[None, str] = None,
|
|
92
|
+
accurate: bool = False,
|
|
93
|
+
) -> int:
|
|
94
|
+
"""Recovers the number of frames present in a video stream.
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
filename : pathlike
|
|
99
|
+
The pathlike of the file containing a video stream.
|
|
100
|
+
index : int
|
|
101
|
+
The relative index of the video stream being considered,
|
|
102
|
+
by default the first stream encountered is selected.
|
|
103
|
+
backend : str, optional
|
|
104
|
+
- None (default) : Try to read the stream by trying differents backends.
|
|
105
|
+
- 'ffmpeg' : Uses the modules ``pip3 install ffmpeg-python``
|
|
106
|
+
which are using the ``ffmpeg`` program in the background.
|
|
107
|
+
- 'cv2' : Uses the module ``pip3 install opencv-contrib-python-headless``.
|
|
108
|
+
accurate : boolean, optional
|
|
109
|
+
If True, recovers the number of frames by fully decoding all the frames in the video.
|
|
110
|
+
It is very accurate but very slow. If False (default),
|
|
111
|
+
first tries to get the frame count from the file metadata.
|
|
112
|
+
It's not accurate but very fast.
|
|
113
|
+
|
|
114
|
+
Returns
|
|
115
|
+
-------
|
|
116
|
+
nbr : int
|
|
117
|
+
The number of readed frames.
|
|
118
|
+
|
|
119
|
+
Raises
|
|
120
|
+
------
|
|
121
|
+
MissingStreamError
|
|
122
|
+
If the file does not contain a playable video stream.
|
|
123
|
+
MissingInformation
|
|
124
|
+
If the information is unavailable.
|
|
125
|
+
|
|
126
|
+
Examples
|
|
127
|
+
--------
|
|
128
|
+
>>> from cutcutcodec.core.analysis.video.properties.nb_frames import get_nb_frames
|
|
129
|
+
>>> get_nb_frames("cutcutcodec/examples/video.mp4")
|
|
130
|
+
400
|
|
131
|
+
>>> get_nb_frames("cutcutcodec/examples/intro.webm")
|
|
132
|
+
294
|
|
133
|
+
>>>
|
|
134
|
+
"""
|
|
135
|
+
_check_pathexists_index(filename, index)
|
|
136
|
+
|
|
137
|
+
return _mix_and_check(
|
|
138
|
+
backend, accurate, (str(pathlib.Path(filename)), index),
|
|
139
|
+
collections.OrderedDict([
|
|
140
|
+
(
|
|
141
|
+
(
|
|
142
|
+
lambda filename, index: _estimate_len_ffmpeg(
|
|
143
|
+
filename, _map_index_rel_to_abs(filename, index, "video")
|
|
144
|
+
)
|
|
145
|
+
),
|
|
146
|
+
{"accurate": False, "backend": "ffmpeg"},
|
|
147
|
+
),
|
|
148
|
+
(_estimate_frames_cv2, {"accurate": False, "backend": "cv2"}),
|
|
149
|
+
(
|
|
150
|
+
(
|
|
151
|
+
lambda filename, index: _count_frames_ffmpeg(
|
|
152
|
+
filename, _map_index_rel_to_abs(filename, index, "video")
|
|
153
|
+
)
|
|
154
|
+
),
|
|
155
|
+
{"accurate": True, "backend": "ffmpeg"},
|
|
156
|
+
),
|
|
157
|
+
(_count_frames_cv2, {"accurate": True, "backend": "cv2"}),
|
|
158
|
+
])
|
|
159
|
+
)
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""Find the average frame rate of a video stream.
|
|
4
|
+
|
|
5
|
+
This information is collected in the metadata of the file.
|
|
6
|
+
Its access is fast but its value is not always accurate.
|
|
7
|
+
Especially since the framerate is not always constant within the same stream.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from fractions import Fraction
|
|
11
|
+
import collections
|
|
12
|
+
import pathlib
|
|
13
|
+
import typing
|
|
14
|
+
|
|
15
|
+
import cv2 # pip install opencv-contrib-python-headless
|
|
16
|
+
|
|
17
|
+
from cutcutcodec.core.analysis._helper_properties import _check_pathexists_index, _mix_and_check
|
|
18
|
+
from cutcutcodec.core.analysis.ffprobe import _estimate_rate_ffmpeg
|
|
19
|
+
from cutcutcodec.core.analysis.ffprobe import _map_index_rel_to_abs
|
|
20
|
+
from cutcutcodec.core.exceptions import MissingStreamError, MissingInformation
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _estimate_rate_cv2(filename: str, index: int) -> Fraction:
|
|
24
|
+
"""Retrieve via cv2, the metadata concerning the fps.
|
|
25
|
+
|
|
26
|
+
This function is fast because it reads only the header of the file.
|
|
27
|
+
|
|
28
|
+
Examples
|
|
29
|
+
--------
|
|
30
|
+
>>> from cutcutcodec.core.analysis.video.properties.rate import _estimate_rate_cv2
|
|
31
|
+
>>> _estimate_rate_cv2("cutcutcodec/examples/video.mp4", 0)
|
|
32
|
+
Fraction(25, 1)
|
|
33
|
+
>>>
|
|
34
|
+
"""
|
|
35
|
+
cap = cv2.VideoCapture(filename, index)
|
|
36
|
+
if not cap.isOpened():
|
|
37
|
+
raise MissingStreamError(f"impossible to open '{filename}' stream {index} with 'cv2'")
|
|
38
|
+
fps = Fraction(cap.get(cv2.CAP_PROP_FPS)).limit_denominator(1001)
|
|
39
|
+
cap.release()
|
|
40
|
+
if fps <= 0:
|
|
41
|
+
raise MissingInformation(f"'cv2' finds an fps of {fps} in '{filename}' stream {index}")
|
|
42
|
+
return fps
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def get_rate_video(
|
|
46
|
+
filename: typing.Union[str, bytes, pathlib.Path],
|
|
47
|
+
index: int = 0,
|
|
48
|
+
*,
|
|
49
|
+
backend: typing.Union[None, str] = None
|
|
50
|
+
) -> Fraction:
|
|
51
|
+
"""Read in the metadata, the average frequency of the frames.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
filename : pathlike
|
|
56
|
+
The pathlike of the file containing a video stream.
|
|
57
|
+
index : int
|
|
58
|
+
The relative index of the video stream being considered,
|
|
59
|
+
by default the first stream encountered is selected.
|
|
60
|
+
backend : str, optional
|
|
61
|
+
- None (default) : Try to read the stream by trying differents backends.
|
|
62
|
+
- 'ffmpeg' : Uses the modules ``pip install ffmpeg-python``
|
|
63
|
+
which are using the ``ffmpeg`` program in the background.
|
|
64
|
+
- 'cv2' : Uses the module ``pip install opencv-contrib-python-headless``.
|
|
65
|
+
|
|
66
|
+
Returns
|
|
67
|
+
-------
|
|
68
|
+
fps : Fraction
|
|
69
|
+
The average frequency of the frames in hz.
|
|
70
|
+
|
|
71
|
+
Raises
|
|
72
|
+
------
|
|
73
|
+
MissingStreamError
|
|
74
|
+
If the file does not contain a playable video stream.
|
|
75
|
+
MissingInformation
|
|
76
|
+
If the information is unavailable.
|
|
77
|
+
|
|
78
|
+
Examples
|
|
79
|
+
--------
|
|
80
|
+
>>> from cutcutcodec.core.analysis.video.properties.rate import get_rate_video
|
|
81
|
+
>>> get_rate_video("cutcutcodec/examples/video.mp4")
|
|
82
|
+
Fraction(25, 1)
|
|
83
|
+
>>> get_rate_video("cutcutcodec/examples/intro.webm")
|
|
84
|
+
Fraction(30000, 1001)
|
|
85
|
+
>>>
|
|
86
|
+
"""
|
|
87
|
+
_check_pathexists_index(filename, index)
|
|
88
|
+
|
|
89
|
+
return _mix_and_check(
|
|
90
|
+
backend, False, (str(pathlib.Path(filename)), index),
|
|
91
|
+
collections.OrderedDict([
|
|
92
|
+
(
|
|
93
|
+
(
|
|
94
|
+
lambda filename, index: _estimate_rate_ffmpeg(
|
|
95
|
+
filename, _map_index_rel_to_abs(filename, index, "video")
|
|
96
|
+
)
|
|
97
|
+
),
|
|
98
|
+
{"accurate": False, "backend": "ffmpeg"},
|
|
99
|
+
),
|
|
100
|
+
(_estimate_rate_cv2, {"accurate": False, "backend": "cv2"}),
|
|
101
|
+
])
|
|
102
|
+
)
|