Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-imageio-ffmpeg for
openSUSE:Factory checked in at 2022-09-29 18:13:56
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-imageio-ffmpeg (Old)
and /work/SRC/openSUSE:Factory/.python-imageio-ffmpeg.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-imageio-ffmpeg"
Thu Sep 29 18:13:56 2022 rev:3 rq:1006879 version:0.4.7
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-imageio-ffmpeg/python-imageio-ffmpeg.changes
2020-04-15 20:08:04.670169743 +0200
+++
/work/SRC/openSUSE:Factory/.python-imageio-ffmpeg.new.2275/python-imageio-ffmpeg.changes
2022-09-29 18:14:56.647441500 +0200
@@ -1,0 +2,23 @@
+Thu Sep 29 02:35:44 UTC 2022 - Yogalakshmi Arunachalam <[email protected]>
+
+- v0.4.6 Latest
+ Formal support for Python 3.5 -3.10.
+ Automatically find available h264 encoders and choose the best.
+ Allow users to specify quality=None.
+ A fix for closing the std stream.
+
+- v0.4.5
+ Set daemon attribute instead of using deprecated setDaemon method.
+ Optional disabling of prevent_sigint using env var (#60).
+ Get rotation metadata (#39).
+- v0.4.4
+ Support for Aarch64.
+ Basic support to include audio when writing videos.
+
+- Version 0.4.3
+ Support for Python 3.9.
+ File object is closes after use just in case.
+- Version 0.4.2
+ Use latest version of ffmpeg (4.2.2)
+
+-------------------------------------------------------------------
Old:
----
imageio-ffmpeg-0.4.1.tar.gz
New:
----
imageio-ffmpeg-0.4.7.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-imageio-ffmpeg.spec ++++++
--- /var/tmp/diff_new_pack.R9XIs8/_old 2022-09-29 18:14:57.139442465 +0200
+++ /var/tmp/diff_new_pack.R9XIs8/_new 2022-09-29 18:14:57.143442472 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-imageio-ffmpeg
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-imageio-ffmpeg
-Version: 0.4.1
+Version: 0.4.7
Release: 0
Summary: FFMPEG wrapper for Python
License: BSD-2-Clause
++++++ imageio-ffmpeg-0.4.1.tar.gz -> imageio-ffmpeg-0.4.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/PKG-INFO
new/imageio-ffmpeg-0.4.7/PKG-INFO
--- old/imageio-ffmpeg-0.4.1/PKG-INFO 2020-02-24 15:11:03.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/PKG-INFO 2022-04-14 16:41:03.655295600 +0200
@@ -1,22 +1,12 @@
-Metadata-Version: 1.2
+Metadata-Version: 2.1
Name: imageio-ffmpeg
-Version: 0.4.1
+Version: 0.4.7
Summary: FFMPEG wrapper for Python
Home-page: https://github.com/imageio/imageio-ffmpeg
Author: imageio contributors
Author-email: [email protected]
License: BSD-2-Clause
Download-URL: http://pypi.python.org/pypi/imageio-ffmpeg
-Description: FFMPEG wrapper for Python.
-
- Note that the platform-specific wheels contain the binary executable
- of ffmpeg, which makes this package around 60 MiB in size.
- I guess that's the cost for being able to read/write video files.
-
- For Linux users: the above is not the case when installing via your
- Linux package manager (if that is possible), because this package would
- simply depend on ffmpeg in that case.
-
Keywords: video ffmpeg
Platform: any
Classifier: Development Status :: 5 - Production/Stable
@@ -29,10 +19,24 @@
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
Provides: imageio_ffmpeg
-Requires-Python: >=3.4
+Requires-Python: >=3.5
+License-File: LICENSE
+
+FFMPEG wrapper for Python.
+
+Note that the platform-specific wheels contain the binary executable
+of ffmpeg, which makes this package around 60 MiB in size.
+I guess that's the cost for being able to read/write video files.
+
+For Linux users: the above is not the case when installing via your
+Linux package manager (if that is possible), because this package would
+simply depend on ffmpeg in that case.
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/README.md
new/imageio-ffmpeg-0.4.7/README.md
--- old/imageio-ffmpeg-0.4.1/README.md 2020-02-24 14:13:52.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/README.md 2022-04-13 10:53:45.000000000 +0200
@@ -1,6 +1,6 @@
# imageio-ffmpeg
-[](https://travis-ci.org/imageio/imageio-ffmpeg)
+[](https://github.com/imageio/imageio-ffmpeg/actions)
[](https://pypi.python.org/pypi/imageio-ffmpeg/)
FFMPEG wrapper for Python
@@ -22,7 +22,7 @@
## Installation
-This library works with any version of Python 3.4+ (including Pypy).
+This library works with any version of Python 3.5+ (including Pypy).
There are no further dependencies. The wheels on Pypi include the ffmpeg
executable for all common platforms (Windows 7+, Linux kernel 2.6.32+,
OSX 10.9+). Install using:
@@ -99,6 +99,15 @@
Tidelift will coordinate the fix and disclosure.
+## Environment variables
+
+The library can be configured at runtime by setting the following environment
+variables:
+* `IMAGEIO_FFMPEG_EXE=[file name]` -- override the ffmpeg executable;
+* `IMAGEIO_FFMPEG_NO_PREVENT_SIGINT=1` -- don't prevent propagation of SIGINT
+ to the ffmpeg process.
+
+
## API
```py
@@ -112,19 +121,19 @@
):
"""
Create a generator to iterate over the frames in a video file.
-
+
It first yields a small metadata dictionary that contains:
-
+
* ffmpeg_version: the ffmpeg version in use (as a string).
* codec: a hint about the codec used to encode the video, e.g. "h264".
* source_size: the width and height of the encoded video frames.
* size: the width and height of the frames that will be produced.
* fps: the frames per second. Can be zero if it could not be detected.
* duration: duration in seconds. Can be zero if it could not be detected.
-
+
After that, it yields frames until the end of the video is reached. Each
frame is a bytes object.
-
+
This function makes no assumptions about the number of frames in
the data. For one because this is hard to predict exactly, but also
because it may depend on the provided output_params. If you want
@@ -132,14 +141,14 @@
It is also possible to estimate the number of frames from the fps and
duration, but note that even if both numbers are present, the resulting
value is not always correct.
-
+
Example:
-
+
gen = read_frames(path)
meta = gen.__next__()
for frame in gen:
print(len(frame))
-
+
Parameters:
path (str): the filename of the file to read from.
pix_fmt (str): the pixel format of the frames to be read.
@@ -166,25 +175,27 @@
codec=None,
macro_block_size=16,
ffmpeg_log_level="warning",
- ffmpeg_timeout=0,
+ ffmpeg_timeout=None,
input_params=None,
output_params=None,
+ audio_path=None,
+ audio_codec=None,
):
"""
Create a generator to write frames (bytes objects) into a video file.
-
+
The frames are written by using the generator's `send()` method. Frames
can be anything that can be written to a file. Typically these are
bytes objects, but c-contiguous Numpy arrays also work.
-
+
Example:
-
+
gen = write_frames(path, size)
gen.send(None) # seed the generator
for frame in frames:
gen.send(frame)
gen.close() # don't forget this
-
+
Parameters:
path (str): the filename to write to.
size (tuple): the width and height of the frames.
@@ -195,16 +206,22 @@
quality (float): A measure for quality between 0 and 10. Default 5.
Ignored if bitrate is given.
bitrate (str): The bitrate, e.g. "192k". The defaults are pretty good.
- codec (str): The codec. Default "libx264" (or "msmpeg4" for .wmv).
+ codec (str): The codec. Default "libx264" for .mp4 (if available from
+ the ffmpeg executable) or "msmpeg4" for .wmv.
macro_block_size (int): You probably want to align the size of frames
to this value to avoid image resizing. Default 16. Can be set
to 1 to avoid block alignment, though this is not recommended.
ffmpeg_log_level (str): The ffmpeg logging level. Default "warning".
ffmpeg_timeout (float): Timeout in seconds to wait for ffmpeg process
- to finish. Value of 0 will wait forever (default). The time that
+ to finish. Value of 0 or None will wait forever (default). The
time that
ffmpeg needs depends on CPU speed, compression, and frame size.
input_params (list): Additional ffmpeg input command line parameters.
output_params (list): Additional ffmpeg output command line parameters.
+ audio_path (str): A input file path for encoding with an audio stream.
+ Default None, no audio.
+ audio_codec (str): The audio codec to use if audio_path is provided.
+ "copy" will try to use audio_path's audio codec without
re-encoding.
+ Default None, but some formats must have certain codecs specified.
"""
```
@@ -213,7 +230,7 @@
"""
Get the number of frames and number of seconds for the given video
file. Note that this operation can be quite slow for large files.
-
+
Disclaimer: I've seen this produce different results from actually reading
the frames with older versions of ffmpeg (2.x). Therefore I cannot say
with 100% certainty that the returned values are always exact.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_definitions.py
new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_definitions.py
--- old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_definitions.py 2020-02-24
15:10:39.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_definitions.py 2022-04-14
16:40:27.000000000 +0200
@@ -1,13 +1,15 @@
import sys
import struct
-__version__ = "0.4.1"
+__version__ = "0.4.7"
def get_platform():
bits = struct.calcsize("P") * 8
if sys.platform.startswith("linux"):
return "linux{}".format(bits)
+ elif sys.platform.startswith("freebsd"):
+ return "freebsd{}".format(bits)
elif sys.platform.startswith("win"):
return "win{}".format(bits)
elif sys.platform.startswith("cygwin"):
@@ -28,11 +30,12 @@
# Platform string -> ffmpeg filename
FNAME_PER_PLATFORM = {
- "osx64": "ffmpeg-osx64-v4.1", # 10.9+
- "win32": "ffmpeg-win32-v4.1.exe", # Windows 7+
- "win64": "ffmpeg-win64-v4.1.exe",
- # "linux32": "ffmpeg-linux32-v4.1",
- "linux64": "ffmpeg-linux64-v4.1", # Kernel 2.6.32+
+ "osx64": "ffmpeg-osx64-v4.2.2", # 10.10+
+ "win32": "ffmpeg-win32-v4.2.2.exe", # Windows 7+
+ "win64": "ffmpeg-win64-v4.2.2.exe",
+ # "linux32": "ffmpeg-linux32-v4.2.2",
+ "linux64": "ffmpeg-linux64-v4.2.2", # Kernel 3.2.0+
+ "linuxaarch64": "ffmpeg-linuxaarch64-v4.2.2",
}
osxplats =
"macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64"
@@ -40,6 +43,7 @@
# Wheel tag -> platform string
WHEEL_BUILDS = {
"py3-none-manylinux2010_x86_64": "linux64",
+ "py3-none-manylinux2014_aarch64": "linuxaarch64",
"py3-none-" + osxplats: "osx64",
"py3-none-win32": "win32",
"py3-none-win_amd64": "win64",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_io.py
new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_io.py
--- old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_io.py 2020-02-24
15:10:39.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_io.py 2022-04-14
16:39:55.000000000 +0200
@@ -2,6 +2,8 @@
import time
import pathlib
import subprocess
+from functools import lru_cache
+from collections import defaultdict
from ._utils import get_ffmpeg_exe, _popen_kwargs, logger
from ._parsing import LogCatcher, parse_ffmpeg_header, cvsecs
@@ -9,22 +11,137 @@
ISWIN = sys.platform.startswith("win")
+h264_encoder_preference = defaultdict(lambda: -1)
+# The libx264 was the default encoder for a longe time with imageio
+h264_encoder_preference["libx264"] = 100
+
+# Encoder with the nvidia graphics card dedicated hardware
+h264_encoder_preference["h264_nvenc"] = 90
+# Deprecated names for the same encoder
+h264_encoder_preference["nvenc_h264"] = 90
+h264_encoder_preference["nvenc"] = 90
+
+# vaapi provides hardware encoding with intel integrated graphics chipsets
+h264_encoder_preference["h264_vaapi"] = 80
+
+# openh264 is cisco's open source encoder
+h264_encoder_preference["libopenh264"] = 70
+
+h264_encoder_preference["libx264rgb"] = 50
+
+
+def ffmpeg_test_encoder(encoder):
+ # Use the null streams to validate if we can encode anything
+ # https://trac.ffmpeg.org/wiki/Null
+ cmd = [
+ _get_exe(),
+ "-hide_banner",
+ "-f",
+ "lavfi",
+ "-i",
+ "nullsrc=s=256x256:d=8",
+ "-vcodec",
+ encoder,
+ "-f",
+ "null",
+ "-",
+ ]
+ p = subprocess.run(
+ cmd,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ return p.returncode == 0
+
-exe = None
+def get_compiled_h264_encoders():
+ cmd = [_get_exe(), "-hide_banner", "-encoders"]
+ p = subprocess.run(
+ cmd,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ stdout = p.stdout.decode().replace("\r", "")
+ # 2022/04/08: hmaarrfk
+ # I couldn't find a good way to get the list of available encoders from
+ # the ffmpeg command
+ # The ffmpeg command return a table that looks like
+ # Notice the leading space at the very beginning
+ # On ubuntu with libffmpeg-nvenc-dev we get
+ # $ ffmpeg -hide_banner -encoders | grep -i h.264
+ #
+ # Encoders:
+ # V..... = Video
+ # A..... = Audio
+ # S..... = Subtitle
+ # .F.... = Frame-level multithreading
+ # ..S... = Slice-level multithreading
+ # ...X.. = Codec is experimental
+ # ....B. = Supports draw_horiz_band
+ # .....D = Supports direct rendering method 1
+ # ------
+ # V..... libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4
part 10 (codec h264)
+ # V..... libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4
part 10 RGB (codec h264)
+ # V....D h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
+ # V..... h264_omx OpenMAX IL H.264 video encoder (codec h264)
+ # V..... h264_qsv H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
(Intel Quick Sync Video acceleration) (codec h264)
+ # V..... h264_v4l2m2m V4L2 mem2mem H.264 encoder wrapper (codec
h264)
+ # V....D h264_vaapi H.264/AVC (VAAPI) (codec h264)
+ # V..... nvenc NVIDIA NVENC H.264 encoder (codec h264)
+ # V..... nvenc_h264 NVIDIA NVENC H.264 encoder (codec h264)
+ #
+ # However, just because ffmpeg was compiled with the options enabled
+ # it doesn't mean that it will be successful
+ header_footer = stdout.split("------")
+ footer = header_footer[1].strip("\n")
+ encoders = []
+ for line in footer.split("\n"):
+ # Strip to remove any leading spaces
+ line = line.strip()
+ encoder = line.split(" ")[1]
+
+ if encoder in h264_encoder_preference:
+ # These encoders are known to support H.264
+ # We forcibly include them in case their description changes to
+ # not include the string "H.264"
+ encoders.append(encoder)
+ elif (line[0] == "V") and ("H.264" in line):
+ encoders.append(encoder)
+
+ encoders.sort(reverse=True, key=lambda x: h264_encoder_preference[x])
+ if "h264_nvenc" in encoders:
+ # Remove deprecated names for the same encoder
+ for encoder in ["nvenc", "nvenc_h264"]:
+ if encoder in encoders:
+ encoders.remove(encoder)
+ # Return an immutable tuple to avoid users corrupting the lru_cache
+ return tuple(encoders)
+
+
+@lru_cache()
+def get_first_available_h264_encoder():
+ compiled_encoders = get_compiled_h264_encoders()
+ for encoder in compiled_encoders:
+ if ffmpeg_test_encoder(encoder):
+ return encoder
+ else:
+ raise RuntimeError(
+ "No valid H.264 encoder was found with the ffmpeg installation"
+ )
+@lru_cache()
def _get_exe():
- global exe
- if exe is None:
- exe = get_ffmpeg_exe()
- return exe
+ return get_ffmpeg_exe()
def count_frames_and_secs(path):
"""
Get the number of frames and number of seconds for the given video
file. Note that this operation can be quite slow for large files.
-
+
Disclaimer: I've seen this produce different results from actually reading
the frames with older versions of ffmpeg (2.x). Therefore I cannot say
with 100% certainty that the returned values are always exact.
@@ -73,19 +190,19 @@
):
"""
Create a generator to iterate over the frames in a video file.
-
+
It first yields a small metadata dictionary that contains:
-
+
* ffmpeg_version: the ffmpeg version in use (as a string).
* codec: a hint about the codec used to encode the video, e.g. "h264".
* source_size: the width and height of the encoded video frames.
* size: the width and height of the frames that will be produced.
* fps: the frames per second. Can be zero if it could not be detected.
* duration: duration in seconds. Can be zero if it could not be detected.
-
+
After that, it yields frames until the end of the video is reached. Each
frame is a bytes object.
-
+
This function makes no assumptions about the number of frames in
the data. For one because this is hard to predict exactly, but also
because it may depend on the provided output_params. If you want
@@ -93,14 +210,14 @@
It is also possible to estimate the number of frames from the fps and
duration, but note that even if both numbers are present, the resulting
value is not always correct.
-
+
Example:
-
+
gen = read_frames(path)
meta = gen.__next__()
for frame in gen:
print(len(frame))
-
+
Parameters:
path (str): the filename of the file to read from.
pix_fmt (str): the pixel format of the frames to be read.
@@ -224,6 +341,8 @@
raise
finally:
+ # Stop the LogCatcher thread, which reads from stderr.
+ log_catcher.stop_me()
# Make sure that ffmpeg is terminated.
if p.poll() is None:
@@ -243,6 +362,7 @@
# p.stdin.write(b"q") # commented out in v0.4.1
p.stdout.close()
p.stdin.close()
+ # p.stderr.close() -> not here, the log_catcher closes it
except Exception as err: # pragma: no cover
logger.warning("Error while attempting stop ffmpeg (r): " +
str(err))
@@ -276,22 +396,24 @@
ffmpeg_timeout=None,
input_params=None,
output_params=None,
+ audio_path=None,
+ audio_codec=None,
):
"""
Create a generator to write frames (bytes objects) into a video file.
-
+
The frames are written by using the generator's `send()` method. Frames
can be anything that can be written to a file. Typically these are
bytes objects, but c-contiguous Numpy arrays also work.
-
+
Example:
-
+
gen = write_frames(path, size)
gen.send(None) # seed the generator
for frame in frames:
gen.send(frame)
gen.close() # don't forget this
-
+
Parameters:
path (str): the filename to write to.
size (tuple): the width and height of the frames.
@@ -302,7 +424,8 @@
quality (float): A measure for quality between 0 and 10. Default 5.
Ignored if bitrate is given.
bitrate (str): The bitrate, e.g. "192k". The defaults are pretty good.
- codec (str): The codec. Default "libx264" (or "msmpeg4" for .wmv).
+ codec (str): The codec. Default "libx264" for .mp4 (if available from
+ the ffmpeg executable) or "msmpeg4" for .wmv.
macro_block_size (int): You probably want to align the size of frames
to this value to avoid image resizing. Default 16. Can be set
to 1 to avoid block alignment, though this is not recommended.
@@ -312,6 +435,11 @@
ffmpeg needs depends on CPU speed, compression, and frame size.
input_params (list): Additional ffmpeg input command line parameters.
output_params (list): Additional ffmpeg output command line parameters.
+ audio_path (str): A input file path for encoding with an audio stream.
+ Default None, no audio.
+ audio_codec (str): The audio codec to use if audio_path is provided.
+ "copy" will try to use audio_path's audio codec without
re-encoding.
+ Default None, but some formats must have certain codecs specified.
"""
# ----- Input args
@@ -331,7 +459,6 @@
pix_fmt_in = pix_fmt_in or "rgb24"
pix_fmt_out = pix_fmt_out or "yuv420p"
fps = fps or 16
- quality = quality or 5
# bitrate, codec, macro_block_size can all be None or ...
macro_block_size = macro_block_size or 16
ffmpeg_log_level = ffmpeg_log_level or "warning"
@@ -354,8 +481,9 @@
assert isinstance(pix_fmt_in, str), "pix_fmt_in must be str"
assert isinstance(pix_fmt_out, str), "pix_fmt_out must be str"
assert isinstance(fps, floatish), "fps must be float"
- assert isinstance(quality, floatish), "quality must be float"
- assert 1 <= quality <= 10, "quality must be between 1 and 10 inclusive"
+ if quality is not None:
+ assert isinstance(quality, floatish), "quality must be float"
+ assert 1 <= quality <= 10, "quality must be between 1 and 10 inclusive"
assert isinstance(macro_block_size, int), "macro_block_size must be int"
assert isinstance(ffmpeg_log_level, str), "ffmpeg_log_level must be str"
assert isinstance(ffmpeg_timeout, floatish), "ffmpeg_timeout must be float"
@@ -365,19 +493,27 @@
# ----- Prepare
# Get parameters
- default_codec = "libx264"
- if path.lower().endswith(".wmv"):
- # This is a safer default codec on windows to get videos that
- # will play in powerpoint and other apps. H264 is not always
- # available on windows.
- default_codec = "msmpeg4"
- codec = codec or default_codec
+ if not codec:
+ if path.lower().endswith(".wmv"):
+ # This is a safer default codec on windows to get videos that
+ # will play in powerpoint and other apps. H264 is not always
+ # available on windows.
+ codec = "msmpeg4"
+ else:
+ codec = get_first_available_h264_encoder()
+
+ audio_params = ["-an"]
+ if audio_path is not None and not path.lower().endswith(".gif"):
+ audio_params = ["-i", audio_path]
+ if audio_codec is not None:
+ output_params += ["-acodec", audio_codec]
+ output_params += ["-map", "0:v:0", "-map", "1:a:0"]
# Get command
cmd = [_get_exe(), "-y", "-f", "rawvideo", "-vcodec", "rawvideo", "-s",
sizestr]
cmd += ["-pix_fmt", pix_fmt_in, "-r", "{:.02f}".format(fps)] + input_params
- cmd += ["-i", "-"]
- cmd += ["-an", "-vcodec", codec, "-pix_fmt", pix_fmt_out]
+ cmd += ["-i", "-"] + audio_params
+ cmd += ["-vcodec", codec, "-pix_fmt", pix_fmt_out]
# Add fixed bitrate or variable bitrate compression flags
if bitrate is not None:
@@ -540,3 +676,8 @@
else: # stop_policy == "kill":
# Just kill it
p.kill()
+ # Just to be safe, wrap in try/except
+ try:
+ p.stdout.close()
+ except Exception:
+ pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_parsing.py
new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_parsing.py
--- old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_parsing.py 2020-02-17
15:15:44.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_parsing.py 2022-04-14
16:39:55.000000000 +0200
@@ -6,7 +6,7 @@
class LogCatcher(threading.Thread):
- """ Thread to keep reading from stderr so that the buffer does not
+ """Thread to keep reading from stderr so that the buffer does not
fill up and stalls the ffmpeg process. On stderr a message is send
on every few frames with some meta information. We only keep the
last ones.
@@ -18,7 +18,7 @@
self._lines = []
self._remainder = b""
threading.Thread.__init__(self)
- self.setDaemon(True) # do not let this thread hold up Python shutdown
+ self.daemon = True # do not let this thread hold up Python shutdown
self._should_stop = False
self.start()
@@ -27,12 +27,11 @@
@property
def header(self):
- """ Get header text. Empty string if the header is not yet parsed.
- """
+ """Get header text. Empty string if the header is not yet parsed."""
return self._header
def get_text(self, timeout=0):
- """ Get the whole text written to stderr so far. To preserve
+ """Get the whole text written to stderr so far. To preserve
memory, only the last 50 to 100 frames are kept.
If a timeout is given, wait for this thread to finish. When
@@ -43,7 +42,7 @@
# Wait?
if timeout > 0:
etime = time.time() + timeout
- while self.isAlive() and time.time() < etime: # pragma: no cover
+ while self.is_alive() and time.time() < etime: # pragma: no cover
time.sleep(0.01)
# Return str
lines = b"\n".join(self._lines)
@@ -77,6 +76,13 @@
elif self._lines:
self._lines = limit_lines_local(self._lines)
+ # Close the file when we're done
+ # See #61 and #69
+ try:
+ self._file.close()
+ except Exception:
+ pass
+
def get_output_video_line(lines):
"""Get the line that defines the video stream that ffmpeg outputs,
@@ -93,15 +99,14 @@
def limit_lines(lines, N=32):
- """ When number of lines > 2*N, reduce to N.
- """
+ """When number of lines > 2*N, reduce to N."""
if len(lines) > 2 * N:
lines = [b"... showing only last few lines ..."] + lines[-N:]
return lines
def cvsecs(*args):
- """ converts a time to second. Either cvsecs(min, secs) or
+ """converts a time to second. Either cvsecs(min, secs) or
cvsecs(hours, mins, secs).
"""
if len(args) == 1:
@@ -132,6 +137,17 @@
meta["codec"] = line.split("Video: ", 1)[-1].lstrip().split(" ",
1)[0].strip()
meta["pix_fmt"] = line.split("Video: ", 1)[-1].split(",")[1].strip()
+ # get the output line that speaks about audio
+ audiolines = [
+ l for l in lines if l.lstrip().startswith("Stream ") and " Audio: " in
l
+ ]
+
+ if len(audiolines) > 0:
+ audio_line = audiolines[0]
+ meta["audio_codec"] = (
+ audio_line.split("Audio: ", 1)[-1].lstrip().split(" ",
1)[0].strip()
+ )
+
# get the frame rate.
# matches can be empty, see #171, assume nframes = inf
# the regexp omits values of "1k tbr" which seems a specific edge-case #262
@@ -165,6 +181,14 @@
)
)
+ # get the rotate metadata
+ reo_rotate = re.compile("rotate\s+:\s([0-9]+)")
+ match = reo_rotate.search(text)
+ rotate = 0
+ if match is not None:
+ rotate = match.groups()[0]
+ meta["rotate"] = int(rotate)
+
# get duration (in seconds)
line = [l for l in lines if "Duration: " in l][0]
match = re.search(" [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]", line)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_utils.py
new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_utils.py
--- old/imageio-ffmpeg-0.4.1/imageio_ffmpeg/_utils.py 2020-02-24
15:10:39.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/imageio_ffmpeg/_utils.py 2022-04-14
15:59:01.000000000 +0200
@@ -67,6 +67,12 @@
creationflags = 0x00000200
else:
preexec_fn = os.setpgrp # the _pre_exec does not seem to work
+
+ falsy = ("", "0", "false", "no")
+ if os.getenv("IMAGEIO_FFMPEG_NO_PREVENT_SIGINT", "").lower() not in falsy:
+ # Unset preexec_fn to work around a strange hang on fork() (see #58)
+ preexec_fn = None
+
return {
"startupinfo": startupinfo,
"creationflags": creationflags,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/imageio-ffmpeg-0.4.1/imageio_ffmpeg.egg-info/PKG-INFO
new/imageio-ffmpeg-0.4.7/imageio_ffmpeg.egg-info/PKG-INFO
--- old/imageio-ffmpeg-0.4.1/imageio_ffmpeg.egg-info/PKG-INFO 2020-02-24
15:11:03.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/imageio_ffmpeg.egg-info/PKG-INFO 2022-04-14
16:41:03.000000000 +0200
@@ -1,22 +1,12 @@
-Metadata-Version: 1.2
+Metadata-Version: 2.1
Name: imageio-ffmpeg
-Version: 0.4.1
+Version: 0.4.7
Summary: FFMPEG wrapper for Python
Home-page: https://github.com/imageio/imageio-ffmpeg
Author: imageio contributors
Author-email: [email protected]
License: BSD-2-Clause
Download-URL: http://pypi.python.org/pypi/imageio-ffmpeg
-Description: FFMPEG wrapper for Python.
-
- Note that the platform-specific wheels contain the binary executable
- of ffmpeg, which makes this package around 60 MiB in size.
- I guess that's the cost for being able to read/write video files.
-
- For Linux users: the above is not the case when installing via your
- Linux package manager (if that is possible), because this package would
- simply depend on ffmpeg in that case.
-
Keywords: video ffmpeg
Platform: any
Classifier: Development Status :: 5 - Production/Stable
@@ -29,10 +19,24 @@
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
+Classifier: Programming Language :: Python :: 3.10
Provides: imageio_ffmpeg
-Requires-Python: >=3.4
+Requires-Python: >=3.5
+License-File: LICENSE
+
+FFMPEG wrapper for Python.
+
+Note that the platform-specific wheels contain the binary executable
+of ffmpeg, which makes this package around 60 MiB in size.
+I guess that's the cost for being able to read/write video files.
+
+For Linux users: the above is not the case when installing via your
+Linux package manager (if that is possible), because this package would
+simply depend on ffmpeg in that case.
+
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/imageio-ffmpeg-0.4.1/setup.py
new/imageio-ffmpeg-0.4.7/setup.py
--- old/imageio-ffmpeg-0.4.1/setup.py 2020-02-24 14:13:52.000000000 +0100
+++ new/imageio-ffmpeg-0.4.7/setup.py 2022-04-13 10:52:15.000000000 +0200
@@ -56,7 +56,7 @@
long_description=long_description,
platforms="any",
provides=["imageio_ffmpeg"],
- python_requires=">=3.4",
+ python_requires=">=3.5",
setup_requires=["pip>19"],
install_requires=[],
packages=["imageio_ffmpeg"],
@@ -75,10 +75,11 @@
"Operating System :: POSIX",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
- "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
)