8 Commits

Author SHA1 Message Date
salirezav
8a54a88729 Frontend: removed the forced MIME type from the Video.js sources object so it can correctly handle non-mp4 “regular” streams.
File: video-remote/src/components/VideoModal.tsx
Backend: updated /videos/{file_id}/stream-transcoded so that when a Range request is present, it computes an approximate duration_sec from the requested byte length and bitrate, and passes that to ffmpeg (so the response length aligns with Content-Length).

File: media-api/main.py
2026-03-18 15:04:06 -04:00
Hunter Halloran
78bfcf0261 Mount Nix camera SDK into docker container with proper LD_LIBRARY_PATH 2026-01-30 18:07:18 -05:00
Hunter Halloran
194f3fbd9a Fix Nix string concatenation in preStart 2026-01-30 17:55:19 -05:00
Hunter Halloran
147c21a19b Fix missing 'fi' in shell script 2026-01-30 17:53:49 -05:00
Hunter Halloran
5cb5a78032 Fix env_file paths and ANON_KEY references in docker-compose.yml
- Update sed pattern to correctly match absolute env_file paths
- Replace [REDACTED] placeholders with VITE_SUPABASE_ANON_KEY variable reference
- Fix missing file path in sed command
2026-01-30 17:52:17 -05:00
Hunter Halloran
53314a0896 fix: Link .env file correctly (I hope) 2026-01-30 17:38:03 -05:00
Hunter Halloran
998a84f992 Fix module.nix package references 2026-01-30 17:26:16 -05:00
Hunter Halloran
59d3a1eec1 Move usda-vision module to flake nixosModules output 2026-01-30 17:24:14 -05:00
4 changed files with 41 additions and 14 deletions

View File

@@ -7,6 +7,11 @@
};
outputs = { self, nixpkgs, flake-utils }:
{
# NixOS module (system-independent)
nixosModules.default = import ./module.nix;
}
//
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
@@ -95,9 +100,6 @@
DOCKER_BUILDKIT = "1";
COMPOSE_DOCKER_CLI_BUILD = "1";
};
# NixOS module for deployment
nixosModules.default = import ./module.nix;
}
);
}

View File

@@ -746,18 +746,21 @@ def stream_transcoded(request: Request, file_id: str, start_time: float = 0.0):
time_start_sec = (byte_start / estimated_total_bytes) * video_duration
time_start_sec = max(0.0, min(time_start_sec, video_duration - 0.5))
# For seeking, don't limit duration - stream to end
# The browser will handle buffering
duration_sec = None # None means stream to end
# Update headers for range response
# For seeking, we typically don't know the exact end, so estimate
actual_byte_end = min(byte_end or estimated_total_bytes - 1, estimated_total_bytes - 1)
headers["Content-Range"] = f"bytes {byte_start}-{actual_byte_end}/{estimated_total_bytes}"
headers["Content-Length"] = str(actual_byte_end - byte_start + 1)
# Honor the requested range: approximate duration based on bitrate so the
# transcoded response length matches the declared Content-Length.
requested_bytes = actual_byte_end - byte_start + 1
duration_sec = requested_bytes * 8 / transcoded_bitrate if transcoded_bitrate else None
if duration_sec is not None:
# Clamp to remaining duration.
duration_sec = max(0.0, min(duration_sec, video_duration - time_start_sec))
# Stream from the calculated time position using FFmpeg's -ss flag
# Duration is None, so it will stream to the end
return StreamingResponse(
generate_transcoded_stream(p, time_start_sec, duration_sec),
media_type=content_type,

View File

@@ -3,9 +3,9 @@
let
cfg = config.services.usda-vision;
# Get packages from the flake (self reference)
camera-sdk = config.services.usda-vision.package.camera-sdk or pkgs.callPackage ./camera-sdk.nix {};
usda-vision-app = config.services.usda-vision.package.usda-vision or pkgs.callPackage ./package.nix {};
# Get packages from the package option (must be provided)
camera-sdk = cfg.package.camera-sdk;
usda-vision-app = cfg.package.usda-vision;
in
{
@@ -127,11 +127,30 @@ in
/var/lib/usda-vision/docker-compose.yml
''}
${lib.optionalString (cfg.envFile != null) ''
# Configure docker-compose to use Nix-provided camera SDK
echo "Configuring camera SDK in docker-compose.yml..."
${pkgs.gnused}/bin/sed -i \
-e '/^ - \/etc\/timezone:\/etc\/timezone:ro$/a\ - ${camera-sdk}/lib:/opt/camera-sdk/lib:ro' \
-e 's|LD_LIBRARY_PATH=/usr/local/lib:/lib:/usr/lib|LD_LIBRARY_PATH=/opt/camera-sdk/lib:/usr/local/lib:/lib:/usr/lib|' \
/var/lib/usda-vision/docker-compose.yml
# Fix env_file paths to point to /var/lib/usda-vision/.env
echo "Fixing env_file paths in docker-compose.yml..."
${pkgs.gnused}/bin/sed -i \
's|/var/lib/usda-vision/management-dashboard-web-app/\.env|/var/lib/usda-vision/.env|g' \
/var/lib/usda-vision/docker-compose.yml
# Replace [REDACTED] placeholders with actual VITE_SUPABASE_ANON_KEY reference
echo "Fixing ANON_KEY references in docker-compose.yml..."
${pkgs.gnused}/bin/sed -i \
's|\[REDACTED\]|$${VITE_SUPABASE_ANON_KEY}|g' \
/var/lib/usda-vision/docker-compose.yml
if [ -n "${cfg.envFile}" ]; then
echo "Copying environment file from managed secret..."
cp ${cfg.envFile} /var/lib/usda-vision/.env
chmod 644 /var/lib/usda-vision/.env
''}
fi
${lib.optionalString (cfg.envFile == null) ''
if [ ! -s /var/lib/usda-vision/.env ]; then

View File

@@ -52,7 +52,10 @@ export const VideoModal: React.FC<Props> = ({ fileId, onClose }) => {
sources: [
{
src: src,
type: 'video/mp4'
// Do not hardcode the MIME type: the "regular" endpoint may serve
// non-mp4 containers (avi/mkv/etc), and forcing mp4 can trigger
// MEDIA_ERR_SRC_NOT_SUPPORTED in Video.js/browser.
// Let Video.js/browser sniff based on the actual response.
}
]
})