Add ability to submit frames from recordings (#11212)

* add ability to parse and upload image from recording to frigate+

* Show dialog with current frame to be uploaded

* Implement uploading image in frontend

* Cleanup

* Update title
This commit is contained in:
Nicolas Mowen
2024-05-03 08:00:19 -06:00
committed by GitHub
parent b69c1828cb
commit e7950abec3
8 changed files with 274 additions and 31 deletions

View File

@@ -2,6 +2,7 @@
import datetime
import logging
import subprocess as sp
from abc import ABC, abstractmethod
from multiprocessing import shared_memory
from string import printable
@@ -746,3 +747,37 @@ def add_mask(mask: str, mask_img: np.ndarray):
]
)
cv2.fillPoly(mask_img, pts=[contour], color=(0))
def get_image_from_recording(
file_path: str, relative_frame_time: float
) -> Optional[any]:
"""retrieve a frame from given time in recording file."""
ffmpeg_cmd = [
"ffmpeg",
"-hide_banner",
"-loglevel",
"warning",
"-ss",
f"00:00:{relative_frame_time}",
"-i",
file_path,
"-frames:v",
"1",
"-c:v",
"png",
"-f",
"image2pipe",
"-",
]
process = sp.run(
ffmpeg_cmd,
capture_output=True,
)
if process.returncode == 0:
return process.stdout
else:
return None