iterframes 0.6.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/.release-please-manifest.json +3 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/AGENTS.md +17 -5
- {iterframes-0.6.0 → iterframes-0.7.0}/CHANGELOG.md +7 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/Cargo.lock +1 -1
- {iterframes-0.6.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.6.0 → iterframes-0.7.0}/PKG-INFO +20 -12
- {iterframes-0.6.0 → iterframes-0.7.0}/README.md +14 -10
- iterframes-0.7.0/docs/api.md +151 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/docs/development.md +38 -14
- iterframes-0.6.0/docs/reference.md → iterframes-0.7.0/docs/guides.md +67 -127
- {iterframes-0.6.0 → iterframes-0.7.0}/docs/index.md +34 -8
- {iterframes-0.6.0 → iterframes-0.7.0}/iterframes/__init__.py +20 -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.6.0 → iterframes-0.7.0}/mkdocs.yml +5 -1
- {iterframes-0.6.0 → iterframes-0.7.0}/pyproject.toml +2 -2
- iterframes-0.7.0/scripts/docs_redirects.py +41 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/src/decoder.rs +39 -5
- {iterframes-0.6.0 → iterframes-0.7.0}/src/ffmpeg.rs +34 -8
- {iterframes-0.6.0 → iterframes-0.7.0}/src/lib.rs +24 -1
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/conftest.py +5 -2
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/test_read.py +106 -2
- {iterframes-0.6.0 → iterframes-0.7.0}/uv.lock +21 -21
- {iterframes-0.6.0 → iterframes-0.7.0}/web/index.html +5 -3
- iterframes-0.6.0/.release-please-manifest.json +0 -3
- iterframes-0.6.0/LICENSE +0 -165
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/scripts/check_site.py +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/workflows/ci.yaml +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.github/workflows/pages.yaml +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.gitignore +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.pre-commit-config.yaml +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/.readthedocs.yaml +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/CLAUDE.md +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/build.rs +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/release-please-config.json +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/scripts/build-ffmpeg.sh +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/src/dlpack.rs +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/data/video_480x270.mp4 +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/data/video_av1_480x270.mp4 +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/test_benchmark.py +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/tests/test_select.py +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/README.md +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/favicon.svg +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/fonts/jakarta-latin.woff2 +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/fonts/jetbrains-mono-latin.woff2 +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/frames.webp +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/og.png +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/assets/scenes.webp +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/main.js +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/og-card.html +0 -0
- {iterframes-0.6.0 → iterframes-0.7.0}/web/styles.css +0 -0
|
@@ -61,6 +61,11 @@ as `iterframes.iterframes`, and `iterframes/__init__.py` wraps its
|
|
|
61
61
|
otherwise. Nothing else changes: the index pass still runs, and two
|
|
62
62
|
indices that snap to the same key frame decode it once each, so the caller
|
|
63
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.
|
|
64
69
|
- Errors travel through the channel and become Python exceptions in
|
|
65
70
|
`impl From<Error> for PyErr`. A closed channel means the end of the video.
|
|
66
71
|
- Dropping the reader closes the channel; the thread notices on its next
|
|
@@ -85,6 +90,10 @@ as `iterframes.iterframes`, and `iterframes/__init__.py` wraps its
|
|
|
85
90
|
linker. `build.rs` finds `bash.exe` on `PATH` itself, since Rust would
|
|
86
91
|
otherwise pick WSL's from the system directory.
|
|
87
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.
|
|
88
97
|
- Hardware decoding (`device="mps"` / `"cuda"`, PyTorch's names, mapped
|
|
89
98
|
to FFmpeg's in `hardware_devices` in `src/lib.rs`): VideoToolbox on
|
|
90
99
|
macOS; on Linux and Windows
|
|
@@ -147,11 +156,14 @@ locally.
|
|
|
147
156
|
|
|
148
157
|
## Docs
|
|
149
158
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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.
|
|
155
167
|
|
|
156
168
|
The landing page in `web/` is part of the docs: whenever an argument, a
|
|
157
169
|
default, or the behavior of a feature changes, update it in the same
|
|
@@ -6,6 +6,13 @@ 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
|
+
|
|
9
16
|
## [0.6.0](https://github.com/alesanfra/iterframes/compare/v0.5.0...v0.6.0) (2026-09-20)
|
|
10
17
|
|
|
11
18
|
|
|
@@ -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
|
|
@@ -47,8 +51,8 @@ The landing page at
|
|
|
47
51
|
[alesanfra.github.io/iterframes](https://alesanfra.github.io/iterframes/)
|
|
48
52
|
shows what the decoder does while your loop runs. The documentation is at
|
|
49
53
|
[iterframes.readthedocs.io](https://iterframes.readthedocs.io): the
|
|
50
|
-
[
|
|
51
|
-
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
|
|
52
56
|
[development guide](https://iterframes.readthedocs.io/en/latest/development/)
|
|
53
57
|
covers building from source.
|
|
54
58
|
|
|
@@ -78,7 +82,8 @@ twice as long: the decoding had already happened.
|
|
|
78
82
|
`(height, width, 3)`, straight out of FFmpeg's buffers.
|
|
79
83
|
- **Batches as one array.** `read_batches` decodes into a single
|
|
80
84
|
`(batch, height, width, 3)` block, ready for a model.
|
|
81
|
-
- **Resizing while decoding**, not a `cv2.resize` afterwards
|
|
85
|
+
- **Resizing while decoding**, not a `cv2.resize` afterwards, from
|
|
86
|
+
nearest to Lanczos.
|
|
82
87
|
- **Random access.** Read frames by number, without decoding the rest.
|
|
83
88
|
- **Hardware decoding** on NVIDIA GPUs (NVDEC) and Apple silicon
|
|
84
89
|
(VideoToolbox), in the wheels. On NVIDIA the frames can stay on the GPU
|
|
@@ -113,7 +118,7 @@ frame `n` is the one `read` yields `n`-th. iterframes indexes the file
|
|
|
113
118
|
once, without decoding it, then decodes each frame from the key frame
|
|
114
119
|
before it; frames asked for in order cost no more than reading the video
|
|
115
120
|
straight through. See
|
|
116
|
-
[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).
|
|
117
122
|
|
|
118
123
|
When a frame nearby will do, `approximate` reads the key frame closest to
|
|
119
124
|
each of `frames`, which costs one decoded frame instead of the frames from
|
|
@@ -124,7 +129,7 @@ the key frame on:
|
|
|
124
129
|
frames = list(iterframes.read("video.mp4", frames=[100, 200, 300], approximate=5))
|
|
125
130
|
```
|
|
126
131
|
|
|
127
|
-
See [Approximate frames](https://iterframes.readthedocs.io/en/latest/
|
|
132
|
+
See [Approximate frames](https://iterframes.readthedocs.io/en/latest/guides/#approximate-frames).
|
|
128
133
|
|
|
129
134
|
## Hardware decoding
|
|
130
135
|
|
|
@@ -149,7 +154,7 @@ print(iterframes.DEVICES) # ('cpu', 'mps') on a Mac
|
|
|
149
154
|
|
|
150
155
|
The frames still arrive as NumPy arrays in memory. A GPU saves CPU time
|
|
151
156
|
but is not always faster than the CPU decoder, so measure both; see
|
|
152
|
-
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/
|
|
157
|
+
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/guides/#hardware-decoding).
|
|
153
158
|
|
|
154
159
|
With an NVIDIA GPU, `on_device=True` keeps the frames on it, in NV12, for
|
|
155
160
|
PyTorch and other libraries to take without a copy:
|
|
@@ -162,7 +167,7 @@ for frame in iterframes.read("video.mp4", device="cuda", on_device=True):
|
|
|
162
167
|
uv = torch.from_dlpack(frame.uv) # (height / 2, width / 2, 2)
|
|
163
168
|
```
|
|
164
169
|
|
|
165
|
-
[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
|
|
166
171
|
convert them to RGB there.
|
|
167
172
|
|
|
168
173
|
## Compared with OpenCV, decord, and PyAV
|
|
@@ -202,8 +207,11 @@ lists features that are waiting for someone to build them.
|
|
|
202
207
|
|
|
203
208
|
## License
|
|
204
209
|
|
|
205
|
-
iterframes is released under the [
|
|
206
|
-
[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
|
|
207
212
|
[dav1d](https://code.videolan.org/videolan/dav1d), under the BSD 2-clause
|
|
208
|
-
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).
|
|
209
217
|
|
|
@@ -24,8 +24,8 @@ The landing page at
|
|
|
24
24
|
[alesanfra.github.io/iterframes](https://alesanfra.github.io/iterframes/)
|
|
25
25
|
shows what the decoder does while your loop runs. The documentation is at
|
|
26
26
|
[iterframes.readthedocs.io](https://iterframes.readthedocs.io): the
|
|
27
|
-
[
|
|
28
|
-
documents every argument and error, and the
|
|
27
|
+
[guides](https://iterframes.readthedocs.io/en/latest/guides/) explain the features, the
|
|
28
|
+
[API](https://iterframes.readthedocs.io/en/latest/api/) documents every argument and error, and the
|
|
29
29
|
[development guide](https://iterframes.readthedocs.io/en/latest/development/)
|
|
30
30
|
covers building from source.
|
|
31
31
|
|
|
@@ -55,7 +55,8 @@ twice as long: the decoding had already happened.
|
|
|
55
55
|
`(height, width, 3)`, straight out of FFmpeg's buffers.
|
|
56
56
|
- **Batches as one array.** `read_batches` decodes into a single
|
|
57
57
|
`(batch, height, width, 3)` block, ready for a model.
|
|
58
|
-
- **Resizing while decoding**, not a `cv2.resize` afterwards
|
|
58
|
+
- **Resizing while decoding**, not a `cv2.resize` afterwards, from
|
|
59
|
+
nearest to Lanczos.
|
|
59
60
|
- **Random access.** Read frames by number, without decoding the rest.
|
|
60
61
|
- **Hardware decoding** on NVIDIA GPUs (NVDEC) and Apple silicon
|
|
61
62
|
(VideoToolbox), in the wheels. On NVIDIA the frames can stay on the GPU
|
|
@@ -90,7 +91,7 @@ frame `n` is the one `read` yields `n`-th. iterframes indexes the file
|
|
|
90
91
|
once, without decoding it, then decodes each frame from the key frame
|
|
91
92
|
before it; frames asked for in order cost no more than reading the video
|
|
92
93
|
straight through. See
|
|
93
|
-
[Reading frames by number](https://iterframes.readthedocs.io/en/latest/
|
|
94
|
+
[Reading frames by number](https://iterframes.readthedocs.io/en/latest/guides/#reading-frames-by-number).
|
|
94
95
|
|
|
95
96
|
When a frame nearby will do, `approximate` reads the key frame closest to
|
|
96
97
|
each of `frames`, which costs one decoded frame instead of the frames from
|
|
@@ -101,7 +102,7 @@ the key frame on:
|
|
|
101
102
|
frames = list(iterframes.read("video.mp4", frames=[100, 200, 300], approximate=5))
|
|
102
103
|
```
|
|
103
104
|
|
|
104
|
-
See [Approximate frames](https://iterframes.readthedocs.io/en/latest/
|
|
105
|
+
See [Approximate frames](https://iterframes.readthedocs.io/en/latest/guides/#approximate-frames).
|
|
105
106
|
|
|
106
107
|
## Hardware decoding
|
|
107
108
|
|
|
@@ -126,7 +127,7 @@ print(iterframes.DEVICES) # ('cpu', 'mps') on a Mac
|
|
|
126
127
|
|
|
127
128
|
The frames still arrive as NumPy arrays in memory. A GPU saves CPU time
|
|
128
129
|
but is not always faster than the CPU decoder, so measure both; see
|
|
129
|
-
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/
|
|
130
|
+
[Hardware decoding](https://iterframes.readthedocs.io/en/latest/guides/#hardware-decoding).
|
|
130
131
|
|
|
131
132
|
With an NVIDIA GPU, `on_device=True` keeps the frames on it, in NV12, for
|
|
132
133
|
PyTorch and other libraries to take without a copy:
|
|
@@ -139,7 +140,7 @@ for frame in iterframes.read("video.mp4", device="cuda", on_device=True):
|
|
|
139
140
|
uv = torch.from_dlpack(frame.uv) # (height / 2, width / 2, 2)
|
|
140
141
|
```
|
|
141
142
|
|
|
142
|
-
[Frames on the GPU](https://iterframes.readthedocs.io/en/latest/
|
|
143
|
+
[Frames on the GPU](https://iterframes.readthedocs.io/en/latest/guides/#frames-on-the-gpu) shows how to
|
|
143
144
|
convert them to RGB there.
|
|
144
145
|
|
|
145
146
|
## Compared with OpenCV, decord, and PyAV
|
|
@@ -179,7 +180,10 @@ lists features that are waiting for someone to build them.
|
|
|
179
180
|
|
|
180
181
|
## License
|
|
181
182
|
|
|
182
|
-
iterframes is released under the [
|
|
183
|
-
[FFmpeg](https://ffmpeg.org/), built under the LGPL, and
|
|
183
|
+
iterframes is released under the [Apache License 2.0](https://github.com/alesanfra/iterframes/blob/main/LICENSE).
|
|
184
|
+
The wheels include [FFmpeg](https://ffmpeg.org/), built under the LGPL, and
|
|
184
185
|
[dav1d](https://code.videolan.org/videolan/dav1d), under the BSD 2-clause
|
|
185
|
-
license.
|
|
186
|
+
license. They are listed in
|
|
187
|
+
[`NOTICE`](https://github.com/alesanfra/iterframes/blob/main/NOTICE), with
|
|
188
|
+
their license texts in
|
|
189
|
+
[`licenses/`](https://github.com/alesanfra/iterframes/tree/main/licenses).
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# API
|
|
2
|
+
|
|
3
|
+
Everything lives in the top-level `iterframes` module.
|
|
4
|
+
|
|
5
|
+
## read
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
read(path, height=None, width=None, prefetch_frames=1, device="cpu", on_device=False, frames=None, start=0, stop=None, step=1, approximate=None, interpolation=None) -> Iterator[numpy.ndarray]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Yields the frames of the video at `path`, in order, or with `frames`, or
|
|
12
|
+
`start`, `stop`, and `step`, only those frames, in the order asked for.
|
|
13
|
+
Each frame is a C-contiguous, writable `numpy.ndarray` of shape
|
|
14
|
+
`(height, width, 3)` and dtype `uint8`, holding RGB pixels.
|
|
15
|
+
|
|
16
|
+
| Argument | Description |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `path` | Path of the video, as a `str` or `os.PathLike` |
|
|
19
|
+
| `height` | Height of the frames. Defaults to the height of the video |
|
|
20
|
+
| `width` | Width of the frames. Defaults to the width of the video |
|
|
21
|
+
| `prefetch_frames` | How many decoded frames may wait for your code. Defaults to 1 |
|
|
22
|
+
| `device` | Where to decode: `"cpu"`, `"auto"`, or a name from `DEVICES`. Defaults to `"cpu"`. See [Hardware decoding](guides.md#hardware-decoding) |
|
|
23
|
+
| `on_device` | With `device="cuda"`, yield `CudaFrame` objects left on the GPU instead of arrays. See [Frames on the GPU](guides.md#frames-on-the-gpu) |
|
|
24
|
+
| `frames` | The numbers of the frames to read, in the order to read them. See [Reading frames by number](guides.md#reading-frames-by-number) |
|
|
25
|
+
| `start`, `stop`, `step` | The frames to read, as a slice of the video |
|
|
26
|
+
| `approximate` | With `frames`, read the key frame nearest to each of them instead, when it is within this many frames. `True` is any distance. See [Approximate frames](guides.md#approximate-frames) |
|
|
27
|
+
| `interpolation` | How frames are resized: `"nearest"`, `"bilinear"`, `"bicubic"`, `"area"`, or `"lanczos"`. Defaults to bilinear on the CPU. See [Resizing](guides.md#resizing) |
|
|
28
|
+
|
|
29
|
+
Frames are resized with bilinear interpolation, unless `interpolation`
|
|
30
|
+
says otherwise. When only one of `height`
|
|
31
|
+
and `width` is given, the other keeps the size of the video, so the aspect
|
|
32
|
+
ratio changes.
|
|
33
|
+
|
|
34
|
+
Decoding starts when the first frame is requested, on a background thread
|
|
35
|
+
that runs ahead of your code by up to `prefetch_frames` frames. The thread
|
|
36
|
+
never takes the GIL, so it decodes the next frames while your code
|
|
37
|
+
processes the current one, even when that code holds the GIL. A larger
|
|
38
|
+
`prefetch_frames` smooths out frames that take longer to decode, at the
|
|
39
|
+
cost of memory: one 1080p frame takes about 6 MB.
|
|
40
|
+
|
|
41
|
+
The decoder stops when the iterator is exhausted or garbage-collected, for
|
|
42
|
+
example after a `break`.
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import iterframes
|
|
46
|
+
|
|
47
|
+
for frame in iterframes.read("video.mp4", height=270, width=480):
|
|
48
|
+
print(frame.shape) # (270, 480, 3)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## read_batches
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
read_batches(path, batch_size, height=None, width=None, prefetch_frames=1, device="cpu", drop_last=False, frames=None, start=0, stop=None, step=1, approximate=None, interpolation=None) -> Iterator[numpy.ndarray]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Yields the frames of the video in batches, in order, for models that take
|
|
58
|
+
several frames at once. Each batch is a C-contiguous, writable
|
|
59
|
+
`numpy.ndarray` of shape `(batch_size, height, width, 3)` and dtype
|
|
60
|
+
`uint8`. The frames are decoded straight into it, so unlike `numpy.stack`
|
|
61
|
+
over the frames of `read`, making a batch costs your code no copy.
|
|
62
|
+
|
|
63
|
+
| Argument | Description |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| `batch_size` | Frames per batch, at least 1 |
|
|
66
|
+
| `prefetch_frames` | How many decoded frames may wait for your code, rounded up to whole batches. Defaults to 1, that is one batch |
|
|
67
|
+
| `drop_last` | Drop the last batch when the video ends before it is full. By default it is yielded with the frames left over |
|
|
68
|
+
|
|
69
|
+
The other arguments are those of [`read`](#read); `on_device` is not
|
|
70
|
+
supported. Every frame of a batch has the size of the first frame of the
|
|
71
|
+
video, or `height` and `width`.
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
for batch in iterframes.read_batches("video.mp4", 12, height=224, width=224):
|
|
75
|
+
print(batch.shape) # (12, 224, 224, 3), except maybe the last one
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Errors
|
|
79
|
+
|
|
80
|
+
Errors are raised by the first `next()` on the iterator, not by the call
|
|
81
|
+
to `read`, because decoding starts only then.
|
|
82
|
+
|
|
83
|
+
| Exception | When |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `FileNotFoundError`, `PermissionError`, `OSError` | The file cannot be opened. The exception carries `errno` and `filename` |
|
|
86
|
+
| `ValueError` | The file is not a video FFmpeg can read, or has no video stream |
|
|
87
|
+
| `RuntimeError` | Decoding fails after the video has been opened, for instance on a codec that the build does not include |
|
|
88
|
+
| `IndexError` | `frames` asks for a frame the video does not have |
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
try:
|
|
92
|
+
frames = list(iterframes.read("missing.mp4"))
|
|
93
|
+
except FileNotFoundError as error:
|
|
94
|
+
print(error.filename) # missing.mp4
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## FrameReader
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
FrameReader(path, height=None, width=None, prefetch_frames=1, device="cpu", on_device=False, batch_size=None, drop_last=False, frames=None, start=0, stop=None, step=1, approximate=None, interpolation=None)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The iterator behind `read` and `read_batches`. It yields `Frame` objects,
|
|
104
|
+
`CudaFrame` objects with `on_device=True`, or `Batch` objects with
|
|
105
|
+
`batch_size`.
|
|
106
|
+
|
|
107
|
+
## Frame
|
|
108
|
+
|
|
109
|
+
A decoded frame. It holds the pixels and exposes them through the buffer
|
|
110
|
+
protocol as a writable, C-contiguous `(height, width, 3)` block of
|
|
111
|
+
unsigned bytes, so that other libraries can read them without a copy:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import numpy as np
|
|
115
|
+
from iterframes import FrameReader
|
|
116
|
+
|
|
117
|
+
for frame in FrameReader("video.mp4"):
|
|
118
|
+
array = np.asarray(frame) # what read() yields
|
|
119
|
+
view = memoryview(frame) # no NumPy needed
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
The pixels stay alive as long as the frame or any array or view on it.
|
|
123
|
+
See [Frames without a copy](guides.md#frames-without-a-copy).
|
|
124
|
+
|
|
125
|
+
## Batch
|
|
126
|
+
|
|
127
|
+
Frames decoded into a single block of memory, which the buffer protocol
|
|
128
|
+
exposes as a writable, C-contiguous `(frames, height, width, 3)` block of
|
|
129
|
+
unsigned bytes. `read_batches` wraps it with `numpy.asarray`, which copies
|
|
130
|
+
nothing; its pixels stay alive as long as the batch or any array or view on
|
|
131
|
+
it.
|
|
132
|
+
|
|
133
|
+
## Constants
|
|
134
|
+
|
|
135
|
+
| Name | Value |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| `__version__` | Version of iterframes, such as `"0.4.0"` |
|
|
138
|
+
| `FFMPEG_VERSION` | Version of the FFmpeg that iterframes is linked to, such as `"9.0.2"` |
|
|
139
|
+
| `DEVICES` | Names accepted by `device` besides `"auto"`, such as `("cpu", "mps")` |
|
|
140
|
+
|
|
141
|
+
## Types
|
|
142
|
+
|
|
143
|
+
For type checkers, `iterframes.Device` and `iterframes.Interpolation` are
|
|
144
|
+
the `Literal` types of `device` and `interpolation`:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
Device = Literal["cpu", "mps", "cuda", "auto"]
|
|
148
|
+
Interpolation = Literal["nearest", "bilinear", "bicubic", "area", "lanczos"]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`Device` lists every name, while `DEVICES` lists those this platform has.
|