You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deface is quite handy for processing individual images, but it consistently encounters errors when I attempt to process MP4 files, and I'm uncertain of the underlying cause.
OS: macOS sonoma 14.3
Chip: Apple M1 Pro
Python Version: Python 3.11.7
Traceback (most recent call last):
File "/opt/homebrew/bin/deface", line 8, in<module>sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/deface/deface.py", line 398, in main
video_detect(
File "/opt/homebrew/lib/python3.11/site-packages/deface/deface.py", line 142, in video_detect
nframes = reader.count_frames()
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/imageio/plugins/ffmpeg.py", line 385, in count_frames
return cf(self._filename)[0]
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/imageio_ffmpeg/_io.py", line 187, in count_frames_and_secs
raise RuntimeError("Could not get number of frames") # pragma: no cover
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Could not get number of frames
The text was updated successfully, but these errors were encountered:
Change in lib/python3.9/site-packages/imageio_ffmpeg/_io.py function for counting frames from ffmpeg to ffprobe, I've tested it on macos and it works:
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.
"""
# https://stackoverflow.com/questions/2017843/fetch-frame-count-with-ffmpeg
if isinstance(path, pathlib.PurePath):
path = str(path)
if not isinstance(path, str):
raise TypeError("Video path must be a string or pathlib.Path.")
cmd = ['ffprobe','-v','error','-select_streams','v:0','-count_packets','-show_entries','stream=nb_read_packets','-of','csv=p=0', path]
try:
out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, **_popen_kwargs())
except subprocess.CalledProcessError as err:
out = err.output.decode(errors="ignore")
raise RuntimeError(
"FFMPEG call failed with {}:\n{}".format(err.returncode, out)
)
# Note that other than with the subprocess calls below, ffmpeg wont hang here.
# Worst case Python will stop/crash and ffmpeg will continue running until done.
nframes = out
return nframes
raise RuntimeError("Could not get number of frames") # pragma: no cover
Deface is quite handy for processing individual images, but it consistently encounters errors when I attempt to process MP4 files, and I'm uncertain of the underlying cause.
OS: macOS sonoma 14.3
Chip: Apple M1 Pro
Python Version: Python 3.11.7
The text was updated successfully, but these errors were encountered: