imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

support async #111

Open sugizo opened 3 months ago

sugizo commented 3 months ago

nice to support async ?

the ffmpeg parameter can be run using another python ffmpeg module e.g. module

typed-ffmpeg 
ffmpeg-python

e.g. code

import ffmpeg
url = 'http://takemotopiano.aa1.netvolante.jp:8190/nphMotionJpeg?Resolution=320x240&Quality=Standard&Framerate=30'
output = 'rtsp_%Y_%m_%d_%H_%M_%S.mp4'
scale = 'scale = 320 : -1'
segment_time = '00:01:00' 

stream = ffmpeg.input(url).output(filename = output, 
                                  vcodec = 'libx264', #acodec = 'copy', 
                                  reset_timestamps = 1, 
                                  strftime = 1, 
                                  f = 'segment', 
                                  segment_time = segment_time, 
                                  segment_atclocktime = 1, 
                                  vf = scale, 
                                  r = 25, ).overwrite_output().run_async()

to stop async stream.terminate()

best regards

almarklein commented 3 months ago

I'm not sure if I follow. You don't mean async as in await ... using asyncio, or do are you?

Your code example feels more like it will do the work in the background in a thread or something. This is out of scope of this library, because it represents a very specific use-cases, and one that can be implemented on top of imageio_ffmpeg.

sugizo commented 3 months ago

I'm not sure if I follow. You don't mean async as in await ... using asyncio, or do are you?

Your code example feels more like it will do the work in the background in a thread or something. This is out of scope of this library, because it represents a very specific use-cases, and one that can be implemented on top of imageio_ffmpeg.

yes

objective create video continously from rtsp camera with duration that defined in segment_time parameter