From dd2f95b9c1869f63de5ba495b90a1f0f6fecb1e7 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Mon, 10 Aug 2026 00:21:19 -0400 Subject: [PATCH] revert(video): back to simple send_file for video serving (RPi3 can't transcode) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- app.py | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/app.py b/app.py index b23a602..0bd12ce 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ from flask import Flask, render_template, make_response, json, jsonify, request, send_file, Response from modules import app_gps, app_events, app_car, app_account, app_gps,app_obd, app_sql, app_dash, app_upload, app_video, app_health, app_alerts, app_settings, app_network -import os, time, subprocess +import os, time from gevent.pywsgi import WSGIServer @@ -149,33 +149,7 @@ def local_video_file(): return jsonify(error=str(error)), 400 except FileNotFoundError: return jsonify(error=f"Local video not found: {relative_path}"), 404 - - # Stream via ffmpeg: copy video, transcode audio to AAC (PCM not supported - # in MP4), output as fragmented MP4 so browser plays without full download. - def generate_stream(): - cmd = [ - "ffmpeg", "-nostdin", "-loglevel", "error", - "-i", path, - "-c:v", "copy", - "-c:a", "aac", - "-movflags", "frag_keyframe+empty_moov", - "-f", "mp4", - "pipe:1", - ] - proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - try: - while True: - chunk = proc.stdout.read(65536) - if not chunk: - break - yield chunk - finally: - proc.stdout.close() - proc.wait() - - resp = Response(generate_stream(), 200, mimetype="video/mp4", direct_passthrough=True) - resp.headers["Cache-Control"] = "no-cache" - return resp + return send_file(path, conditional=True, as_attachment=False) @app.route('/api/local-video/thumbnail') def local_video_thumbnail():