Skip to content

Commit

Permalink
Use review item thumbnail for export (#12998)
Browse files Browse the repository at this point in the history
* Use review item thumbnail for export

* Formatting
  • Loading branch information
NickM-27 committed Aug 18, 2024
1 parent 5f80ec2 commit 442fc05
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions frigate/api/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def export_recording(camera_name: str, start_time, end_time):
401,
)

existing_image = json.get("image_path")

recordings_count = (
Recordings.select()
.where(
Expand All @@ -78,6 +80,7 @@ def export_recording(camera_name: str, start_time, end_time):
current_app.frigate_config,
camera_name,
friendly_name,
existing_image,
int(start_time),
int(end_time),
(
Expand Down
11 changes: 10 additions & 1 deletion frigate/record/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import threading
from enum import Enum
from pathlib import Path
from typing import Optional

from peewee import DoesNotExist

Expand Down Expand Up @@ -49,7 +50,8 @@ def __init__(
self,
config: FrigateConfig,
camera: str,
name: str,
name: Optional[str],
image: Optional[str],
start_time: int,
end_time: int,
playback_factor: PlaybackFactorEnum,
Expand All @@ -58,6 +60,7 @@ def __init__(
self.config = config
self.camera = camera
self.user_provided_name = name
self.user_provided_image = image
self.start_time = start_time
self.end_time = end_time
self.playback_factor = playback_factor
Expand All @@ -72,6 +75,12 @@ def get_datetime_from_timestamp(self, timestamp: int) -> str:
def save_thumbnail(self, id: str) -> str:
thumb_path = os.path.join(CLIPS_DIR, f"export/{id}.webp")

if self.user_provided_image is not None and os.path.isfile(
self.user_provided_image
):
shutil.copy(self.user_provided_image, thumb_path)
return thumb_path

if (
self.start_time
< datetime.datetime.now(datetime.timezone.utc)
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/events/EventView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export default function EventView({
axios
.post(
`export/${review.camera}/start/${review.start_time - REVIEW_PADDING}/end/${endTime}`,
{ playback: "realtime" },
{ playback: "realtime", image_path: review.thumb_path },
)
.then((response) => {
if (response.status == 200) {
Expand Down

0 comments on commit 442fc05

Please sign in to comment.