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.

Files changed (233) hide show
  1. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__init__.py +6 -0
  2. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/__main__.py +38 -0
  3. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/c_build.py +33 -0
  4. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/__init__.py +3 -0
  5. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/__init__.py +3 -0
  6. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/_helper_properties.py +52 -0
  7. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/__init__.py +3 -0
  8. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/__init__.py +3 -0
  9. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/audio/properties/duration.py +83 -0
  10. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/ffprobe.py +637 -0
  11. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/__init__.py +3 -0
  12. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/find.py +82 -0
  13. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/graph/time_backprop.py +68 -0
  14. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/__init__.py +3 -0
  15. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_audio.py +239 -0
  16. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/rate_video.py +97 -0
  17. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/shape.py +107 -0
  18. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/stream/time_backprop.py +183 -0
  19. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/__init__.py +3 -0
  20. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/__init__.py +3 -0
  21. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/duration.py +162 -0
  22. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/nb_frames.py +159 -0
  23. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/rate.py +102 -0
  24. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/analysis/video/properties/timestamps.py +194 -0
  25. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/__init__.py +3 -0
  26. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/container.py +40 -0
  27. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/encoder.py +152 -0
  28. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/filter.py +33 -0
  29. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame.py +127 -0
  30. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_audio.py +205 -0
  31. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/frame_video.py +322 -0
  32. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/layout.py +206 -0
  33. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/meta_filter.py +41 -0
  34. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/muxer.py +184 -0
  35. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/node.py +164 -0
  36. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream.py +182 -0
  37. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_audio.py +130 -0
  38. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/classes/stream_video.py +193 -0
  39. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/__init__.py +7 -0
  40. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/ast_to_file.py +125 -0
  41. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/__init__.py +6 -0
  42. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/compatibility.py +734 -0
  43. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/default.py +99 -0
  44. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/encodec.py +40 -0
  45. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/muxer.py +8 -0
  46. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/export/rate.py +133 -0
  47. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_ast.py +477 -0
  48. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_json.py +104 -0
  49. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/graph_to_tree.py +190 -0
  50. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/json_to_graph.py +114 -0
  51. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/parse.py +123 -0
  52. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/__init__.py +15 -0
  53. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/dynamic.py +544 -0
  54. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/lambdify.py +612 -0
  55. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/preprocess.py +698 -0
  56. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/sympy_to_torch/printer.py +926 -0
  57. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/compilation/tree_to_graph.py +168 -0
  58. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/__init__.py +3 -0
  59. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/decision/__init__.py +8 -0
  60. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/__init__.py +3 -0
  61. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/add.py +73 -0
  62. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/edit/operation/remove.py +476 -0
  63. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/exceptions.py +60 -0
  64. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/__init__.py +3 -0
  65. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/__init__.py +3 -0
  66. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/add.py +170 -0
  67. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cat.py +60 -0
  68. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/cut.py +112 -0
  69. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/delay.py +85 -0
  70. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/equation.py +261 -0
  71. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/fir.py +231 -0
  72. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/identity.py +48 -0
  73. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/resample.py +451 -0
  74. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/audio/subclip.py +91 -0
  75. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/cut.py +74 -0
  76. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/__init__.py +3 -0
  77. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/audio_cast.py +208 -0
  78. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/mix/video_cast.py +197 -0
  79. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/subclip.py +53 -0
  80. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/__init__.py +3 -0
  81. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/add.py +331 -0
  82. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cat.py +60 -0
  83. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/cut.py +113 -0
  84. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/delay.py +84 -0
  85. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/equation.py +265 -0
  86. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/identity.py +48 -0
  87. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/pad.py +99 -0
  88. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/filters/video/subclip.py +91 -0
  89. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/__init__.py +3 -0
  90. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/__init__.py +3 -0
  91. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/empty.py +73 -0
  92. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/equation.py +56 -0
  93. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/audio/noise.py +243 -0
  94. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/__init__.py +3 -0
  95. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/c_fractal.cpython-312-x86_64-linux-gnu.so +0 -0
  96. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/empty.py +69 -0
  97. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/equation.py +109 -0
  98. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/__init__.py +3 -0
  99. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/fractal.c +116 -0
  100. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/geometry.py +100 -0
  101. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/fractal/mandelbrot.py +176 -0
  102. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/generation/video/noise.py +112 -0
  103. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/__init__.py +3 -0
  104. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/interfaces/seedable.py +82 -0
  105. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/__init__.py +3 -0
  106. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_ffmpeg.py +904 -0
  107. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/read_svg.py +145 -0
  108. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/scheduler.py +356 -0
  109. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/io/write.py +340 -0
  110. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/__init__.py +3 -0
  111. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/__init__.py +3 -0
  112. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/basic.py +35 -0
  113. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/__init__.py +3 -0
  114. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/clean/graph.py +80 -0
  115. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/__init__.py +3 -0
  116. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/hashes/graph.py +81 -0
  117. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cache/singleton.py +47 -0
  118. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/cuda/__init__.py +3 -0
  119. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/__init__.py +5 -0
  120. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/factor/proba.py +189 -0
  121. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/__init__.py +5 -0
  122. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/generalize/delay_to_fir.py +88 -0
  123. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/graph.py +17 -0
  124. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/__init__.py +3 -0
  125. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/parallel/buffer.py +90 -0
  126. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/core/opti/utils.py +34 -0
  127. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/audio_5.1_narration.oga +0 -0
  128. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/intro.webm +0 -0
  129. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/logo.svg +13 -0
  130. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/project.json +226 -0
  131. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/examples/video.mp4 +0 -0
  132. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__init__.py +8 -0
  133. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/__main__.py +25 -0
  134. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/actions.py +63 -0
  135. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/__init__.py +3 -0
  136. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/app/app.py +248 -0
  137. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/base.py +50 -0
  138. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/__init__.py +3 -0
  139. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/__init__.py +3 -0
  140. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/container_input_ffmpeg.py +90 -0
  141. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_delay.py +9 -0
  142. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_equation.py +45 -0
  143. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_fir.py +58 -0
  144. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_audio_subclip.py +9 -0
  145. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_cut.py +82 -0
  146. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_delay.py +20 -0
  147. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_subclip.py +21 -0
  148. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_delay.py +9 -0
  149. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_equation.py +53 -0
  150. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/filter_video_subclip.py +9 -0
  151. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_equation.py +14 -0
  152. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_audio_noise.py +19 -0
  153. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_equation.py +13 -0
  154. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_mandelbrot.py +60 -0
  155. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/all/generator_video_noise.py +18 -0
  156. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/base.py +99 -0
  157. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/default.py +27 -0
  158. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/documentation.py +47 -0
  159. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/general.py +71 -0
  160. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/interface.py +305 -0
  161. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/loader.py +41 -0
  162. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edit_node_state/main.py +62 -0
  163. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/edition_tabs.py +34 -0
  164. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/__init__.py +3 -0
  165. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/base.py +122 -0
  166. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/filters.py +42 -0
  167. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry/generators.py +42 -0
  168. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/entry_tabs.py +46 -0
  169. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/__init__.py +3 -0
  170. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/_helper.py +54 -0
  171. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/container.py +226 -0
  172. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/doc.py +67 -0
  173. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/encodec.py +289 -0
  174. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/export/main.py +173 -0
  175. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/__init__.py +3 -0
  176. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/edge_properties.py +56 -0
  177. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/main.py +280 -0
  178. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/flowchart/node.py +44 -0
  179. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/main.py +151 -0
  180. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/menu.py +21 -0
  181. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/__init__.py +3 -0
  182. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/audio_settings.py +183 -0
  183. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/main.py +41 -0
  184. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/preferences/video_settings.py +257 -0
  185. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/run.py +71 -0
  186. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/__init__.py +3 -0
  187. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/main.py +30 -0
  188. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/slider.py +286 -0
  189. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/track.py +97 -0
  190. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/timeline/view.py +90 -0
  191. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/toolbar.py +29 -0
  192. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/tools.py +23 -0
  193. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/__init__.py +3 -0
  194. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/audio_player.py +103 -0
  195. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/control.py +96 -0
  196. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/frame_extractor.py +254 -0
  197. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/gui/video_preview/main.py +115 -0
  198. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__init__.py +8 -0
  199. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/__main__.py +27 -0
  200. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/coding_style.py +49 -0
  201. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/generation.py +52 -0
  202. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/install.py +72 -0
  203. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/run.py +58 -0
  204. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/abstract.py +215 -0
  205. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_cast.py +35 -0
  206. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/audio_equation.py +71 -0
  207. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/c_memory.py +132 -0
  208. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compatibility.py +27 -0
  209. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/compile.py +42 -0
  210. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/encoder.py +23 -0
  211. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_cut.py +107 -0
  212. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_delay.py +71 -0
  213. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/filter_empty.py +40 -0
  214. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/fir.py +143 -0
  215. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/hashes.py +23 -0
  216. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/initialisation.py +24 -0
  217. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/muxer.py +22 -0
  218. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/nan_snapshot.py +39 -0
  219. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/read.py +192 -0
  220. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/serialization_equality.py +50 -0
  221. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/snapshot_shape.py +21 -0
  222. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/sympy_to_torch.py +135 -0
  223. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/thread_safe.py +77 -0
  224. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/time_range.py +55 -0
  225. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/video_equation.py +77 -0
  226. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/testing/tests/write.py +95 -0
  227. cutcutcodec-1.0.post3.data/platlib/cutcutcodec/utils.py +40 -0
  228. cutcutcodec-1.0.post3.dist-info/LICENSE +7 -0
  229. cutcutcodec-1.0.post3.dist-info/METADATA +271 -0
  230. cutcutcodec-1.0.post3.dist-info/RECORD +233 -0
  231. cutcutcodec-1.0.post3.dist-info/WHEEL +5 -0
  232. cutcutcodec-1.0.post3.dist-info/entry_points.txt +6 -0
  233. cutcutcodec-1.0.post3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Preference management window."""
4
+
5
+ from qtpy import QtWidgets
6
+
7
+ from cutcutcodec.gui.base import CutcutcodecWidget
8
+ from cutcutcodec.gui.tools import WaitCursor
9
+ from cutcutcodec.gui.preferences.audio_settings import PreferencesAudio
10
+ from cutcutcodec.gui.preferences.video_settings import PreferencesVideo
11
+
12
+
13
+ class PreferencesTabs(CutcutcodecWidget, QtWidgets.QDialog):
14
+ """Groups together the different preference management windows."""
15
+
16
+ def __init__(self, parent):
17
+ super().__init__(parent)
18
+ self._parent = parent
19
+
20
+ self.widgets = []
21
+
22
+ with WaitCursor(self.main_window):
23
+ tabs = QtWidgets.QTabWidget(self)
24
+ for i, stream in enumerate(self.app.tree().in_streams):
25
+ if stream.type == "audio":
26
+ self.widgets.append(PreferencesAudio(self, i))
27
+ elif stream.type == "video":
28
+ self.widgets.append(PreferencesVideo(self, i))
29
+ else:
30
+ raise NotImplementedError(f"not yet supported {stream.type}")
31
+ tabs.addTab(self.widgets[-1], f"Profile Stream {i} ({stream.type})")
32
+
33
+ self.setWindowTitle("Preferences")
34
+ layout = QtWidgets.QVBoxLayout()
35
+ layout.addWidget(tabs)
36
+ self.setLayout(layout)
37
+
38
+ def refresh(self):
39
+ """Update the elements of this widget and child widgets."""
40
+ for sub_window in self.widgets:
41
+ sub_window.refresh()
@@ -0,0 +1,257 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Allow to select the parameters of a video stream."""
4
+
5
+ from fractions import Fraction
6
+ import re
7
+
8
+ from qtpy import QtWidgets
9
+
10
+ from cutcutcodec.core.analysis.stream.shape import optimal_shape_video
11
+ from cutcutcodec.core.compilation.export.rate import suggest_video_rate
12
+ from cutcutcodec.gui.base import CutcutcodecWidget
13
+
14
+
15
+ CLASSICAL_FPS = {
16
+ Fraction(15): "animation",
17
+ Fraction(24000, 1001): "old cinema",
18
+ Fraction(24): "old cinema",
19
+ Fraction(25): "old television",
20
+ Fraction(30000, 1001): "standard",
21
+ Fraction(30): "cinema",
22
+ Fraction(50): "interlaced television",
23
+ Fraction(60000, 1001): "modern television",
24
+ Fraction(60): "computer screen",
25
+ Fraction(120): "human perception threshold",
26
+ Fraction(240): "slow-motion",
27
+ Fraction(300): "slow-motion",
28
+ }
29
+ CLASSICAL_SHAPES = { # numpy convention (height, width)
30
+ (240, 320): "QVGA",
31
+ (240, 426): "240p",
32
+ (360, 480): "",
33
+ (360, 640): "360p",
34
+ (480, 320): "HVGA",
35
+ (480, 640): "VGA",
36
+ (480, 854): "480p",
37
+ (576, 768): "PAL",
38
+ (600, 800): "SVGA",
39
+ (720, 960): "",
40
+ (720, 1280): "720p HD High Definition",
41
+ (768, 1024): "XGA",
42
+ (900, 1200): "",
43
+ (960, 1280): "",
44
+ (1050, 1400): "SXGA",
45
+ (1080, 1920): "1080p FHD Full HD",
46
+ (1200, 1600): "UXGA",
47
+ (1440, 1920): "",
48
+ (1440, 2560): "1440p QHD Quad HD",
49
+ (1536, 2048): "QXGA",
50
+ (1707, 2276): "",
51
+ (1920, 2560): "",
52
+ (2160, 3840): "4K UHD Ultra HD",
53
+ (4320, 7680): "8K Full Ultra HD",
54
+ }
55
+
56
+
57
+ class PreferencesVideo(CutcutcodecWidget, QtWidgets.QWidget):
58
+ """Allow to select the frame rate and the resolution of a video stream."""
59
+
60
+ def __init__(self, parent, index_abs):
61
+ super().__init__(parent)
62
+ self._parent = parent
63
+
64
+ self.widgets = {"fpstext": None, "fpscomb": None, "shapetext": None, "shapecomb": None}
65
+
66
+ tree = self.app.tree()
67
+ self.stream = tree.in_streams[index_abs]
68
+ self.index_rel = None
69
+ for i, stream in enumerate(tree.in_select("video")):
70
+ if stream is self.stream:
71
+ self.index_rel = i
72
+ assert self.index_rel is not None, "the output container has been modified in background"
73
+
74
+ grid_layout = QtWidgets.QGridLayout()
75
+ ref_span = self.init_fps(grid_layout)
76
+ separador = QtWidgets.QFrame()
77
+ separador.setFrameShape(QtWidgets.QFrame.Shape.HLine)
78
+ grid_layout.addWidget(separador, ref_span, 0, 1, 2)
79
+ self.init_shape(grid_layout, ref_span=ref_span+1)
80
+ self.setLayout(grid_layout)
81
+ self.refresh()
82
+
83
+ def _select_fps(self, text: str):
84
+ """From combo box."""
85
+ # decode the fps Fraction or None
86
+ if "automatic" in text:
87
+ fps = None
88
+ elif text == "manual":
89
+ fps = self.best_fps
90
+ else:
91
+ fps = Fraction(max(re.findall(r"\d+/?\d*", text), key=len))
92
+
93
+ # update only if it changed
94
+ if (curr_fps := self.app.export_settings["rates"]["video"][self.index_rel]) is not None:
95
+ curr_fps = Fraction(curr_fps)
96
+ if fps != curr_fps:
97
+ self.app.export_settings["rates"]["video"][self.index_rel] = (
98
+ None if fps is None else str(fps)
99
+ )
100
+ print(f"update fps (stream video {self.index_rel}) to {fps}")
101
+ self.main_window.refresh()
102
+
103
+ def _select_shape(self, text: str):
104
+ """From combo box."""
105
+ # decode the shape (tuple[int, int] or None)
106
+ if "automatic" in text:
107
+ shape = None
108
+ elif text == "manual":
109
+ shape = (
110
+ self.app.export_settings["shapes"][self.index_rel]
111
+ or optimal_shape_video(self.stream)
112
+ or (720, 1080)
113
+ )
114
+ else:
115
+ shape = tuple(map(int, re.findall(r"\d+", text)))[1::-1]
116
+ if len(shape) != 2 or shape[0] <= 0 or shape[1] <= 0:
117
+ self.widgets["shapetext"].setStyleSheet("background:red;")
118
+ return
119
+
120
+ # update only if it changed
121
+ if shape != self.app.export_settings["shapes"][self.index_rel]:
122
+ self.app.export_settings["shapes"][self.index_rel] = shape
123
+ print(f"update shape (stream video {self.index_rel}) to {shape}")
124
+ self.main_window.refresh()
125
+
126
+ def _validate_fps(self):
127
+ """Check that the frame rate is a correct fraction."""
128
+ text = self.widgets["fpstext"].text()
129
+ if re.fullmatch(r"\s*", text):
130
+ self._select_fps("automatic")
131
+ return
132
+ try:
133
+ fps = Fraction(text).limit_denominator(1001)
134
+ except (ValueError, ZeroDivisionError):
135
+ self.widgets["fpstext"].setStyleSheet("background:red;")
136
+ return
137
+ if fps <= 0:
138
+ self.widgets["fpstext"].setStyleSheet("background:red;")
139
+ return
140
+ self._select_fps(str(fps))
141
+
142
+ def _validate_shape(self):
143
+ """Check that the shape is correct."""
144
+ text = self.widgets["shapetext"].text()
145
+ if re.fullmatch(r"\s*", text):
146
+ self._select_shape("automatic")
147
+ return
148
+ self._select_shape(text)
149
+
150
+ @property
151
+ def best_fps(self) -> Fraction:
152
+ """Return the most appropriated frame rate for the current configuration.
153
+
154
+ If the fps is specified by the user, it returns the given fps.
155
+ Otherwise it ask to ``cutcutcodec.core.compilation.export.rate.suggest_video_rate``
156
+ for the best estimation.
157
+ """
158
+ if (fps := self.app.export_settings["rates"]["video"][self.index_rel]) is not None:
159
+ return Fraction(fps)
160
+ return suggest_video_rate(self.stream)
161
+
162
+ def init_fps(self, grid_layout, ref_span=0):
163
+ """Display and allows to modify the framerate."""
164
+ grid_layout.addWidget(QtWidgets.QLabel("Frame Rate (fps):"), ref_span, 0)
165
+ self.widgets["fpstext"] = QtWidgets.QLineEdit()
166
+ self.widgets["fpstext"].editingFinished.connect(self._validate_fps)
167
+ grid_layout.addWidget(self.widgets["fpstext"], ref_span, 1)
168
+ grid_layout.addWidget(QtWidgets.QLabel("Selection:"), ref_span+1, 0)
169
+ self.widgets["fpscomb"] = QtWidgets.QComboBox()
170
+ self.widgets["fpscomb"].textActivated.connect(self._select_fps)
171
+ grid_layout.addWidget(self.widgets["fpscomb"], ref_span+1, 1)
172
+ return ref_span + 2
173
+
174
+ def init_shape(self, grid_layout, ref_span=0):
175
+ """Display and allows to modify the shape of the frames."""
176
+ grid_layout.addWidget(QtWidgets.QLabel("Resolution (width x height):"), ref_span, 0)
177
+ self.widgets["shapetext"] = QtWidgets.QLineEdit()
178
+ self.widgets["shapetext"].editingFinished.connect(self._validate_shape)
179
+ grid_layout.addWidget(self.widgets["shapetext"], ref_span, 1)
180
+ grid_layout.addWidget(QtWidgets.QLabel("Selection:"), ref_span+1, 0)
181
+ self.widgets["shapecomb"] = QtWidgets.QComboBox()
182
+ self.widgets["shapecomb"].textActivated.connect(self._select_shape)
183
+ grid_layout.addWidget(self.widgets["shapecomb"], ref_span+1, 1)
184
+ return ref_span + 2
185
+
186
+ def refresh(self):
187
+ """Update the elements of this widget and child widgets."""
188
+ self.refresh_fps()
189
+ self.refresh_shape()
190
+
191
+ def refresh_fps(self):
192
+ """Refresh the data related to the fps."""
193
+ def format_fps(fps: Fraction) -> str:
194
+ if fps.denominator == 1:
195
+ text = str(fps.numerator)
196
+ else:
197
+ text = f"{float(fps):.2f} = {fps}"
198
+ if CLASSICAL_FPS.get(fps, ""):
199
+ text = f"{text} ({CLASSICAL_FPS[fps]})"
200
+ return text
201
+
202
+ # update combobox items
203
+ self.widgets["fpscomb"].clear()
204
+ self.widgets["fpscomb"].addItem("automatic")
205
+ self.widgets["fpscomb"].addItem("manual")
206
+ self.widgets["fpscomb"].addItems(map(format_fps, sorted(CLASSICAL_FPS)))
207
+
208
+ # select the right combobox item
209
+ if (fps := self.app.export_settings["rates"]["video"][self.index_rel]) is None:
210
+ self.widgets["fpscomb"].setCurrentText("automatic")
211
+ else:
212
+ fps = Fraction(fps)
213
+ if fps in CLASSICAL_FPS:
214
+ self.widgets["fpscomb"].setCurrentText(format_fps(fps))
215
+ else:
216
+ self.widgets["fpscomb"].setCurrentText("manual")
217
+
218
+ # update textbox item
219
+ self.widgets["fpstext"].setPlaceholderText(str(suggest_video_rate(self.stream)))
220
+ if (fps := self.app.export_settings["rates"]["video"][self.index_rel]) is not None:
221
+ self.widgets["fpstext"].setText(fps)
222
+ else:
223
+ self.widgets["fpstext"].setText("")
224
+ self.widgets["fpstext"].setStyleSheet("background:none;")
225
+
226
+ def refresh_shape(self):
227
+ """Refresh the data related to the shape."""
228
+ def format_shape(shape: tuple[int, int]) -> str:
229
+ height, width = shape
230
+ ratio = Fraction(width, height).limit_denominator(20)
231
+ text = f"{width}x{height} {ratio.numerator}:{ratio.denominator}"
232
+ if CLASSICAL_SHAPES.get(shape, ""):
233
+ text = f"{text} ({CLASSICAL_SHAPES[shape]})"
234
+ return text
235
+
236
+ # update combobox items
237
+ self.widgets["shapecomb"].clear()
238
+ self.widgets["shapecomb"].addItem("automatic")
239
+ self.widgets["shapecomb"].addItem("manual")
240
+ self.widgets["shapecomb"].addItems(map(format_shape, sorted(CLASSICAL_SHAPES)))
241
+
242
+ # select the right combobox item
243
+ if (shape := self.app.export_settings["shapes"][self.index_rel]) is None:
244
+ self.widgets["shapecomb"].setCurrentText("automatic")
245
+ elif shape in CLASSICAL_SHAPES:
246
+ self.widgets["shapecomb"].setCurrentText(format_shape(shape))
247
+ else:
248
+ self.widgets["shapecomb"].setCurrentText("manual")
249
+
250
+ # update textbox item
251
+ shape = optimal_shape_video(self.stream) or (720, 1080)
252
+ self.widgets["shapetext"].setPlaceholderText("x".join(map(str, shape[::-1]))) # h*w to w*h
253
+ if (shape := self.app.export_settings["shapes"][self.index_rel]) is not None:
254
+ self.widgets["shapetext"].setText("x".join(map(str, shape[::-1]))) # h*w to w*h
255
+ else:
256
+ self.widgets["shapetext"].setText("")
257
+ self.widgets["shapetext"].setStyleSheet("background:none;")
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Entry point of the GUI."""
4
+
5
+ import multiprocessing
6
+ import pathlib
7
+ import queue
8
+ import signal
9
+ import subprocess
10
+ import sys
11
+ import traceback
12
+ import typing
13
+
14
+ from qtpy import QtWidgets
15
+
16
+ from cutcutcodec.core.opti.graph import optimize
17
+ from cutcutcodec.core.compilation.ast_to_file import ast_to_file
18
+ from cutcutcodec.core.compilation.graph_to_ast import graph_to_ast
19
+ from cutcutcodec.gui.main import MainWindow
20
+
21
+
22
+ def run_gui(project_file: typing.Optional[pathlib.Path], output: multiprocessing.Queue):
23
+ """Start the GUI."""
24
+ app = QtWidgets.QApplication.instance()
25
+ if not app:
26
+ app = QtWidgets.QApplication(sys.argv)
27
+
28
+ # soft ctrl+c management, replace lambda by signal.SIG_DFL for fast closing
29
+ signal.signal(signal.SIGINT, lambda *_: app.quit())
30
+
31
+ # create the window
32
+ window = MainWindow(output)
33
+ if project_file is not None:
34
+ window.open(project_file)
35
+ window.showMaximized()
36
+ window.refresh()
37
+
38
+ # catch and show global exceptions
39
+ def crach_except_hook(exc, value, tb_):
40
+ msg = "".join(traceback.format_exception(exc, value, tb_))
41
+ sys.stderr.write(msg)
42
+ window.crash(msg)
43
+ app.quit()
44
+ sys.excepthook = crach_except_hook
45
+
46
+ app.exec()
47
+
48
+
49
+ def run_gui_pipeline(project_file: typing.Optional[pathlib.Path] = None) -> int:
50
+ """Return the main complete pipeline including gui."""
51
+ output = multiprocessing.Queue()
52
+
53
+ process_gui = multiprocessing.Process(target=run_gui, args=(project_file, output))
54
+ process_gui.start()
55
+ process_gui.join()
56
+
57
+ try:
58
+ res = output.get(False)
59
+ except queue.Empty: # if the gui was prematuraly closed
60
+ return 0
61
+ if res["optimize"]:
62
+ res["graph"] = optimize(res["graph"])
63
+
64
+ # write the file
65
+ filename = res["filename"].with_suffix(".py")
66
+ ast_to_file(graph_to_ast(res["graph"]), filename)
67
+
68
+ if res["excecute"]:
69
+ subprocess.run([sys.executable, str(filename)], check=True)
70
+
71
+ return 0
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Group the tools for the timeline window visualisation."""
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Allow video and audio cronological previews and editing."""
4
+
5
+ from qtpy import QtWidgets
6
+
7
+ from cutcutcodec.gui.base import CutcutcodecWidget
8
+ from cutcutcodec.gui.timeline.slider import Slider
9
+ from cutcutcodec.gui.timeline.view import View
10
+
11
+
12
+ class Timeline(CutcutcodecWidget, QtWidgets.QWidget):
13
+ """Time slider and tracks."""
14
+
15
+ def __init__(self, parent):
16
+ super().__init__(parent)
17
+ self._parent = parent
18
+
19
+ self.slider = Slider(self)
20
+ self.view = View(self)
21
+
22
+ layout = QtWidgets.QVBoxLayout()
23
+ layout.addWidget(self.slider)
24
+ layout.addWidget(self.view)
25
+ self.setLayout(layout)
26
+
27
+ def refresh(self):
28
+ """Update the elements of this widget and child widgets."""
29
+ self.slider.refresh()
30
+ self.view.refresh()
@@ -0,0 +1,286 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """Allow for simple navigation through time."""
4
+
5
+ from fractions import Fraction
6
+ import math
7
+
8
+ from qtpy import QtCore, QtGui, QtWidgets
9
+
10
+ from cutcutcodec.gui.base import CutcutcodecWidget
11
+
12
+
13
+ class QRangeSlider(QtWidgets.QSlider):
14
+ """Like QtWidgets.QSlider with 2 buttons.
15
+
16
+ Based on https://stackoverflow.com/questions/67028200/pyqt5-qslider-two-positions.
17
+ """
18
+
19
+ sliderMoved = QtCore.Signal(int, int)
20
+
21
+ def __init__(self, *args, **kwargs):
22
+ super().__init__(*args, **kwargs)
23
+
24
+ self._low, self._high = self.minimum(), self.maximum()
25
+
26
+ self.pressed_control = QtWidgets.QStyle.SubControl.SC_None
27
+ self.hover_control = QtWidgets.QStyle.SubControl.SC_None
28
+ self.click_offset = 0
29
+ self.active_slider = 0 # 0 for the low, 1 for the high, -1 for both
30
+
31
+ def _pick(self, point):
32
+ if self.orientation() == QtCore.Qt.Orientation.Horizontal:
33
+ return point.x()
34
+ return point.y()
35
+
36
+ def _pixelPosToRangeValue(self, pos):
37
+ opt = QtWidgets.QStyleOptionSlider()
38
+ self.initStyleOption(opt)
39
+ style = QtWidgets.QApplication.style()
40
+
41
+ g_r = style.subControlRect(
42
+ style.ComplexControl.CC_Slider, opt, style.SubControl.SC_SliderGroove, self
43
+ )
44
+ s_r = style.subControlRect(
45
+ style.ComplexControl.CC_Slider, opt, style.SubControl.SC_SliderHandle, self
46
+ )
47
+
48
+ if self.orientation() == QtCore.Qt.Orientation.Horizontal:
49
+ slider_length = s_r.width()
50
+ slider_min = g_r.x()
51
+ slider_max = g_r.right() - slider_length + 1
52
+ else:
53
+ slider_length = s_r.height()
54
+ slider_min = g_r.y()
55
+ slider_max = g_r.bottom() - slider_length + 1
56
+
57
+ return style.sliderValueFromPosition(
58
+ self.minimum(), self.maximum(), pos-slider_min, slider_max-slider_min, opt.upsideDown
59
+ )
60
+
61
+ def low(self):
62
+ """Return the low position."""
63
+ return self._low
64
+
65
+ def setLow(self, low: int):
66
+ """Update the low position."""
67
+ self._low = low
68
+ self.update()
69
+
70
+ def high(self):
71
+ """Return the high position."""
72
+ return self._high
73
+
74
+ def setHigh(self, high: int):
75
+ """Update the hight position."""
76
+ self._high = high
77
+ self.update()
78
+
79
+ def paintEvent(self, _):
80
+ """Draw the slider.
81
+
82
+ Based on http://qt.gitorious.org/qt/qt/blobs/master/src/gui/widgets/qslider.cpp.
83
+ """
84
+ painter = QtGui.QPainter(self)
85
+ style = QtWidgets.QApplication.style()
86
+
87
+ # draw groove
88
+ opt = QtWidgets.QStyleOptionSlider()
89
+ self.initStyleOption(opt)
90
+ opt.siderValue = 0
91
+ opt.sliderPosition = 0
92
+ opt.subControls = QtWidgets.QStyle.SubControl.SC_SliderGroove
93
+ style.drawComplexControl(QtWidgets.QStyle.ComplexControl.CC_Slider, opt, painter, self)
94
+ groove = style.subControlRect(
95
+ QtWidgets.QStyle.ComplexControl.CC_Slider,
96
+ opt,
97
+ QtWidgets.QStyle.SubControl.SC_SliderGroove,
98
+ self,
99
+ )
100
+
101
+ # drawSpan
102
+ self.initStyleOption(opt)
103
+ opt.subControls = QtWidgets.QStyle.SubControl.SC_SliderGroove
104
+ opt.siderValue = 0
105
+ opt.sliderPosition = self._low
106
+ low_rect = style.subControlRect(
107
+ QtWidgets.QStyle.ComplexControl.CC_Slider,
108
+ opt,
109
+ QtWidgets.QStyle.SubControl.SC_SliderHandle,
110
+ self,
111
+ )
112
+ opt.sliderPosition = self._high
113
+ high_rect = style.subControlRect(
114
+ QtWidgets.QStyle.ComplexControl.CC_Slider,
115
+ opt,
116
+ QtWidgets.QStyle.SubControl.SC_SliderHandle,
117
+ self,
118
+ )
119
+
120
+ low_pos = self._pick(low_rect.center())
121
+ high_pos = self._pick(high_rect.center())
122
+ min_pos = min(low_pos, high_pos)
123
+ max_pos = max(low_pos, high_pos)
124
+
125
+ cursor = QtCore.QRect(low_rect.center(), high_rect.center()).center()
126
+ if opt.orientation == QtCore.Qt.Orientation.Horizontal:
127
+ span_rect = QtCore.QRect(
128
+ QtCore.QPoint(min_pos, cursor.y()-2), QtCore.QPoint(max_pos, cursor.y()+1)
129
+ )
130
+ else:
131
+ span_rect = QtCore.QRect(
132
+ QtCore.QPoint(cursor.x()-2, min_pos), QtCore.QPoint(cursor.x()+1, max_pos)
133
+ )
134
+
135
+ if opt.orientation == QtCore.Qt.Orientation.Horizontal:
136
+ groove.adjust(0, 0, -1, 0)
137
+ else:
138
+ groove.adjust(0, 0, 0, -1)
139
+
140
+ highlight = self.palette().color(QtGui.QPalette.ColorRole.Highlight)
141
+ painter.setBrush(QtGui.QBrush(highlight))
142
+ painter.setPen(QtGui.QPen(highlight, 0))
143
+ painter.drawRect(span_rect.intersected(groove))
144
+
145
+ for value in (self._low, self._high):
146
+ opt = QtWidgets.QStyleOptionSlider()
147
+ self.initStyleOption(opt)
148
+
149
+ # Only draw the groove for the first slider so it doesn't get drawn
150
+ # on top of the existing ones every time
151
+ opt.subControls = QtWidgets.QStyle.SubControl.SC_SliderHandle
152
+
153
+ # if self.tickPosition() != QtWidgets.QSlider.TickPosition.NoTicks:
154
+ # opt.subControls |= QtWidgets.QStyle.SubControl.SC_SliderTickmarks
155
+
156
+ if self.pressed_control:
157
+ opt.activeSubControls = self.pressed_control
158
+ else:
159
+ opt.activeSubControls = self.hover_control
160
+
161
+ opt.sliderPosition = value
162
+ opt.sliderValue = value
163
+ style.drawComplexControl(QtWidgets.QStyle.ComplexControl.CC_Slider, opt, painter, self)
164
+
165
+ def mousePressEvent(self, event):
166
+ """When the mouse is pressed on the slider."""
167
+ event.accept()
168
+
169
+ style = QtWidgets.QApplication.style()
170
+ button = event.button()
171
+
172
+ # In a normal slider control, when the user clicks on a point in the
173
+ # slider's total range, but not on the slider part of the control the
174
+ # control would jump the slider value to where the user clicked.
175
+ # For this control, clicks which are not direct hits will slide both
176
+ # slider parts
177
+
178
+ if button:
179
+ opt = QtWidgets.QStyleOptionSlider()
180
+ self.initStyleOption(opt)
181
+
182
+ self.active_slider = -1
183
+
184
+ if self._low + self._high > self.minimum() + self.maximum():
185
+ i_value = ((0, self._low), (1, self._high))
186
+ else:
187
+ i_value = ((1, self._high), (0, self._low))
188
+ for i, value in i_value:
189
+ opt.sliderPosition = value
190
+ hit = style.hitTestComplexControl(
191
+ style.ComplexControl.CC_Slider, opt, event.pos(), self
192
+ )
193
+ if hit == style.SubControl.SC_SliderHandle:
194
+ self.active_slider = i
195
+ self.pressed_control = hit
196
+
197
+ self.triggerAction(self.SliderAction.SliderMove)
198
+ self.setRepeatAction(self.SliderAction.SliderNoAction)
199
+ self.setSliderDown(True)
200
+ break
201
+
202
+ if self.active_slider < 0:
203
+ self.pressed_control = QtWidgets.QStyle.SubControl.SC_SliderHandle
204
+ self.click_offset = self._pixelPosToRangeValue(self._pick(event.pos()))
205
+ self.triggerAction(self.SliderAction.SliderMove)
206
+ self.setRepeatAction(self.SliderAction.SliderNoAction)
207
+ else:
208
+ event.ignore()
209
+
210
+ def mouseMoveEvent(self, event):
211
+ """When the curseor is mooved."""
212
+ if self.pressed_control != QtWidgets.QStyle.SubControl.SC_SliderHandle:
213
+ event.ignore()
214
+ return
215
+
216
+ event.accept()
217
+ new_pos = self._pixelPosToRangeValue(self._pick(event.pos()))
218
+ opt = QtWidgets.QStyleOptionSlider()
219
+ self.initStyleOption(opt)
220
+
221
+ if self.active_slider < 0:
222
+ offset = new_pos - self.click_offset
223
+ self._high += offset
224
+ self._low += offset
225
+ if self._low < self.minimum():
226
+ diff = self.minimum() - self._low
227
+ self._low += diff
228
+ self._high += diff
229
+ if self._high > self.maximum():
230
+ diff = self.maximum() - self._high
231
+ self._low += diff
232
+ self._high += diff
233
+ elif self.active_slider == 0:
234
+ if new_pos >= self._high:
235
+ new_pos = self._high - 1
236
+ self._low = new_pos
237
+ else:
238
+ if new_pos <= self._low:
239
+ new_pos = self._low + 1
240
+ self._high = new_pos
241
+
242
+ self.click_offset = new_pos
243
+
244
+ self.update()
245
+
246
+ self.sliderMoved.emit(self._low, self._high)
247
+
248
+
249
+ class Slider(CutcutcodecWidget, QRangeSlider):
250
+ """Return the slider for adapt the view."""
251
+
252
+ def __init__(self, parent):
253
+ self._parent = parent
254
+ super().__init__(QtCore.Qt.Orientation.Horizontal, parent)
255
+
256
+ self.sliderMoved.connect(self.slider_moved)
257
+
258
+ self.setMinimum(0)
259
+ self.setMaximum(3600*1000)
260
+ self.setLow(0)
261
+ self.setHigh(600*1000)
262
+
263
+ def refresh(self):
264
+ """Update the elements of this widget and child widgets."""
265
+ duration = (
266
+ max((s.beginning+s.duration for s in self.app.tree().in_streams), default=math.inf)
267
+ )
268
+ if duration == math.inf:
269
+ self.setMaximum(3600*1000) # 1h
270
+ else:
271
+ self.setMaximum(round(1000*duration))
272
+
273
+ if self.low() >= self.maximum():
274
+ self.setLow(0)
275
+ if self.high() > self.maximum():
276
+ self.setHigh(self.maximum())
277
+
278
+ def slider_moved(self, low, high):
279
+ """Help when called when the slider is moved by user."""
280
+ self.parent.view.update_range(Fraction(low, 1000), Fraction(high, 1000))
281
+
282
+ def update_range(self, t_min, t_max):
283
+ """Help when called when the timeline is moved by user."""
284
+ low, high = round(1000*t_min), round(1000*t_max)
285
+ self.setLow(low)
286
+ self.setHigh(high)