mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
Fix gif creation and add better error handling (#9797)
* Add better error handling * Fix end_ts logic * Formatting
This commit is contained in:
parent
bcbea8da7d
commit
b9e20fc833
@ -603,7 +603,9 @@ def event_preview(id: str, max_cache_age=2592000):
|
|||||||
)
|
)
|
||||||
|
|
||||||
start_ts = event.start_time
|
start_ts = event.start_time
|
||||||
end_ts = min(event.end_time - event.start_time, 20) if event.end_time else 20
|
end_ts = (
|
||||||
|
start_ts + min(event.end_time - event.start_time, 20) if event.end_time else 20
|
||||||
|
)
|
||||||
|
|
||||||
if datetime.fromtimestamp(event.start_time) < datetime.now().replace(
|
if datetime.fromtimestamp(event.start_time) < datetime.now().replace(
|
||||||
minute=0, second=0
|
minute=0, second=0
|
||||||
@ -663,6 +665,14 @@ def event_preview(id: str, max_cache_age=2592000):
|
|||||||
ffmpeg_cmd,
|
ffmpeg_cmd,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if process.returncode != 0:
|
||||||
|
logger.error(process.stderr)
|
||||||
|
return make_response(
|
||||||
|
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
||||||
|
500,
|
||||||
|
)
|
||||||
|
|
||||||
gif_bytes = process.stdout
|
gif_bytes = process.stdout
|
||||||
else:
|
else:
|
||||||
# need to generate from existing images
|
# need to generate from existing images
|
||||||
@ -723,6 +733,7 @@ def event_preview(id: str, max_cache_age=2592000):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
|
logger.error(process.stderr)
|
||||||
return make_response(
|
return make_response(
|
||||||
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
jsonify({"success": False, "message": "Unable to create preview gif"}),
|
||||||
500,
|
500,
|
||||||
|
Loading…
Reference in New Issue
Block a user