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
{{ message }}
Repository navigation
Is it possible to directly stream from python? #218
We are using python to capture and pre-process a stream of images which then have to be sent over the network. At the moment we use the following pipeline:
It works but it would be great to skip the syphon / spout step, at least on the sending side. How is it possible to create a stream in python which then can be consumed by ultragrid directly?
We currently convert opencv mats into textures and render them in an opengl context to be shared by syphon / spout. And it would of course make more sense to directly offer a stream to ultragrid. I assume ffmpeg or GStreamer are needed, and I would prefer ffmpeg.
Maybe I missed it in the documentation, but I only read about examples where you are specifying the source which will be streamed, instead of having a third party app (except syphon / spout / ndi) which offers the stream.
what operating system are you using? On Linux it should be already possible using the file video capture and pipes.
You can either use a named pipe, or standard input. Then it should be possible to pass uncompressed data through the pipe in a suitable container, for example NUT. In these examples I'm using ffmpeg as the video source, but you can swap it out with your application if it outputs a stream that ffmpeg can decode.
Thanks for your answer. I am currently working on MacOS, the actual system will run on Windows. I have implemented a basic example which sends the frames into a pipe and it seems to work (when changing -c with -t in your example).
It is currently quite slow (only 17-20 FPS + 500ms delay), but I will investigate further.
Update: Using .bmp as encoding for cv2.imencode speeds it up to 25 FPS and about 50-100ms delay.
Activity
mpiatka commentedon Mar 3, 2022
Hi,
what operating system are you using? On Linux it should be already possible using the
filevideo capture and pipes.You can either use a named pipe, or standard input. Then it should be possible to pass uncompressed data through the pipe in a suitable container, for example NUT. In these examples I'm using ffmpeg as the video source, but you can swap it out with your application if it outputs a stream that ffmpeg can decode.
To use named pipe:
Or stdin could be used directly:
cansik commentedon Mar 3, 2022
Thanks for your answer. I am currently working on MacOS, the actual system will run on Windows. I have implemented a basic example which sends the frames into a pipe and it seems to work (when changing
-cwith-tin your example).It is currently quite slow (only 17-20 FPS + 500ms delay), but I will investigate further.
Update: Using
.bmpas encoding forcv2.imencodespeeds it up to 25 FPS and about 50-100ms delay.