diff --git a/Dockerfile b/Dockerfile index 74bc3c6f3..4bc1368c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -126,8 +126,8 @@ RUN wget -qO edgetpu_model.tflite https://github.com/google-coral/test_data/raw/ RUN wget -qO cpu_model.tflite https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite COPY labelmap.txt . # Copy OpenVino model -COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model -RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt +#COPY --from=ov-converter /models/public/ssdlite_mobilenet_v2/FP16 openvino-model +#RUN wget -q https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt -O openvino-model/coco_91cl_bkgr.txt diff --git a/docker-compose.yml b/docker-compose.yml index 3ed08493c..4e6b1d447 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: build: context: . target: devcontainer - devices: - - /dev/bus/usb:/dev/bus/usb +# devices: +# - /dev/bus/usb:/dev/bus/usb # - /dev/dri:/dev/dri # for intel hwaccel, needs to be updated for your hardware volumes: - .:/workspace/frigate:cached @@ -21,7 +21,7 @@ services: - /etc/localtime:/etc/localtime:ro - ./config/config.yml:/config/config.yml:ro - ./debug:/media/frigate - - /dev/bus/usb:/dev/bus/usb +# - /dev/bus/usb:/dev/bus/usb mqtt: container_name: mqtt image: eclipse-mosquitto:1.6 diff --git a/docker/rootfs/usr/local/nginx/conf/nginx.conf b/docker/rootfs/usr/local/nginx/conf/nginx.conf index e7f21ffed..e4dbfa8cc 100644 --- a/docker/rootfs/usr/local/nginx/conf/nginx.conf +++ b/docker/rootfs/usr/local/nginx/conf/nginx.conf @@ -61,12 +61,12 @@ http { vod_mode mapped; vod_max_mapping_response_size 1m; vod_upstream_location /api; + vod_align_segments_to_key_frames on; + vod_manifest_segment_durations_mode accurate; vod_ignore_edit_list on; - vod_segment_duration 4000; - vod_align_segments_to_key_frames on; - vod_manifest_duration_policy min; - vod_dash_manifest_format segmenttemplate; - vod_dash_profiles urn:mpeg:dash:profile:isoff-live:2011; + vod_segment_duration 10000; + vod_hls_mpegts_align_frames off; + vod_hls_mpegts_interleave_frame on; # file handle caching / aio open_file_cache max=1000 inactive=5m; @@ -84,14 +84,14 @@ http { # gzip manifests gzip on; - gzip_types application/vnd.apple.mpegurl video/f4m application/dash+xml text/xml; + gzip_types application/vnd.apple.mpegurl; location /vod/ { aio threads; - vod dash; + vod hls; secure_token $args; - secure_token_types application/dash+xml; + secure_token_types application/vnd.apple.mpegurl; add_header Access-Control-Allow-Headers '*'; add_header Access-Control-Expose-Headers 'Server,range,Content-Length,Content-Range'; @@ -101,11 +101,6 @@ http { expires off; } - location /vod_status { - vod_status; - access_log off; - } - location /stream/ { add_header Cache-Control "no-store"; expires off; diff --git a/frigate/const.py b/frigate/const.py index b4d73f24b..86be952f4 100644 --- a/frigate/const.py +++ b/frigate/const.py @@ -5,6 +5,7 @@ CACHE_DIR = "/tmp/cache" YAML_EXT = (".yaml", ".yml") PLUS_ENV_VAR = "PLUS_API_KEY" PLUS_API_HOST = "https://api.frigate.video" +MAX_SEGMENT_DURATION = 600 # Regex Consts diff --git a/frigate/http.py b/frigate/http.py index 7dcc417b6..901097679 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -32,7 +32,7 @@ from peewee import SqliteDatabase, operator, fn, DoesNotExist from playhouse.shortcuts import model_to_dict from frigate.config import FrigateConfig -from frigate.const import CLIPS_DIR, RECORD_DIR +from frigate.const import CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR from frigate.models import Event, Recordings from frigate.object_processing import TrackedObject from frigate.stats import stats_snapshot @@ -1050,13 +1050,19 @@ def vod_ts(camera_name, start_ts, end_ts): clips = [] durations = [] + max_duration_ms = MAX_SEGMENT_DURATION * 1000 recording: Recordings for recording in recordings: clip = {"type": "source", "path": recording.path} duration = int(recording.duration * 1000) - if duration > 0: + # Determine if we need to end the last clip early + if recording.end_time > end_ts: + duration -= int((recording.end_time - end_ts) * 1000) + + if 0 < duration < max_duration_ms: + clip["keyFrameDurations"] = [duration] clips.append(clip) durations.append(duration) else: diff --git a/frigate/record.py b/frigate/record.py index 768a96df2..69cece362 100644 --- a/frigate/record.py +++ b/frigate/record.py @@ -5,7 +5,6 @@ import multiprocessing as mp import os import queue import random -import shutil import string import subprocess as sp import threading @@ -16,7 +15,7 @@ import psutil from peewee import JOIN, DoesNotExist from frigate.config import RetainModeEnum, FrigateConfig -from frigate.const import CACHE_DIR, RECORD_DIR +from frigate.const import CACHE_DIR, MAX_SEGMENT_DURATION, RECORD_DIR from frigate.models import Event, Recordings from frigate.util import area @@ -173,7 +172,7 @@ class RecordingMaintainer(threading.Thread): duration = -1 # ensure duration is within expected length - if 0 < duration < 600: + if 0 < duration < MAX_SEGMENT_DURATION: end_time = start_time + datetime.timedelta(seconds=duration) self.end_time_cache[cache_path] = (end_time, duration) else: diff --git a/web/src/routes/Events.jsx b/web/src/routes/Events.jsx index a130185cb..f99553031 100644 --- a/web/src/routes/Events.jsx +++ b/web/src/routes/Events.jsx @@ -561,8 +561,8 @@ export default function Events({ path, ...props }) { autoplay: true, sources: [ { - src: `${apiHost}/vod/event/${event.id}/manifest.mpd`, - type: 'application/dash+xml', + src: `${apiHost}vod/event/${event.id}/master.m3u8`, + type: 'application/vnd.apple.mpegurl', }, ], }} diff --git a/web/src/routes/Recording.jsx b/web/src/routes/Recording.jsx index 05ece4751..01c623ebd 100644 --- a/web/src/routes/Recording.jsx +++ b/web/src/routes/Recording.jsx @@ -69,11 +69,11 @@ export default function Recording({ camera, date, hour = '00', minute = '00', se description: `${camera} recording @ ${h.hour}:00.`, sources: [ { - src: `${apiHost}/vod/${year}-${month}/${day}/${h.hour}/${camera}/${timezone.replaceAll( + src: `${apiHost}vod/${year}-${month}/${day}/${h.hour}/${camera}/${timezone.replaceAll( '/', '_' - )}/manifest.mpd`, - type: 'application/dash+xml', + )}/master.m3u8`, + type: 'application/vnd.apple.mpegurl', }, ], };