ancient-processor 4.0.1__tar.gz → 4.1.0__tar.gz
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.
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/CHANGELOG.md +20 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/PKG-INFO +2 -1
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/README.md +1 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/PKG-INFO +2 -1
- ancient_processor-4.1.0/src/ancient_processor.egg-info/scm_version.json +8 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/estimators.py +255 -33
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/templates.py +1 -1
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_estimators.py +276 -12
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_templates.py +25 -0
- ancient_processor-4.0.1/src/ancient_processor.egg-info/scm_version.json +0 -8
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.gitattributes +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.github/dependabot.yml +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.github/pull_request_template.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.github/workflows/ci.yml +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.github/workflows/pages.yml +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.github/workflows/release.yml +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/.gitignore +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/CONTRIBUTING.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/LICENSE +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/MANIFEST.in +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/THIRD_PARTY_NOTICES.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/docs/acceptance.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/docs/release-plan.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/docs/system-design.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/docs/ui-wizard.md +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/pyproject.toml +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/setup.cfg +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/setup.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/SOURCES.txt +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/dependency_links.txt +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/entry_points.txt +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/requires.txt +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/scm_file_list.json +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/ancient_processor.egg-info/top_level.txt +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/__init__.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/__main__.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/_core.pyi +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/_core.pyx +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/diagnose.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/doctor.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/encoders.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/file_dialog.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/gemini.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/gpu_heat.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/jobs.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/look.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/models.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/plan.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/plans.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/preview.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/probe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/progress.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/py.typed +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/qa.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/recipe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/reframe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/regions.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/render.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/review.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/segment_loop.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/segments.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/shot_plan.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/shots.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/span_sr.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/stability.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/treatments.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/upscale.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/validator.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/wizard.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/wizard_pages.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/src/super_processor/worker.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/conftest.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/loop_driver.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_api_key_store.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_audio_mux.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_core.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_diagnose_plan.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_doctor.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_faults.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_frame_alignment.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gemini.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gemini_live.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gemini_video.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gpu_blend.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gpu_codec.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gpu_heat.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_gpu_strength.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_hwdecode.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_job_cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_jobs.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_kept_duration.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_look.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_packaging.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_pass_through.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_plan_cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_plan_io.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_plan_pick.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_plan_revise.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_plan_score.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_preview_encode.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_preview_window.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_probe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_product_flow.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_progress.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_recipe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_reframe.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_regions.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_render_argv.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_render_choose.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_review_server.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_apply.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_bounds.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_ffmpeg.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_groups.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_labels.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_loop.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_loop_wizard.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_merge.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_notes.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_review.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_sample.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_samples_io.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_score.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_segment_split.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_sentence.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_shot_plan.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_shots.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_span_gpu.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_stability.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_timing_safety.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_treatments.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_upscale.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_validator.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_vmaf.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_api.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_cli.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_edges.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_flow_steps.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_full_flow.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_hardening.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_media.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_media_routes.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_navigation.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_note_scale.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_pages.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_render_steps.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_wizard_safety.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/tests/test_worker.py +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/uv.lock +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/index.html +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/package-lock.json +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/package.json +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/scripts/a11y.mjs +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/App.tsx +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/LiveWizard.tsx +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/StaticShell.tsx +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/api.ts +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/main.tsx +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/styles.css +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/src/vite-env.d.ts +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/tests/api.test.mjs +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/tests/proxy.test.mjs +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/tsconfig.json +0 -0
- {ancient_processor-4.0.1 → ancient_processor-4.1.0}/web/vite.config.ts +0 -0
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.1.0] - 2026-11-16
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- `diagnose` suggested stabilising, at its strongest setting and a 30%
|
|
15
|
+
zoom, for nearly every video. It measured how much the picture changed
|
|
16
|
+
between two frames, so any movement, fade or cut counted as shake: 11 of
|
|
17
|
+
12 test clips came out at the maximum. It now reads 8 frames in a row at
|
|
18
|
+
each sample point (every second frame at 50-60 fps), finds the
|
|
19
|
+
whole-frame shift between neighbours up to 5% of the width, skips cuts
|
|
20
|
+
and repeated frames (24p film carried at 30p), and measures how much the
|
|
21
|
+
shift changes from frame to frame, scaled to 30 fps, so a steady pan
|
|
22
|
+
scores nothing and the same shake reads the same at 24, 30 or 60 fps.
|
|
23
|
+
The zoom follows how far the picture strays (1-15%), and vid.stab's
|
|
24
|
+
shakiness is rounded instead of cut down. Every real test clip now stays
|
|
25
|
+
off; simulated handheld shake on a 1947 film, on 360p and on 25-60 fps
|
|
26
|
+
video is caught. Slow sway under about 1 Hz and a subject filling half
|
|
27
|
+
the frame are not told apart from a still camera. Diagnosing takes about
|
|
28
|
+
0.3 s longer.
|
|
29
|
+
|
|
10
30
|
## [4.0.1] - 2026-11-16
|
|
11
31
|
|
|
12
32
|
### Changed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ancient-processor
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: Local-first AI-assisted video processing
|
|
5
5
|
Author: Super Processor contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -41,6 +41,7 @@ Dynamic: license-file
|
|
|
41
41
|
# Super Processor
|
|
42
42
|
|
|
43
43
|
[](https://github.com/LKPJohn2026/super-processor/actions/workflows/ci.yml)
|
|
44
|
+
[](https://pypi.org/project/ancient-processor/)
|
|
44
45
|
|
|
45
46
|
Local-first AI video restoration: SPAN 2x upscaling, with a strength
|
|
46
47
|
control for how much new detail it adds.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Super Processor
|
|
2
2
|
|
|
3
3
|
[](https://github.com/LKPJohn2026/super-processor/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/ancient-processor/)
|
|
4
5
|
|
|
5
6
|
Local-first AI video restoration: SPAN 2x upscaling, with a strength
|
|
6
7
|
control for how much new detail it adds.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ancient-processor
|
|
3
|
-
Version: 4.0
|
|
3
|
+
Version: 4.1.0
|
|
4
4
|
Summary: Local-first AI-assisted video processing
|
|
5
5
|
Author: Super Processor contributors
|
|
6
6
|
License-Expression: MIT
|
|
@@ -41,6 +41,7 @@ Dynamic: license-file
|
|
|
41
41
|
# Super Processor
|
|
42
42
|
|
|
43
43
|
[](https://github.com/LKPJohn2026/super-processor/actions/workflows/ci.yml)
|
|
44
|
+
[](https://pypi.org/project/ancient-processor/)
|
|
44
45
|
|
|
45
46
|
Local-first AI video restoration: SPAN 2x upscaling, with a strength
|
|
46
47
|
control for how much new detail it adds.
|
|
@@ -13,7 +13,7 @@ from typing import Any
|
|
|
13
13
|
from . import histogram_u8, mean_luma, percentile_u8, sad_u8
|
|
14
14
|
from .doctor import check_ffmpeg_capability, which
|
|
15
15
|
from .encoders import HARDWARE_DECODERS, decoder_input_args
|
|
16
|
-
from .probe import MediaFacts
|
|
16
|
+
from .probe import MediaFacts, parse_frame_rate
|
|
17
17
|
|
|
18
18
|
ESTIMATES_FILE_NAME = "estimates.json"
|
|
19
19
|
ESTIMATES_SCHEMA_VERSION = 1
|
|
@@ -177,8 +177,66 @@ def extract_gray_frame(
|
|
|
177
177
|
The frame is scaled to ``width`` x ``height``, or with ``crop`` the
|
|
178
178
|
centre ``width`` x ``height`` is cut out at the source's own pixels.
|
|
179
179
|
"""
|
|
180
|
+
return _gray_frames(
|
|
181
|
+
source,
|
|
182
|
+
at_s=at_s,
|
|
183
|
+
width=width,
|
|
184
|
+
height=height,
|
|
185
|
+
count=1,
|
|
186
|
+
least=1,
|
|
187
|
+
ffmpeg_bin=ffmpeg_bin,
|
|
188
|
+
decoder=decoder,
|
|
189
|
+
crop=crop,
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def extract_gray_run(
|
|
194
|
+
source: Path,
|
|
195
|
+
*,
|
|
196
|
+
at_s: float,
|
|
197
|
+
count: int = 8,
|
|
198
|
+
width: int = 320,
|
|
199
|
+
height: int = 180,
|
|
200
|
+
ffmpeg_bin: str | None = None,
|
|
201
|
+
decoder: str | None = None,
|
|
202
|
+
stride: int = 1,
|
|
203
|
+
) -> list[bytes]:
|
|
204
|
+
"""Decode up to ``count`` consecutive grayscale frames from ``at_s``,
|
|
205
|
+
every ``stride``-th one, scaled to ``width`` x ``height``. Near the end
|
|
206
|
+
of a clip fewer may come back, but never fewer than two."""
|
|
207
|
+
frame = width * height
|
|
208
|
+
data = _gray_frames(
|
|
209
|
+
source,
|
|
210
|
+
at_s=at_s,
|
|
211
|
+
width=width,
|
|
212
|
+
height=height,
|
|
213
|
+
count=count,
|
|
214
|
+
least=2,
|
|
215
|
+
ffmpeg_bin=ffmpeg_bin,
|
|
216
|
+
decoder=decoder,
|
|
217
|
+
crop=False,
|
|
218
|
+
stride=stride,
|
|
219
|
+
)
|
|
220
|
+
return [data[i : i + frame] for i in range(0, len(data), frame)]
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def _gray_frames(
|
|
224
|
+
source: Path,
|
|
225
|
+
*,
|
|
226
|
+
at_s: float,
|
|
227
|
+
width: int,
|
|
228
|
+
height: int,
|
|
229
|
+
count: int,
|
|
230
|
+
least: int,
|
|
231
|
+
ffmpeg_bin: str | None,
|
|
232
|
+
decoder: str | None,
|
|
233
|
+
crop: bool,
|
|
234
|
+
stride: int = 1,
|
|
235
|
+
) -> bytes:
|
|
236
|
+
"""Up to ``count`` whole frames, packed; at least ``least`` of them."""
|
|
180
237
|
binary = ffmpeg_bin or _ffmpeg_bin()
|
|
181
|
-
|
|
238
|
+
frame = width * height
|
|
239
|
+
expected = frame * least
|
|
182
240
|
last_detail = ""
|
|
183
241
|
for attempt in _decoder_attempts(decoder):
|
|
184
242
|
cmd = [
|
|
@@ -192,9 +250,13 @@ def extract_gray_frame(
|
|
|
192
250
|
"-i",
|
|
193
251
|
str(source),
|
|
194
252
|
"-frames:v",
|
|
195
|
-
|
|
253
|
+
str(count),
|
|
196
254
|
"-vf",
|
|
197
|
-
f"{
|
|
255
|
+
(f"select=not(mod(n\\,{stride}))," if stride > 1 else "")
|
|
256
|
+
+ f"{'crop' if crop else 'scale'}={width}:{height},format=gray",
|
|
257
|
+
# Each decoded frame once: no repeats to fill gaps in time.
|
|
258
|
+
"-fps_mode",
|
|
259
|
+
"passthrough",
|
|
198
260
|
"-f",
|
|
199
261
|
"rawvideo",
|
|
200
262
|
"-pix_fmt",
|
|
@@ -229,7 +291,8 @@ def extract_gray_frame(
|
|
|
229
291
|
f"short frame buffer at {at_s:g}s "
|
|
230
292
|
f"({len(completed.stdout)} < {expected} bytes)"
|
|
231
293
|
)
|
|
232
|
-
|
|
294
|
+
whole = min(count, len(completed.stdout) // frame)
|
|
295
|
+
return completed.stdout[: whole * frame]
|
|
233
296
|
raise EstimatorError(
|
|
234
297
|
f"ffmpeg frame extract failed at {at_s:g}s"
|
|
235
298
|
+ (f": {last_detail}" if last_detail else "")
|
|
@@ -435,39 +498,193 @@ def _estimate_denoise(
|
|
|
435
498
|
return suggestion, {"noise_residual": noise, "denoise_strength": strength}
|
|
436
499
|
|
|
437
500
|
|
|
501
|
+
# Shake is measured on runs of consecutive frames, scaled to this size.
|
|
502
|
+
SHAKE_RUN = 8
|
|
503
|
+
SHAKE_WIDTH = 320
|
|
504
|
+
SHAKE_HEIGHT = 180
|
|
505
|
+
# Shake is compared at this frame rate: faster footage reads every second
|
|
506
|
+
# (or third) frame, and the jitter is scaled to what it would be at 30 fps.
|
|
507
|
+
SHAKE_FPS = 30.0
|
|
508
|
+
# Largest whole-frame shift searched between neighbouring frames, in pixels
|
|
509
|
+
# of the scaled frame (5% of the width).
|
|
510
|
+
_SHIFT_RADIUS = 16
|
|
511
|
+
# Mean absolute difference, after the best alignment, above which two
|
|
512
|
+
# neighbouring frames are not one picture moved: a cut or a flash.
|
|
513
|
+
_CUT_COST = 12.0
|
|
514
|
+
# Below this difference, with no move, the frame is a repeat (a 24p film
|
|
515
|
+
# carried at 30p, or a frame FFmpeg duplicated) and is skipped.
|
|
516
|
+
_REPEAT_COST = 0.5
|
|
517
|
+
# Jitter, in % of the frame per frame at 30 fps, from which stabilising is
|
|
518
|
+
# suggested.
|
|
519
|
+
_SHAKE_ON_PCT = 0.5
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
def shake_stride(fps: float | None) -> int:
|
|
523
|
+
"""Read every n-th frame so the run's frame rate is near 30 fps."""
|
|
524
|
+
if not fps or fps <= 0:
|
|
525
|
+
return 1
|
|
526
|
+
return max(1, round(fps / SHAKE_FPS))
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
def _match_cost(
|
|
530
|
+
a: bytes, b: bytes, width: int, height: int, dx: int, dy: int, margin: int
|
|
531
|
+
) -> float:
|
|
532
|
+
"""Mean absolute difference between ``a`` and ``b`` moved by (dx, dy),
|
|
533
|
+
over the middle of the frame."""
|
|
534
|
+
span = width - 2 * margin
|
|
535
|
+
total = 0
|
|
536
|
+
for y in range(margin, height - margin):
|
|
537
|
+
row = y * width + margin
|
|
538
|
+
other = (y + dy) * width + margin + dx
|
|
539
|
+
total += sad_u8(a[row : row + span], b[other : other + span])
|
|
540
|
+
return total / (span * (height - 2 * margin))
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
def _vertex(left: float, mid: float, right: float) -> float:
|
|
544
|
+
"""Where a parabola through three equally spaced costs bottoms out,
|
|
545
|
+
from -0.5 to 0.5 around the middle one."""
|
|
546
|
+
curve = left - 2.0 * mid + right
|
|
547
|
+
if curve <= 0.0:
|
|
548
|
+
return 0.0
|
|
549
|
+
return max(-0.5, min(0.5, (left - right) / (2.0 * curve)))
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
def _global_shift(
|
|
553
|
+
a: bytes, b: bytes, width: int, height: int, radius: int = _SHIFT_RADIUS
|
|
554
|
+
) -> tuple[float, float, float]:
|
|
555
|
+
"""How far the picture moved from ``a`` to ``b`` as (dx, dy) in pixels,
|
|
556
|
+
to a fraction of a pixel, and the mean difference left after lining
|
|
557
|
+
them up."""
|
|
558
|
+
margin = radius + 2
|
|
559
|
+
costs: dict[tuple[int, int], float] = {}
|
|
560
|
+
|
|
561
|
+
def cost(dx: int, dy: int) -> float:
|
|
562
|
+
if (dx, dy) not in costs:
|
|
563
|
+
costs[dx, dy] = _match_cost(a, b, width, height, dx, dy, margin)
|
|
564
|
+
return costs[dx, dy]
|
|
565
|
+
|
|
566
|
+
def rank(shift: tuple[int, int]) -> tuple[float, int]:
|
|
567
|
+
# On a tie, the smaller shift: a flat picture has not moved.
|
|
568
|
+
return cost(*shift), abs(shift[0]) + abs(shift[1])
|
|
569
|
+
|
|
570
|
+
coarse = range(-radius, radius + 1, 2)
|
|
571
|
+
bx, by = min(((dx, dy) for dy in coarse for dx in coarse), key=rank)
|
|
572
|
+
bx, by = min(((bx + i, by + j) for j in (-1, 0, 1) for i in (-1, 0, 1)), key=rank)
|
|
573
|
+
mid = cost(bx, by)
|
|
574
|
+
fx = _vertex(cost(bx - 1, by), mid, cost(bx + 1, by))
|
|
575
|
+
fy = _vertex(cost(bx, by - 1), mid, cost(bx, by + 1))
|
|
576
|
+
return bx + fx, by + fy, mid
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def _run_moves(
|
|
580
|
+
run: list[bytes], width: int, height: int
|
|
581
|
+
) -> tuple[list[tuple[float, float] | None], int]:
|
|
582
|
+
"""The picture's move between each pair of frames in % of the frame,
|
|
583
|
+
None across a cut, with repeated frames left out; and how many repeats
|
|
584
|
+
there were."""
|
|
585
|
+
moves: list[tuple[float, float] | None] = []
|
|
586
|
+
repeats = 0
|
|
587
|
+
for a, b in zip(run, run[1:], strict=False):
|
|
588
|
+
dx, dy, left = _global_shift(a, b, width, height)
|
|
589
|
+
moved = round(dx) != 0 or round(dy) != 0
|
|
590
|
+
if not moved and left <= _REPEAT_COST:
|
|
591
|
+
repeats += 1
|
|
592
|
+
elif left > _CUT_COST:
|
|
593
|
+
moves.append(None)
|
|
594
|
+
else:
|
|
595
|
+
moves.append((100.0 * dx / width, 100.0 * dy / height))
|
|
596
|
+
return moves, repeats
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
def _run_shake(
|
|
600
|
+
run: list[bytes], width: int, height: int, fps: float = SHAKE_FPS
|
|
601
|
+
) -> tuple[float, float] | None:
|
|
602
|
+
"""Jitter and peak excursion of one run of frames, each in % of the
|
|
603
|
+
frame, or None when no two neighbouring moves can be compared.
|
|
604
|
+
|
|
605
|
+
Jitter is how much the picture's move changes from one frame to the
|
|
606
|
+
next, scaled to 30 fps: a steady pan moves the same each frame and has
|
|
607
|
+
none. The excursion is how far the picture strays from a steady path,
|
|
608
|
+
which is what a stabiliser has to crop away. ``fps`` is the run's own
|
|
609
|
+
frame rate."""
|
|
610
|
+
moves, repeats = _run_moves(run, width, height)
|
|
611
|
+
if not moves and repeats:
|
|
612
|
+
return 0.0, 0.0 # every frame a repeat: a still picture
|
|
613
|
+
steps = [
|
|
614
|
+
math.hypot(m2[0] - m1[0], m2[1] - m1[1])
|
|
615
|
+
for m1, m2 in zip(moves, moves[1:], strict=False)
|
|
616
|
+
if m1 is not None and m2 is not None
|
|
617
|
+
]
|
|
618
|
+
if not steps:
|
|
619
|
+
return None
|
|
620
|
+
# The move changes more between frames further apart, by the square of
|
|
621
|
+
# the time between them; repeated frames were dropped, so the frames
|
|
622
|
+
# left are further apart.
|
|
623
|
+
pairs = len(run) - 1
|
|
624
|
+
rate = fps * (pairs - repeats) / pairs
|
|
625
|
+
jitter = sum(steps) / len(steps) * (rate / SHAKE_FPS) ** 2
|
|
626
|
+
# The longest stretch without a cut, as positions from its first frame.
|
|
627
|
+
best: list[tuple[float, float]] = []
|
|
628
|
+
stretch: list[tuple[float, float]] = []
|
|
629
|
+
for move in [*moves, None]:
|
|
630
|
+
if move is None:
|
|
631
|
+
best = max(best, stretch, key=len)
|
|
632
|
+
stretch = []
|
|
633
|
+
else:
|
|
634
|
+
stretch.append(move)
|
|
635
|
+
x = y = 0.0
|
|
636
|
+
path = [(0.0, 0.0)]
|
|
637
|
+
for mx, my in best:
|
|
638
|
+
x, y = x + mx, y + my
|
|
639
|
+
path.append((x, y))
|
|
640
|
+
n = len(path) - 1
|
|
641
|
+
excursion = max(
|
|
642
|
+
math.hypot(px - x * k / n, py - y * k / n) for k, (px, py) in enumerate(path)
|
|
643
|
+
)
|
|
644
|
+
return jitter, excursion
|
|
645
|
+
|
|
646
|
+
|
|
438
647
|
def _estimate_shake(
|
|
439
|
-
|
|
648
|
+
runs: list[list[bytes]],
|
|
649
|
+
width: int = SHAKE_WIDTH,
|
|
650
|
+
height: int = SHAKE_HEIGHT,
|
|
651
|
+
fps: float = SHAKE_FPS,
|
|
440
652
|
) -> tuple[OpSuggestion, dict[str, float]]:
|
|
441
|
-
if
|
|
653
|
+
measured = [m for m in (_run_shake(run, width, height, fps) for run in runs) if m]
|
|
654
|
+
if not measured:
|
|
442
655
|
suggestion = OpSuggestion(
|
|
443
656
|
enabled=False,
|
|
444
657
|
confidence=0.0,
|
|
445
658
|
params={"shakiness": 5.0, "smoothing": 10.0, "max_crop_pct": 10.0},
|
|
446
|
-
reason="
|
|
659
|
+
reason="no steady stretch of frames to measure shake on",
|
|
447
660
|
)
|
|
448
|
-
return suggestion, {"
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
shakiness = max(1.0, min(10.0,
|
|
457
|
-
smoothing = max(
|
|
458
|
-
|
|
459
|
-
|
|
661
|
+
return suggestion, {"shake_jitter_pct": 0.0, "shake_excursion_pct": 0.0}
|
|
662
|
+
|
|
663
|
+
# The middle window, or the calmer of the middle two, so one handheld
|
|
664
|
+
# insert or one cut does not decide.
|
|
665
|
+
jitters = sorted(j for j, _ in measured)
|
|
666
|
+
jitter = jitters[(len(jitters) - 1) // 2]
|
|
667
|
+
excursion = max(e for _, e in measured)
|
|
668
|
+
enabled = jitter >= _SHAKE_ON_PCT
|
|
669
|
+
shakiness = max(1.0, min(10.0, jitter * 3.0))
|
|
670
|
+
smoothing = max(10.0, min(30.0, 10.0 + 2.0 * shakiness))
|
|
671
|
+
# Crop away the stray on both sides, with half again for the parts of
|
|
672
|
+
# the shot the sample did not see.
|
|
673
|
+
max_crop = max(1.0, min(15.0, 3.0 * excursion))
|
|
460
674
|
suggestion = OpSuggestion(
|
|
461
675
|
enabled=enabled,
|
|
462
|
-
confidence=min(1.0,
|
|
676
|
+
confidence=min(1.0, jitter / (2.0 * _SHAKE_ON_PCT)) * len(measured) / len(runs),
|
|
463
677
|
params={
|
|
464
678
|
"shakiness": round(shakiness if enabled else 5.0, 2),
|
|
465
679
|
"smoothing": round(smoothing if enabled else 10.0, 2),
|
|
466
680
|
"max_crop_pct": round(max_crop if enabled else 10.0, 2),
|
|
467
681
|
},
|
|
468
|
-
reason=f"
|
|
682
|
+
reason=f"jitter={jitter:.2f}% excursion={excursion:.2f}% of the frame",
|
|
469
683
|
)
|
|
470
|
-
return suggestion, {
|
|
684
|
+
return suggestion, {
|
|
685
|
+
"shake_jitter_pct": jitter,
|
|
686
|
+
"shake_excursion_pct": excursion,
|
|
687
|
+
}
|
|
471
688
|
|
|
472
689
|
|
|
473
690
|
def estimate_look(
|
|
@@ -484,12 +701,18 @@ def estimate_look(
|
|
|
484
701
|
raise EstimatorError("look estimation requires a video stream")
|
|
485
702
|
|
|
486
703
|
windows = choose_sample_windows(facts)
|
|
487
|
-
duration = max(facts.duration_s or 1.0, 0.5)
|
|
488
704
|
gray_frames: list[bytes] = []
|
|
489
705
|
rgb_means: list[tuple[float, float, float]] = []
|
|
490
|
-
|
|
706
|
+
runs: list[list[bytes]] = []
|
|
491
707
|
|
|
492
708
|
side = grain_crop_side(facts)
|
|
709
|
+
video = facts.primary_video()
|
|
710
|
+
fps = None
|
|
711
|
+
if video is not None:
|
|
712
|
+
fps = parse_frame_rate(video.avg_frame_rate) or parse_frame_rate(
|
|
713
|
+
video.r_frame_rate
|
|
714
|
+
)
|
|
715
|
+
stride = shake_stride(fps)
|
|
493
716
|
grain_frames: list[bytes] = []
|
|
494
717
|
for window in windows:
|
|
495
718
|
frame_a = extract_gray_frame(source, at_s=window.start_s, ffmpeg_bin=ffmpeg_bin)
|
|
@@ -504,15 +727,12 @@ def estimate_look(
|
|
|
504
727
|
crop=True,
|
|
505
728
|
)
|
|
506
729
|
)
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
730
|
+
runs.append(
|
|
731
|
+
extract_gray_run(
|
|
732
|
+
source, at_s=window.start_s, ffmpeg_bin=ffmpeg_bin, stride=stride
|
|
733
|
+
)
|
|
510
734
|
)
|
|
511
|
-
if abs(pair_at - window.start_s) < 0.03:
|
|
512
|
-
pair_at = min(duration - 0.05, window.start_s + 0.08)
|
|
513
|
-
frame_b = extract_gray_frame(source, at_s=pair_at, ffmpeg_bin=ffmpeg_bin)
|
|
514
735
|
gray_frames.append(frame_a)
|
|
515
|
-
pair_frames.append((frame_a, frame_b))
|
|
516
736
|
rgb_means.append(
|
|
517
737
|
extract_rgb_means(source, at_s=window.start_s, ffmpeg_bin=ffmpeg_bin)
|
|
518
738
|
)
|
|
@@ -523,7 +743,9 @@ def estimate_look(
|
|
|
523
743
|
denoise, denoise_metrics = _estimate_denoise(gray_frames)
|
|
524
744
|
else:
|
|
525
745
|
denoise, denoise_metrics = _estimate_denoise(grain_frames, side)
|
|
526
|
-
stabilize, shake_metrics = _estimate_shake(
|
|
746
|
+
stabilize, shake_metrics = _estimate_shake(
|
|
747
|
+
runs, fps=(fps / stride) if fps else SHAKE_FPS
|
|
748
|
+
)
|
|
527
749
|
|
|
528
750
|
metrics = {}
|
|
529
751
|
metrics.update(contrast_metrics)
|
|
@@ -140,7 +140,7 @@ def _stabilize_detect(
|
|
|
140
140
|
if not ffmpeg_has_filter("vidstabdetect", ffmpeg_bin=ffmpeg_bin):
|
|
141
141
|
# Homebrew/Chocolatey builds often omit vid.stab; deshake is single-pass.
|
|
142
142
|
return None
|
|
143
|
-
shakiness =
|
|
143
|
+
shakiness = max(1, min(10, round(float(stabilize.params.get("shakiness", 5.0)))))
|
|
144
144
|
return (
|
|
145
145
|
f"vidstabdetect=shakiness={shakiness}:accuracy=15:"
|
|
146
146
|
f"result={_escape_filter_path(transforms)}"
|