I’d like to stream data directly to disk. One way of doing that is simply to read data and write to file, but I also want to minimalize RAM usage. I’ve figured out some manual way of doing that: Do I really have to manually load stream part by part? If so, how can I determine optimal value of BUFF…
Tag: stream
Proccesing audio from twilio media stream using Python
I am streaming call audio to my local server using Twilio Streams. For reference I used the offical guide from the Twilio Team. Decoding the audio and saving it to a .wav file works, although when playing back the audio sounds somewhat distored (“slow-motion” with compression artificats). You can …
Asyncio Streams automatically restarts to read data even after writer.close() is run
I followed the tutorial in https://docs.python.org/3/library/asyncio-stream.html to read data from a sensor (TCP protocol, PC as the server): The program is supposed to finish after 1 second data transmission. However, the output is: It repeated automatically and infinitely. What is the reason for this and Ho…
Detecting cheapest way to build independent iterators
Suppose I’m writing a function taking in an iterable, and my function wants to be agnostic as to whether that iterable is actually an iterator yet or not. (This is a common situation, right? I think basically all the itertools functions are written this way. Take in an iterable, return an iterator.) If …
Pipe and OpenCV to FFmpeg with audio streaming RTMP in Python
I’m trying to stream FFmpeg with audio. I will show my code below: Import module Create variables Command param Create subprocess to ffmpeg command Send frame to RTMP server I hope you can help me to be able to live stream via FFmpeg over RTMP with audio. Thanks! Answer Assuming you actually need to use…
Live-output / stream from Python subprocess
I am using Python and it’s subprocess library to check output from calls using strace, something in the matter of: However, this only gives me the output after the called subprocess already finished, which is very limiting for my use-case. I need a kind of “stream” or live-output from the pr…
Can you “stream” images to ffmpeg to construct a video, instead of saving them to disk?
My work recently involves programmatically making videos. In python, the typical workflow looks something like this: This workflow creates an image for each frame in the video and saves it to disk. After all images have been saved, ffmpeg is called to construct a video from all of the images. Saving the image…
How to convert an iterable to a stream?
If I’ve got an iterable containing strings, is there a simple way to turn it into a stream? I want to do something like this: Answer Here’s my streaming iterator an experimental branch of urllib3 supporting streaming chunked request via iterables: Source with context: https://github.com/shazow/url…