imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
233 stars 52 forks source link

0.4.0 regression on Linux: count_frames() freezes #33

Closed mdraw closed 4 years ago

mdraw commented 4 years ago

When updating to imageio-ffmpeg 0.4.0, my code which uses the imageio.plugins.ffmpeg.FfmpegFormat.Reader.count_frames() function freezes with 0% CPU utilization. This happened on two different Linux systems and multiple video files from different sources today, so I investigated a bit and found that reverting the change in this line https://github.com/imageio/imageio-ffmpeg/commit/a19c76161660523e9ea8374f61c87de1de4f5619#diff-f32de983d7bf3c1014870e92de0d1882R41 back to the previous version

out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=ISWIN)

fixes the freezing on my system. I don't know what exactly is happening there, I only noticed that when sending a KeyboardInterrupt, the traceback always shows that it was currently executing the line

out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, **_popen_kwargs())

in imageio_ffmpeg/_io.py.

A minimal code example to reproduce this, given that a.mp4 is a regular video file:

import imageio
r = imageio.get_reader('a.mp4')
r.count_frames()
almarklein commented 4 years ago

What OS is this, and does it also freeze on this?

import imageio
r = imageio.get_reader('imageio:cockatoo.mp4')
r.count_frames()

Can you also provide the result of this:

import imageio_ffmpeg
imageio_ffmpeg.get_ffmpeg_version()
almarklein commented 4 years ago

And does it freeze on simply reading the frames?

almarklein commented 4 years ago

And does it freeze on simply reading the frames?

This is the most important question, really. If it does not (i.e. if reading/writing frames works fine) then #37 should have fixed this issue.

mdraw commented 4 years ago

Thanks a lot for the quick fix and the immediate release! 0.4.1 works fine. Indeed, on 0.4.0 it didn't freeze on reading the frames. Only counting freezed the process.

almarklein commented 4 years ago

Thanks for confirming!