Skip to content

Commit 42139f9

Browse files
authored
Py38 (#31)
* add/test py3.8 * also try testing on windows and pypy3 * update readme * Looking into it * update api doc texts a bit * whatever * get more info * get more info * try * ok ... try shipping ms redis * undo * disable windows CI build (aka give up)
1 parent a19c761 commit 42139f9

File tree

4 files changed

+46
-25
lines changed

4 files changed

+46
-25
lines changed

.travis.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ matrix:
2020
python: "3.6"
2121
env: TEST_UNIT=0 TEST_STYLE=1
2222
# Special OS'es / interpreters
23-
#- os: windows
24-
# language: bash
25-
# env: TEST_UNIT=1
23+
# - os: windows -> does not work, calling ffmpeg.exe fails with exitcode 3221225781 (missing library?)
24+
# language: bash
25+
# env: TEST_UNIT=1
26+
- os: linux
27+
python: "pypy3"
28+
env: TEST_UNIT=1
2629
# The main tests run on Linux for a all relevant Python versions.
2730
- os: linux
2831
python: "3.4"
@@ -34,7 +37,10 @@ matrix:
3437
python: "3.6"
3538
env: TEST_UNIT=1 TEST_COVER=1
3639
- os: linux
37-
python: "3.7-dev"
40+
python: "3.7"
41+
env: TEST_UNIT=1
42+
- os: linux
43+
python: "3.8-dev"
3844
env: TEST_UNIT=1
3945

4046

@@ -74,6 +80,7 @@ install:
7480
export PATH=/c/Python38:/c/Python38/Scripts:/c/Python37:/c/Python37/Scripts:$PATH;
7581
fi;
7682
# Install dependencies depending on ENV
83+
# - pip install -U pip -> not allowed on Windows (?)
7784
- pip install invoke
7885
- if [ "${TEST_UNIT}" == "1" ]; then
7986
pip install -q psutil;
@@ -86,7 +93,7 @@ install:
8693

8794
before_script:
8895

89-
script:
96+
script:
9097
- python -c "import sys; print(sys.version, '\n', sys.prefix)";
9198
# Run unit tests or style test
9299
- if [ "${TEST_STYLE}" == "1" ]; then

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,30 @@ making distribution and installation *much* easier. And probably
7777
the code itself too. In contrast, [PyAV](https://github.com/mikeboers/PyAV)
7878
wraps ffmpeg at the C level.
7979

80+
Note that because of how `imageio-ffmpeg` works, `read_frames()` and
81+
`write_frames()` only accept file names, and not file (like) objects.
82+
8083

8184
## API
8285

8386
```py
84-
def read_frames(path, pix_fmt="rgb24", bpp=3, input_params=None, output_params=None):
87+
def read_frames(
88+
path,
89+
pix_fmt="rgb24",
90+
bpp=None,
91+
input_params=None,
92+
output_params=None,
93+
bits_per_pixel=None,
94+
):
8595
"""
8696
Create a generator to iterate over the frames in a video file.
8797
8898
It first yields a small metadata dictionary that contains:
8999
90-
* ffmpeg_version: the ffmpeg version is use (as a string).
91-
* codec: a hint about the codec used to encode the video, e.g. "h264"
92-
* source_size: the width and height of the encoded video frames
93-
* size: the width and height of the frames that will be produced
100+
* ffmpeg_version: the ffmpeg version in use (as a string).
101+
* codec: a hint about the codec used to encode the video, e.g. "h264".
102+
* source_size: the width and height of the encoded video frames.
103+
* size: the width and height of the frames that will be produced.
94104
* fps: the frames per second. Can be zero if it could not be detected.
95105
* duration: duration in seconds. Can be zero if it could not be detected.
96106
@@ -113,13 +123,16 @@ def read_frames(path, pix_fmt="rgb24", bpp=3, input_params=None, output_params=N
113123
print(len(frame))
114124
115125
Parameters:
116-
path (str): the file to write to.
126+
path (str): the filename of the file to read from.
117127
pix_fmt (str): the pixel format of the frames to be read.
118128
The default is "rgb24" (frames are uint8 RGB images).
119-
bpp (int): The number of bytes per pixel in the output frames.
120-
This depends on the given pix_fmt. Default is 3 (RGB).
121129
input_params (list): Additional ffmpeg input command line parameters.
122130
output_params (list): Additional ffmpeg output command line parameters.
131+
bits_per_pixel (int): The number of bits per pixel in the output frames.
132+
This depends on the given pix_fmt. Default is 24 (RGB)
133+
bpp (int): DEPRECATED, USE bits_per_pixel INSTEAD. The number of bytes per pixel in the output frames.
134+
This depends on the given pix_fmt. Some pixel formats like yuv420p have 12 bits per pixel
135+
and cannot be set in bytes as integer. For this reason the bpp argument is deprecated.
123136
"""
124137
```
125138

@@ -135,7 +148,7 @@ def write_frames(
135148
codec=None,
136149
macro_block_size=16,
137150
ffmpeg_log_level="warning",
138-
ffmpeg_timeout=20.0,
151+
ffmpeg_timeout=0,
139152
input_params=None,
140153
output_params=None,
141154
):
@@ -155,7 +168,7 @@ def write_frames(
155168
gen.close() # don't forget this
156169
157170
Parameters:
158-
path (str): the file to write to.
171+
path (str): the filename to write to.
159172
size (tuple): the width and height of the frames.
160173
pix_fmt_in (str): the pixel format of incoming frames.
161174
E.g. "gray", "gray8a", "rgb24", or "rgba". Default "rgb24".
@@ -170,8 +183,8 @@ def write_frames(
170183
to 1 to avoid block alignment, though this is not recommended.
171184
ffmpeg_log_level (str): The ffmpeg logging level. Default "warning".
172185
ffmpeg_timeout (float): Timeout in seconds to wait for ffmpeg process
173-
to finish. Value of 0 will wait forever. The time that ffmpeg needs
174-
depends on CPU speed, compression, and frame size. Default 20.0.
186+
to finish. Value of 0 will wait forever (default). The time that
187+
ffmpeg needs depends on CPU speed, compression, and frame size.
175188
input_params (list): Additional ffmpeg input command line parameters.
176189
output_params (list): Additional ffmpeg output command line parameters.
177190
"""
@@ -192,7 +205,7 @@ def count_frames_and_secs(path):
192205
```py
193206
def get_ffmpeg_exe():
194207
"""
195-
Get the ffmpeg executable file. This can be the binary defined by
208+
Get the ffmpeg executable file. This can be the binary defined by
196209
the IMAGEIO_FFMPEG_EXE environment variable, the binary distributed
197210
with imageio-ffmpeg, an ffmpeg binary installed with conda, or the
198211
system ffmpeg (in that order). A RuntimeError is raised if no valid

imageio_ffmpeg/_io.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ def read_frames(
7676
7777
It first yields a small metadata dictionary that contains:
7878
79-
* ffmpeg_version: the ffmpeg version is use (as a string).
80-
* codec: a hint about the codec used to encode the video, e.g. "h264"
81-
* source_size: the width and height of the encoded video frames
82-
* size: the width and height of the frames that will be produced
79+
* ffmpeg_version: the ffmpeg version in use (as a string).
80+
* codec: a hint about the codec used to encode the video, e.g. "h264".
81+
* source_size: the width and height of the encoded video frames.
82+
* size: the width and height of the frames that will be produced.
8383
* fps: the frames per second. Can be zero if it could not be detected.
8484
* duration: duration in seconds. Can be zero if it could not be detected.
8585
@@ -102,7 +102,7 @@ def read_frames(
102102
print(len(frame))
103103
104104
Parameters:
105-
path (str): the file path to read from.
105+
path (str): the filename of the file to read from.
106106
pix_fmt (str): the pixel format of the frames to be read.
107107
The default is "rgb24" (frames are uint8 RGB images).
108108
input_params (list): Additional ffmpeg input command line parameters.
@@ -291,7 +291,7 @@ def write_frames(
291291
gen.close() # don't forget this
292292
293293
Parameters:
294-
path (str): the file to write to.
294+
path (str): the filename to write to.
295295
size (tuple): the width and height of the frames.
296296
pix_fmt_in (str): the pixel format of incoming frames.
297297
E.g. "gray", "gray8a", "rgb24", or "rgba". Default "rgb24".

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
provides=["imageio_ffmpeg"],
5959
python_requires=">=3.4",
6060
setup_requires=["pip>19"],
61-
install_requires=[], # todo: maybe numpy
61+
install_requires=[],
6262
packages=["imageio_ffmpeg"],
6363
package_dir={"imageio_ffmpeg": "imageio_ffmpeg"},
6464
package_data={"imageio_ffmpeg": ["binaries/*.*"]},
@@ -79,5 +79,6 @@
7979
"Programming Language :: Python :: 3.5",
8080
"Programming Language :: Python :: 3.6",
8181
"Programming Language :: Python :: 3.7",
82+
"Programming Language :: Python :: 3.8",
8283
],
8384
)

0 commit comments

Comments
 (0)