iterframes 0.5.0__tar.gz → 0.7.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.
- iterframes-0.7.0/.github/scripts/check_site.py +50 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.github/workflows/ci.yaml +9 -0
- iterframes-0.7.0/.github/workflows/pages.yaml +61 -0
- iterframes-0.7.0/.release-please-manifest.json +3 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/AGENTS.md +53 -5
- {iterframes-0.5.0 → iterframes-0.7.0}/CHANGELOG.md +14 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/Cargo.lock +1 -1
- {iterframes-0.5.0 → iterframes-0.7.0}/Cargo.toml +2 -2
- iterframes-0.7.0/LICENSE +202 -0
- iterframes-0.7.0/NOTICE +19 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/PKG-INFO +33 -12
- {iterframes-0.5.0 → iterframes-0.7.0}/README.md +27 -10
- iterframes-0.7.0/docs/api.md +151 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/docs/development.md +38 -14
- iterframes-0.5.0/docs/reference.md → iterframes-0.7.0/docs/guides.md +88 -121
- {iterframes-0.5.0 → iterframes-0.7.0}/docs/index.md +39 -6
- {iterframes-0.5.0 → iterframes-0.7.0}/iterframes/__init__.py +34 -4
- iterframes-0.7.0/licenses/FFmpeg-LGPL-2.1.txt +502 -0
- iterframes-0.7.0/licenses/dav1d-BSD-2-Clause.txt +23 -0
- iterframes-0.7.0/licenses/nv-codec-headers-MIT.txt +26 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/mkdocs.yml +5 -1
- {iterframes-0.5.0 → iterframes-0.7.0}/pyproject.toml +2 -2
- iterframes-0.7.0/scripts/docs_redirects.py +41 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/src/decoder.rs +77 -9
- {iterframes-0.5.0 → iterframes-0.7.0}/src/ffmpeg.rs +34 -8
- {iterframes-0.5.0 → iterframes-0.7.0}/src/lib.rs +57 -5
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/conftest.py +5 -2
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/test_benchmark.py +26 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/test_read.py +106 -2
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/test_select.py +101 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/uv.lock +21 -21
- iterframes-0.7.0/web/README.md +123 -0
- iterframes-0.7.0/web/assets/favicon.svg +5 -0
- iterframes-0.7.0/web/assets/fonts/jakarta-latin.woff2 +0 -0
- iterframes-0.7.0/web/assets/fonts/jetbrains-mono-latin.woff2 +0 -0
- iterframes-0.7.0/web/assets/frames.webp +0 -0
- iterframes-0.7.0/web/assets/og.png +0 -0
- iterframes-0.7.0/web/assets/scenes.webp +0 -0
- iterframes-0.7.0/web/index.html +534 -0
- iterframes-0.7.0/web/main.js +467 -0
- iterframes-0.7.0/web/og-card.html +51 -0
- iterframes-0.7.0/web/styles.css +730 -0
- iterframes-0.5.0/.release-please-manifest.json +0 -3
- iterframes-0.5.0/LICENSE +0 -165
- {iterframes-0.5.0 → iterframes-0.7.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.gitignore +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.pre-commit-config.yaml +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/.readthedocs.yaml +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/CLAUDE.md +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/build.rs +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/release-please-config.json +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/scripts/build-ffmpeg.sh +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/src/dlpack.rs +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/data/video_480x270.mp4 +0 -0
- {iterframes-0.5.0 → iterframes-0.7.0}/tests/data/video_av1_480x270.mp4 +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Check that every local reference in the landing page resolves to a file.
|
|
2
|
+
|
|
3
|
+
The page has no build step, so nothing else would catch a renamed asset or a
|
|
4
|
+
typo in a path until the deployed site showed a broken image.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import re
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from urllib.parse import unquote, urlparse
|
|
11
|
+
|
|
12
|
+
# href="...", src="..." and url(...) in CSS.
|
|
13
|
+
REFERENCES = re.compile(
|
|
14
|
+
r"""(?:href|src)\s*=\s*["']([^"']+)["']|url\(\s*["']?([^"')]+)["']?\s*\)"""
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def local(reference: str) -> bool:
|
|
19
|
+
parsed = urlparse(reference)
|
|
20
|
+
return not parsed.scheme and not parsed.netloc and bool(parsed.path)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def main(root: Path) -> int:
|
|
24
|
+
missing = []
|
|
25
|
+
for source in sorted(root.rglob("*")):
|
|
26
|
+
if source.suffix not in {".html", ".css", ".js"}:
|
|
27
|
+
continue
|
|
28
|
+
text = source.read_text(encoding="utf-8")
|
|
29
|
+
for match in REFERENCES.finditer(text):
|
|
30
|
+
reference = match.group(1) or match.group(2)
|
|
31
|
+
if not local(reference):
|
|
32
|
+
continue
|
|
33
|
+
path = unquote(urlparse(reference).path)
|
|
34
|
+
if path in {"./", "."}:
|
|
35
|
+
continue
|
|
36
|
+
target = (source.parent / path).resolve()
|
|
37
|
+
if not target.exists():
|
|
38
|
+
line = text.count("\n", 0, match.start()) + 1
|
|
39
|
+
missing.append(f"{source}:{line}: {reference}")
|
|
40
|
+
|
|
41
|
+
for problem in missing:
|
|
42
|
+
print(f"missing: {problem}", file=sys.stderr)
|
|
43
|
+
if missing:
|
|
44
|
+
return 1
|
|
45
|
+
print(f"every local reference under {root} resolves")
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
raise SystemExit(main(Path(sys.argv[1] if len(sys.argv) > 1 else "web")))
|
|
@@ -8,11 +8,20 @@ name: CI
|
|
|
8
8
|
# updates its release pull request, and merging that pull request creates
|
|
9
9
|
# the tag and a draft GitHub release, then the jobs below attach the
|
|
10
10
|
# wheels, publish them to PyPI, and publish the release.
|
|
11
|
+
# The landing page has its own workflow, and nothing here builds it, so a
|
|
12
|
+
# commit that only touches web/ skips the wheel matrix. release-please skips
|
|
13
|
+
# with it, and picks those commits up on the next push that does build
|
|
14
|
+
# something.
|
|
11
15
|
on:
|
|
12
16
|
push:
|
|
13
17
|
branches:
|
|
14
18
|
- main
|
|
19
|
+
paths-ignore: &page
|
|
20
|
+
- 'web/**'
|
|
21
|
+
- '.github/workflows/pages.yaml'
|
|
22
|
+
- '.github/scripts/check_site.py'
|
|
15
23
|
pull_request:
|
|
24
|
+
paths-ignore: *page
|
|
16
25
|
workflow_dispatch:
|
|
17
26
|
|
|
18
27
|
permissions:
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Publishes web/ to https://alesanfra.github.io/iterframes/.
|
|
2
|
+
#
|
|
3
|
+
# The page is plain HTML, CSS and JavaScript, so there is nothing to build:
|
|
4
|
+
# the job uploads the directory and hands it to Pages. It runs only when
|
|
5
|
+
# web/ changes, and ci.yaml ignores web/ for the same reason, so a change
|
|
6
|
+
# to one never spends minutes on the other.
|
|
7
|
+
#
|
|
8
|
+
# Pages must be set to "GitHub Actions" under Settings > Pages for the
|
|
9
|
+
# deployment to be accepted.
|
|
10
|
+
name: Pages
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
branches:
|
|
15
|
+
- main
|
|
16
|
+
paths: &page
|
|
17
|
+
- 'web/**'
|
|
18
|
+
- '.github/workflows/pages.yaml'
|
|
19
|
+
- '.github/scripts/check_site.py'
|
|
20
|
+
pull_request:
|
|
21
|
+
paths: *page
|
|
22
|
+
workflow_dispatch:
|
|
23
|
+
|
|
24
|
+
permissions:
|
|
25
|
+
contents: read
|
|
26
|
+
|
|
27
|
+
# One deployment at a time, and never cancel one halfway: a cancelled
|
|
28
|
+
# deployment leaves the live site on the previous version.
|
|
29
|
+
concurrency:
|
|
30
|
+
group: pages
|
|
31
|
+
cancel-in-progress: false
|
|
32
|
+
|
|
33
|
+
jobs:
|
|
34
|
+
check:
|
|
35
|
+
name: Check the page
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v7
|
|
39
|
+
- name: Check every local link and asset resolves
|
|
40
|
+
run: python3 .github/scripts/check_site.py web
|
|
41
|
+
|
|
42
|
+
deploy:
|
|
43
|
+
name: Deploy to GitHub Pages
|
|
44
|
+
# Pull requests get the check above; only main is published.
|
|
45
|
+
if: ${{ github.event_name != 'pull_request' }}
|
|
46
|
+
needs: check
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
permissions:
|
|
49
|
+
pages: write
|
|
50
|
+
id-token: write
|
|
51
|
+
environment:
|
|
52
|
+
name: github-pages
|
|
53
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v7
|
|
56
|
+
- uses: actions/configure-pages@v6
|
|
57
|
+
- uses: actions/upload-pages-artifact@v5
|
|
58
|
+
with:
|
|
59
|
+
path: web
|
|
60
|
+
- id: deployment
|
|
61
|
+
uses: actions/deploy-pages@v5
|
|
@@ -54,6 +54,18 @@ as `iterframes.iterframes`, and `iterframes/__init__.py` wraps its
|
|
|
54
54
|
frame, which decoding cannot return either, so frame numbers are those of
|
|
55
55
|
a plain `read`. A stream that cannot seek, such as raw H.264, is opened
|
|
56
56
|
again and read from the start (`Source::open`).
|
|
57
|
+
- `approximate` goes with `frames` only, and carries a tolerance in frames
|
|
58
|
+
(`True` is `usize::MAX`), in `Selection::Frames`. `selected` then maps
|
|
59
|
+
each index through `Seeker::nearest_key`, which snaps it to the key frame
|
|
60
|
+
closest to it when that is within the tolerance, and leaves it alone
|
|
61
|
+
otherwise. Nothing else changes: the index pass still runs, and two
|
|
62
|
+
indices that snap to the same key frame decode it once each, so the caller
|
|
63
|
+
gets one frame per number asked for.
|
|
64
|
+
- `interpolation` picks the `SWS_*` flag of the `Scaler`
|
|
65
|
+
(`ffmpeg::Interpolation`); `None` is `SWS_BILINEAR`. A named one also
|
|
66
|
+
turns off the `resize` option of the `*_cuvid` decoders
|
|
67
|
+
(`resize_on_device` in `Source`), so the CPU resizes what the GPU
|
|
68
|
+
decoded, since NVIDIA's method cannot be chosen.
|
|
57
69
|
- Errors travel through the channel and become Python exceptions in
|
|
58
70
|
`impl From<Error> for PyErr`. A closed channel means the end of the video.
|
|
59
71
|
- Dropping the reader closes the channel; the thread notices on its next
|
|
@@ -78,6 +90,10 @@ as `iterframes.iterframes`, and `iterframes/__init__.py` wraps its
|
|
|
78
90
|
linker. `build.rs` finds `bash.exe` on `PATH` itself, since Rust would
|
|
79
91
|
otherwise pick WSL's from the system directory.
|
|
80
92
|
- Keep the build LGPL: never pass `--enable-gpl` or `--enable-nonfree`.
|
|
93
|
+
- iterframes itself is Apache-2.0. The wheels carry the licenses of what
|
|
94
|
+
they bundle, listed in `NOTICE` with their texts in `licenses/`: when a
|
|
95
|
+
version in `scripts/build-ffmpeg.sh` changes, or a library is added,
|
|
96
|
+
update both.
|
|
81
97
|
- Hardware decoding (`device="mps"` / `"cuda"`, PyTorch's names, mapped
|
|
82
98
|
to FFmpeg's in `hardware_devices` in `src/lib.rs`): VideoToolbox on
|
|
83
99
|
macOS; on Linux and Windows
|
|
@@ -103,6 +119,7 @@ as `iterframes.iterframes`, and `iterframes/__init__.py` wraps its
|
|
|
103
119
|
| `scripts/build-ffmpeg.sh` | Static FFmpeg and dav1d, run by `build.rs` |
|
|
104
120
|
| `tests/` | pytest suite; frames are compared with PyAV |
|
|
105
121
|
| `docs/` | MkDocs site published on Read the Docs |
|
|
122
|
+
| `web/` | Landing page published on GitHub Pages |
|
|
106
123
|
|
|
107
124
|
## Environment
|
|
108
125
|
|
|
@@ -139,11 +156,42 @@ locally.
|
|
|
139
156
|
|
|
140
157
|
## Docs
|
|
141
158
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
159
|
+
Four pages: `index.md` (overview and quick start), `guides.md` (what the
|
|
160
|
+
arguments are for, and what they cost), `api.md` (signatures, arguments,
|
|
161
|
+
and errors), `development.md`. `scripts/docs_redirects.py` sends links to
|
|
162
|
+
the old `reference/` page, anchors included, to the page that now holds
|
|
163
|
+
each section; add to it when a section moves. Every example must match
|
|
164
|
+
the behavior of a freshly built module; check them instead of writing
|
|
165
|
+
them from memory. Keep the text short, in American English, with no
|
|
166
|
+
performance claims that have not been measured.
|
|
167
|
+
|
|
168
|
+
The landing page in `web/` is part of the docs: whenever an argument, a
|
|
169
|
+
default, or the behavior of a feature changes, update it in the same
|
|
170
|
+
change as the code, and say so in the pull request. Its diagrams are
|
|
171
|
+
drawn from the numbers declared in `web/main.js`, so change the number
|
|
172
|
+
and let the drawing and the captions follow; never write a figure into
|
|
173
|
+
the HTML that the script also computes. `web/README.md` lists those
|
|
174
|
+
numbers and the files. Check the result in a browser before proposing the
|
|
175
|
+
change: open `web/index.html`, or serve the directory with
|
|
176
|
+
`python3 -m http.server --directory web`. The page has no build step and no
|
|
177
|
+
third-party request: its two typefaces are self-hosted woff2 files in
|
|
178
|
+
`web/assets/fonts/`, and everything else is plain HTML, CSS, and JavaScript.
|
|
179
|
+
`web/README.md` describes the look and the colour rules; keep them rather
|
|
180
|
+
than restyling one component on its own.
|
|
181
|
+
|
|
182
|
+
## Landing page
|
|
183
|
+
|
|
184
|
+
`web/` is the page at
|
|
185
|
+
[alesanfra.github.io/iterframes](https://alesanfra.github.io/iterframes/):
|
|
186
|
+
plain HTML, CSS and JavaScript, no build step, no framework, no web fonts and
|
|
187
|
+
no third-party script. `.github/workflows/pages.yaml` uploads the directory
|
|
188
|
+
and runs only when it changes; `ci.yaml` ignores it, so neither spends minutes
|
|
189
|
+
on the other. Its two animated diagrams are built from constants at the top of
|
|
190
|
+
`main.js`, and their captions are computed from the same constants, so a
|
|
191
|
+
number cannot appear in the drawing and the prose with two different values.
|
|
192
|
+
`web/README.md` has the `ffmpeg` commands that made the images.
|
|
193
|
+
|
|
194
|
+
Keep its claims to what the benchmarks measured, as in the docs.
|
|
147
195
|
|
|
148
196
|
## Conventions
|
|
149
197
|
|
|
@@ -6,6 +6,20 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|
|
6
6
|
From 0.4.0 on, [release-please](https://github.com/googleapis/release-please)
|
|
7
7
|
writes each entry from the Conventional Commits since the previous release.
|
|
8
8
|
|
|
9
|
+
## [0.7.0](https://github.com/alesanfra/iterframes/compare/v0.6.0...v0.7.0) (2026-09-29)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* choose how frames are resized with interpolation ([#15](https://github.com/alesanfra/iterframes/issues/15)) ([6317322](https://github.com/alesanfra/iterframes/commit/63173220228303d0ca508e00037260ffe272b69c))
|
|
15
|
+
|
|
16
|
+
## [0.6.0](https://github.com/alesanfra/iterframes/compare/v0.5.0...v0.6.0) (2026-09-20)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* read approximate frames ([#11](https://github.com/alesanfra/iterframes/issues/11)) ([2158899](https://github.com/alesanfra/iterframes/commit/2158899f72f73d69c0020236181e340bb8648fc1))
|
|
22
|
+
|
|
9
23
|
## [0.5.0](https://github.com/alesanfra/iterframes/compare/v0.4.0...v0.5.0) (2026-09-20)
|
|
10
24
|
|
|
11
25
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "iterframes"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.7.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.89"
|
|
6
6
|
description = "Iterate over the frames of a video as NumPy arrays, decoded on a background thread while you process them"
|
|
7
7
|
homepage = "https://github.com/alesanfra/iterframes"
|
|
8
8
|
repository = "https://github.com/alesanfra/iterframes"
|
|
9
|
-
license = "
|
|
9
|
+
license = "Apache-2.0"
|
|
10
10
|
publish = false
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
|
iterframes-0.7.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
iterframes-0.7.0/NOTICE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
iterframes
|
|
2
|
+
Copyright 2020 Alessio Sanfratello
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0, found in
|
|
5
|
+
the LICENSE file.
|
|
6
|
+
|
|
7
|
+
The wheels also include software by third parties, under their own
|
|
8
|
+
licenses, whose texts are in the licenses directory:
|
|
9
|
+
|
|
10
|
+
- FFmpeg 9.0.2 (https://ffmpeg.org/), under the GNU Lesser General
|
|
11
|
+
Public License, version 2.1 or later: licenses/FFmpeg-LGPL-2.1.txt.
|
|
12
|
+
It is built without its GPL and nonfree parts. Its source and the
|
|
13
|
+
script that builds it, scripts/build-ffmpeg.sh, are available, so that
|
|
14
|
+
it can be modified, rebuilt, and relinked.
|
|
15
|
+
- dav1d 1.5.4 (https://code.videolan.org/videolan/dav1d), under the BSD
|
|
16
|
+
2-clause license: licenses/dav1d-BSD-2-Clause.txt.
|
|
17
|
+
- nv-codec-headers 13.0.19.0 (https://github.com/FFmpeg/nv-codec-headers),
|
|
18
|
+
in the Linux and Windows wheels only, under the MIT license:
|
|
19
|
+
licenses/nv-codec-headers-MIT.txt.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: iterframes
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Classifier: Intended Audience :: Science/Research
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
@@ -8,11 +8,15 @@ Classifier: Programming Language :: Rust
|
|
|
8
8
|
Classifier: Topic :: Multimedia :: Video
|
|
9
9
|
Requires-Dist: numpy>=1.21
|
|
10
10
|
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
License-File: licenses/FFmpeg-LGPL-2.1.txt
|
|
13
|
+
License-File: licenses/dav1d-BSD-2-Clause.txt
|
|
14
|
+
License-File: licenses/nv-codec-headers-MIT.txt
|
|
11
15
|
Summary: Iterate over the frames of a video as NumPy arrays, decoded on a background thread while you process them
|
|
12
16
|
Keywords: video,decoder,ffmpeg,frames,numpy,video-reader,pytorch,deep-learning,computer-vision,nvdec,videotoolbox
|
|
13
17
|
Home-Page: https://github.com/alesanfra/iterframes
|
|
14
18
|
Author-email: Alessio Sanfratello <sanfra90@gmail.com>
|
|
15
|
-
License-Expression:
|
|
19
|
+
License-Expression: Apache-2.0
|
|
16
20
|
Requires-Python: >=3.11
|
|
17
21
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
18
22
|
Project-URL: Changelog, https://github.com/alesanfra/iterframes/blob/main/CHANGELOG.md
|
|
@@ -43,10 +47,12 @@ adding to it, even when your code is pure Python. `pip install iterframes`
|
|
|
43
47
|
brings FFmpeg with it: nothing else to install, no system packages, no
|
|
44
48
|
`ffmpeg` binary to call.
|
|
45
49
|
|
|
46
|
-
The
|
|
50
|
+
The landing page at
|
|
51
|
+
[alesanfra.github.io/iterframes](https://alesanfra.github.io/iterframes/)
|
|
52
|
+
shows what the decoder does while your loop runs. The documentation is at
|
|
47
53
|
[iterframes.readthedocs.io](https://iterframes.readthedocs.io): the
|
|
48
|
-
[
|
|
49
|
-
documents every argument and error, and the
|
|
54
|
+
[guides](https://iterframes.readthedocs.io/en/latest/guides/) explain the features, the
|
|
55
|
+
[API](https://iterframes.readthedocs.io/en/latest/api/) documents every argument and error, and the
|
|
50
56
|
[development guide](https://iterframes.readthedocs.io/en/latest/development/)
|
|
51
57
|
covers building from source.
|
|
52
58
|
|
|
@@ -76,7 +82,8 @@ twice as long: the decoding had already happened.
|
|
|
76
82
|
`(height, width, 3)`, straight out of FFmpeg's buffers.
|
|
77
83
|
- **Batches as one array.** `read_batches` decodes into a single
|
|
78
84
|
`(batch, height, width, 3)` block, ready for a model.
|
|
79
|
-
- **Resizing while decoding**, not a `cv2.resize` afterwards
|
|
85
|
+
- **Resizing while decoding**, not a `cv2.resize` afterwards, from
|
|
86
|
+
nearest to Lanczos.
|
|
80
87
|
- **Random access.** Read frames by number, without decoding the rest.
|
|
81
88
|
- **Hardware decoding** on NVIDIA GPUs (NVDEC) and Apple silicon
|
|
82
89
|
(VideoToolbox), in the wheels. On NVIDIA the frames can stay on the GPU
|
|
@@ -111,7 +118,18 @@ frame `n` is the one `read` yields `n`-th. iterframes indexes the file
|
|
|
111
118
|
once, without decoding it, then decodes each frame from the key frame
|
|
112
119
|
before it; frames asked for in order cost no more than reading the video
|
|
113
120
|
straight through. See
|
|
114
|
-
[Reading frames by number](https://iterframes.readthedocs.io/en/latest/
|
|
121
|
+
[Reading frames by number](https://iterframes.readthedocs.io/en/latest/guides/#reading-frames-by-number).
|
|
122
|
+
|
|
123
|
+
When a frame nearby will do, `approximate` reads the key frame closest to
|
|
124
|
+
each of `frames`, which costs one decoded frame instead of the frames from
|
|
125
|
+
the key frame on:
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
# The nearest key frame within 5 frames, else the frame itself.
|
|
129
|
+
frames = list(iterframes.read("video.mp4", frames=[100, 200, 300], approximate=5))
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
See [Approximate frames](https://iterframes.readthedocs.io/en/latest/guides/#approximate-frames).
|
|
115
133
|
|
|
116
134
|
## Hardware decoding
|
|
117
135
|
|
|
@@ -136,7 +154,7 @@ print(iterframes.DEVICES) # ('cpu', 'mps') on a Mac
|
|
|
136
154
|
|
|
137
155
|
The frames still arrive as NumPy arrays in memory. A GPU saves CPU time
|
|
138
156
|
but is not always faster than the CPU decoder, so measure both; see
|
|
139
|
-
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/
|
|
157
|
+
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/guides/#hardware-decoding).
|
|
140
158
|
|
|
141
159
|
With an NVIDIA GPU, `on_device=True` keeps the frames on it, in NV12, for
|
|
142
160
|
PyTorch and other libraries to take without a copy:
|
|
@@ -149,7 +167,7 @@ for frame in iterframes.read("video.mp4", device="cuda", on_device=True):
|
|
|
149
167
|
uv = torch.from_dlpack(frame.uv) # (height / 2, width / 2, 2)
|
|
150
168
|
```
|
|
151
169
|
|
|
152
|
-
[Frames on the GPU](https://iterframes.readthedocs.io/en/latest/
|
|
170
|
+
[Frames on the GPU](https://iterframes.readthedocs.io/en/latest/guides/#frames-on-the-gpu) shows how to
|
|
153
171
|
convert them to RGB there.
|
|
154
172
|
|
|
155
173
|
## Compared with OpenCV, decord, and PyAV
|
|
@@ -189,8 +207,11 @@ lists features that are waiting for someone to build them.
|
|
|
189
207
|
|
|
190
208
|
## License
|
|
191
209
|
|
|
192
|
-
iterframes is released under the [
|
|
193
|
-
[FFmpeg](https://ffmpeg.org/), built under the LGPL, and
|
|
210
|
+
iterframes is released under the [Apache License 2.0](https://github.com/alesanfra/iterframes/blob/main/LICENSE).
|
|
211
|
+
The wheels include [FFmpeg](https://ffmpeg.org/), built under the LGPL, and
|
|
194
212
|
[dav1d](https://code.videolan.org/videolan/dav1d), under the BSD 2-clause
|
|
195
|
-
license.
|
|
213
|
+
license. They are listed in
|
|
214
|
+
[`NOTICE`](https://github.com/alesanfra/iterframes/blob/main/NOTICE), with
|
|
215
|
+
their license texts in
|
|
216
|
+
[`licenses/`](https://github.com/alesanfra/iterframes/tree/main/licenses).
|
|
196
217
|
|