imageio / imageio-ffmpeg

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

imageio_ffmpeg We had to kill ffmpeg to stop it, video reader not write! #46

Closed mayste closed 3 years ago

mayste commented 3 years ago

Hi, I'm looking for ffmpeg timeout param for video reader. I need to read a video with resolution 512X512 in batch of 16 frames and do some operations. How I can increase the timeout for leave the video reader open? Thanks

almarklein commented 3 years ago

Hi @mayste, the API is in the readme - I think you're looking for the ffmpeg_timeout parameter.

mayste commented 3 years ago

Yes but this parameter is available over writing and not reading

Sent from my iPhone

On 25 Jan 2021, at 12:19, Almar Klein notifications@github.com wrote:

 Hi @mayste, the API is in the readme - I think you're looking for the ffmpeg_timeout parameter.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

almarklein commented 3 years ago

In that case I do not understand the question :) What goes wrong now which you think can be fixed with a timeout?

mayste commented 3 years ago

When I’m trying to read a video. I need to leave it open for long time. I got error: We had to kill ffmpeg to stop it. So I wanted to ask if there is a way to change the timeout or a way to prevent this. Thanks

Sent from my iPhone

On 25 Jan 2021, at 13:06, Almar Klein notifications@github.com wrote:

 In that case I do not understand the question :) What goes wrong now which you think can be fixed with a timeout?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

almarklein commented 3 years ago

I suspect this is because you read the first few frames and then stop the iteration. The way to tell ffmpeg to stop has changed a couple of times, as different solutions have side effects for certain use-cases. In the current approach we close both stdin and stdout of the ffmpeg subprocess, then wait at most 1.5 s, and then kill it if it has not stopped yet. This was tested to work well, but we appear to have a use-case here for which it does not.

If you could help determine whether this can be improved, that 'd be great. I'd be especially interested if giving ffmpeg more time by increasing the timeout would help. You could try this by increasing the 1.5 here:

https://github.com/imageio/imageio-ffmpeg/blob/71b2fb0130e92a55d09588e19b5e823566ebb9b4/imageio_ffmpeg/_io.py#L252-L254

I can see a few options:

mayste commented 3 years ago

Thanks, I will try