senko/python-video-converter

Incompatible with Threads

JosephRedfern opened this issue · 4 comments

This module, as excellent as it is, does not seem to allow you to convert videos if the conversation is kicked off in a child thread.

Having done some digging, it seems to be down to the use of Pythons signals library, whose docs state: "only the main thread can set a new signal handler".

It would be nice if the module supported threads, so that multiple videos could be converted simultaneously.

Hey, thanks for reporting this and for taking time to investigate the cause.

The signals are used for timeout in case ffmpeg gets stuck (can happen with some weird/invalid format videos). If used in a background thread, there's probably other means of dealing with this problem, so I've made the timeout into an option (still enabled by default so the default behaviour is the same) that can be disabled. Check the Converter (or FFMpeg if you're using the low-level interface) docstrings for detailed info.

I've just pushed the changes to the repo (and bumped the version to 1.0.2). Please let me know if this fixes your problem. From the description, it should be all that's needed, but as I don't have a threaded app that uses the module I can't test it myself.

works excellent for me!

Hello,

@senko , I don't find the way to disable the signal in current python-video-converter library. Any tips ?

Cheers,

@ouhouhsami you can set the timeout to None when you call the convert function:

c = Converter()
c.convert(infile, outfile, options, timeout=None)