I have a video stored on the cloud, I'm using this Flask route to download chunks of the video at a time and return it to the user as a stream:
@app.route("/api/v1/download")
def downloadAPI():
def download_file(streamable):
with streamable as stream:
stream.raise_for_status()
for chunk in stream.iter_content(chunk_size=512):
yield chunk
headers = {"range": range}
resp = requests.request(
method=request.method,
url="example.com/api/file",
headers=headers,
data=request.get_data(),
cookies=request.cookies,
allow_redirects=False,
stream=True)
return Response(download_file(resp), resp.status_code)
How would I transcode these chunks on the fly?
I'm planning on transcoding basically any type of video to mp4