I am trying to convert a remote WebM file on the fly to MP4. This should happen without writing anything to disk. Furthermore it would be great to be able to stream out results as soon as possible.
This is my flask function without the actual conversion, so you get a idea of the streaming.
@app.route("/stream/mp4")
def as_mp4():
url = "http://video.webmfiles.org/big-buck-bunny_trailer.webm"
r = requests.get(url, stream=True)
def stream():
# convert it here
for chunk in r.iter_content(chunk_size=1024):
yield chunk
# end for
# end def
return Response(stream(), mimetype="video/mp4")
# end def
ffmpeg
reading directly from the URL and writing to stdout, perhaps, but you might have trouble with MP4 format since it requires seekable output. It should work with Matroska (MKV) format. – Either