2026-04-07 21:58:19 -04:00
|
|
|
|
import { join } from 'path';
|
2026-05-22 23:52:30 -04:00
|
|
|
|
import { stat, unlink } from 'fs/promises';
|
2026-04-07 21:58:19 -04:00
|
|
|
|
import { tmpdir } from 'os';
|
2026-05-15 21:26:16 -04:00
|
|
|
|
import { Queue } from 'bullmq';
|
2026-04-07 21:58:19 -04:00
|
|
|
|
import { query } from '../db/client.js';
|
|
|
|
|
|
import { downloadFromS3, uploadToS3 } from '../s3/client.js';
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
import { transcodeVideo, transcodeImage, getMediaInfo, isHwCodec } from '../ffmpeg/executor.js';
|
|
|
|
|
|
|
|
|
|
|
|
// Read the global proxy-encoder settings from the DB. These are written by
|
|
|
|
|
|
// Settings → Proxy encoding in the GUI. Falls back to libx264 defaults if
|
|
|
|
|
|
// nothing is configured (first-run / fresh install).
|
|
|
|
|
|
async function loadProxyEncodingSettings() {
|
|
|
|
|
|
const result = await query(
|
|
|
|
|
|
`SELECT key, value FROM settings
|
|
|
|
|
|
WHERE key IN ('gpu_transcode_enabled','gpu_codec','gpu_preset','gpu_bitrate_mbps',
|
|
|
|
|
|
'gpu_rc_mode','gpu_audio_codec','gpu_audio_bitrate_kbps')`
|
|
|
|
|
|
);
|
|
|
|
|
|
const map = {};
|
|
|
|
|
|
for (const { key, value } of result.rows) map[key] = value;
|
|
|
|
|
|
|
|
|
|
|
|
const gpuEnabled = map.gpu_transcode_enabled === 'true';
|
|
|
|
|
|
const codec = map.gpu_codec || (gpuEnabled ? 'h264_nvenc' : 'libx264');
|
|
|
|
|
|
const preset = map.gpu_preset || (gpuEnabled ? 'p4' : 'fast');
|
|
|
|
|
|
const rcMode = map.gpu_rc_mode || null;
|
|
|
|
|
|
const audioCodec = map.gpu_audio_codec || 'aac';
|
2026-05-26 12:57:37 -04:00
|
|
|
|
const audioKbps = parseInt(map.gpu_audio_bitrate_kbps || '128', 10);
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
|
2026-05-26 13:44:18 -04:00
|
|
|
|
// VBR 500k–1M: target average 750k, hard cap 1M, buffer 2M.
|
|
|
|
|
|
// libx264 ABR mode — quality varies per-scene within the envelope.
|
|
|
|
|
|
// These are stored in the DB as the bitrate field; min/max derived from it.
|
|
|
|
|
|
const bitrateM = parseFloat(map.gpu_bitrate_mbps || '0.75');
|
|
|
|
|
|
const targetBps = Math.round(bitrateM * 1000); // kbps
|
|
|
|
|
|
const minKbps = Math.round(targetBps * 0.5); // 50% of target
|
|
|
|
|
|
const maxKbps = Math.round(targetBps * 1.33); // 133% of target, capped at ~1M for 750k target
|
|
|
|
|
|
const bufKbps = maxKbps * 2; // 2× maxrate recommended
|
|
|
|
|
|
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
return {
|
|
|
|
|
|
videoCodec: codec,
|
|
|
|
|
|
videoPreset: preset,
|
2026-05-26 13:44:18 -04:00
|
|
|
|
videoBitrate: `${targetBps}k`,
|
|
|
|
|
|
videoMinRate: `${minKbps}k`,
|
|
|
|
|
|
videoMaxRate: `${maxKbps}k`,
|
|
|
|
|
|
videoBufSize: `${bufKbps}k`,
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
rateControl: rcMode,
|
|
|
|
|
|
audioCodec,
|
|
|
|
|
|
audioBitrate: `${audioKbps}k`,
|
|
|
|
|
|
_gpu: gpuEnabled && isHwCodec(codec),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
|
|
|
|
|
|
// Codec names ffprobe reports for still-image inputs. These bypass the video
|
|
|
|
|
|
// transcode entirely — see proxyWorker below.
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
const IMAGE_CODECS = new Set([
|
|
|
|
|
|
'png', 'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls', 'svg',
|
|
|
|
|
|
]);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
|
|
|
|
|
|
const S3_BUCKET = process.env.S3_BUCKET || 'wild-dragon';
|
|
|
|
|
|
|
2026-05-26 07:36:54 -04:00
|
|
|
|
// BUG FIX #7: Keep thumbnailQueue as a module-level singleton so it is only
|
|
|
|
|
|
// opened once and can be closed during SIGTERM (via the exported closer).
|
|
|
|
|
|
// Previously a new Queue was created inside the worker function; BullMQ Queue
|
|
|
|
|
|
// instances hold an open Redis connection that prevents clean shutdown.
|
2026-05-15 21:26:16 -04:00
|
|
|
|
const parseRedisUrl = (url) => {
|
|
|
|
|
|
const parsed = new URL(url);
|
|
|
|
|
|
return { host: parsed.hostname, port: parseInt(parsed.port, 10) };
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-26 07:36:54 -04:00
|
|
|
|
export const thumbnailQueue = new Queue('thumbnail', {
|
2026-05-15 21:26:16 -04:00
|
|
|
|
connection: parseRedisUrl(process.env.REDIS_URL || 'redis://queue:6379'),
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-04-07 21:58:19 -04:00
|
|
|
|
export const proxyWorker = async (job) => {
|
|
|
|
|
|
const { assetId, inputKey, outputKey } = job.data;
|
|
|
|
|
|
|
|
|
|
|
|
const tmpDir = tmpdir();
|
2026-05-15 21:26:16 -04:00
|
|
|
|
const inputPath = join(tmpDir, `proxy-input-${job.id}.mov`);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
const outputPath = join(tmpDir, `proxy-output-${job.id}.mp4`);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
2026-05-15 21:26:16 -04:00
|
|
|
|
// Download original from S3
|
2026-05-16 00:29:50 -04:00
|
|
|
|
await job.updateProgress(10);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
console.log(`[proxy] Downloading ${inputKey} for asset ${assetId}`);
|
|
|
|
|
|
await downloadFromS3(S3_BUCKET, inputKey, inputPath);
|
|
|
|
|
|
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
// Look up the asset row early — we want media_type before deciding how
|
|
|
|
|
|
// to process. That lets us route 'image' assets to the poster path even
|
|
|
|
|
|
// when ffprobe doesn't return a codec name in IMAGE_CODECS (e.g. future
|
|
|
|
|
|
// formats like AVIF / HEIF / JPEG-XL).
|
|
|
|
|
|
const assetRow = await query(
|
|
|
|
|
|
'SELECT media_type FROM assets WHERE id = $1',
|
|
|
|
|
|
[assetId]
|
|
|
|
|
|
);
|
|
|
|
|
|
const dbMediaType = assetRow.rows[0]?.media_type || null;
|
|
|
|
|
|
|
2026-05-22 23:52:30 -04:00
|
|
|
|
// Reject obviously-empty inputs before handing them to ffmpeg. Aborted
|
|
|
|
|
|
// SRT/RTMP recordings end up as 0-byte (or ftyp-only ~1KB) objects in S3
|
|
|
|
|
|
// when the source disconnects before any frame is received; the proxy
|
|
|
|
|
|
// pipeline used to bomb on "moov atom not found", which buried the
|
|
|
|
|
|
// real reason. Bail with a clear message and let the asset go to 'error'.
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
//
|
|
|
|
|
|
// Skip this check for image assets — a single PNG icon can legitimately
|
|
|
|
|
|
// be a few hundred bytes.
|
2026-05-22 23:52:30 -04:00
|
|
|
|
const { size: inputBytes } = await stat(inputPath);
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
if (dbMediaType !== 'image' && inputBytes < 4096) {
|
2026-05-22 23:52:30 -04:00
|
|
|
|
throw new Error(
|
|
|
|
|
|
`Source is empty or truncated (${inputBytes} bytes). The recording ` +
|
|
|
|
|
|
`likely ended before any frames were received — check the source ` +
|
|
|
|
|
|
`URL / SDI signal and re-record.`
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
// Extract source metadata (fps, codec, resolution, duration, size, audio)
|
2026-05-18 23:22:56 -04:00
|
|
|
|
await job.updateProgress(20);
|
|
|
|
|
|
let mediaInfo = {};
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
let hasAudio = true;
|
2026-05-18 23:22:56 -04:00
|
|
|
|
try {
|
|
|
|
|
|
mediaInfo = await getMediaInfo(inputPath);
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
hasAudio = !!mediaInfo.hasAudio;
|
2026-05-18 23:22:56 -04:00
|
|
|
|
console.log(`[proxy] Metadata for ${assetId}: ${JSON.stringify(mediaInfo)}`);
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.warn(`[proxy] getMediaInfo failed for ${assetId}: ${err.message}`);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
// Still images skip the video proxy — they have no temporal stream and
|
|
|
|
|
|
// x264 with a one-frame PNG input fails (Could not open encoder before EOF).
|
|
|
|
|
|
// Generate a scaled JPEG poster instead; the thumbnail job will downsize it.
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
//
|
|
|
|
|
|
// We treat the input as an image if EITHER the DB says so (media_type =
|
|
|
|
|
|
// 'image', set by upload.js based on Content-Type or extension), OR
|
|
|
|
|
|
// ffprobe reports a codec we know is a still-image format.
|
|
|
|
|
|
const codecLower = mediaInfo.codec ? mediaInfo.codec.toLowerCase() : null;
|
|
|
|
|
|
const isImage = dbMediaType === 'image' || (codecLower && IMAGE_CODECS.has(codecLower));
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
|
|
|
|
|
|
if (isImage) {
|
|
|
|
|
|
const imageOutputKey = outputKey.replace(/\.mp4$/, '.jpg');
|
|
|
|
|
|
const imageOutputPath = outputPath.replace(/\.mp4$/, '.jpg');
|
fix(worker): route SVG (and other image assets) through the image-poster
path instead of failing the video transcode
Previously IMAGE_CODECS contained the raster ffprobe codec names ('png',
'mjpeg', 'jpeg', 'webp', 'gif', 'tiff', 'bmp', 'jpegls') but not 'svg'.
An SVG-as-asset (e.g. an architecture diagram dragged into a project) was
correctly tagged media_type='image' in the DB but ffprobe reported its
codec as 'svg', which fell through to the video branch, found
durationMs===null, and died with 'Empty or truncated source: codec=svg,
resolution=0x0'. That clogs the failed-jobs list with red rows that have
nothing to do with broken captures.
Two fixes here:
1) Add 'svg' to IMAGE_CODECS so the existing transcodeImage()/poster
path handles it.
2) Also bail to the poster path when the asset row itself says
media_type='image', even if ffprobe didn't return a codec name we
recognize (defensive — catches future formats like AVIF without
requiring an explicit catalog update).
Closes part of #13.
2026-05-23 10:26:59 -04:00
|
|
|
|
console.log(`[proxy] Image asset ${assetId} (codec=${codecLower || 'unknown'}, db_media_type=${dbMediaType}) — emitting poster instead of video proxy`);
|
feat: live HLS preview, proxy worker fixes, Settings tabs, growing-files + Premier panel
- worker/proxy: scale-to-even filter, analyzeduration 100M, skip images, hasAudio
- worker/promotion: SMB landing zone -> S3 on idle, queues proxy job, status='ready'
- web-ui screens-ingest: HlsPreview component replaces fake LiveStrip/FauxFrame
- web-ui screens-admin: functional Settings tabs (S3, GPU, Growing, SDI, AMPP)
- mam-api /settings/growing: GET/PUT growing-files config
- mam-api /assets/:id/live-path: SMB UNC/POSIX path for live growing assets
- capture-manager: GROWING_ENABLED -> write hires to /growing instead of S3 stream
- recorders.js: pass GROWING_ENABLED to capture container, bind /growing mount
- docker-compose: mount /mnt/NVME/MAM/wild-dragon-growing on mam-api + worker
- premiere-plugin: Mount Live button, Relink-to-HiRes, live->ready status poll
2026-05-22 19:12:53 -04:00
|
|
|
|
await job.updateProgress(40);
|
|
|
|
|
|
await transcodeImage(inputPath, imageOutputPath);
|
|
|
|
|
|
await job.updateProgress(70);
|
|
|
|
|
|
await uploadToS3(S3_BUCKET, imageOutputKey, imageOutputPath);
|
|
|
|
|
|
await job.updateProgress(90);
|
|
|
|
|
|
await query(
|
|
|
|
|
|
`UPDATE assets
|
|
|
|
|
|
SET thumbnail_s3_key = $1,
|
|
|
|
|
|
proxy_s3_key = NULL,
|
|
|
|
|
|
resolution = COALESCE($2, resolution),
|
|
|
|
|
|
file_size = COALESCE($3, file_size),
|
|
|
|
|
|
status = 'ready',
|
|
|
|
|
|
updated_at = NOW()
|
|
|
|
|
|
WHERE id = $4`,
|
|
|
|
|
|
[imageOutputKey, mediaInfo.resolution ?? null, mediaInfo.fileSizeBytes ?? null, assetId]
|
|
|
|
|
|
);
|
|
|
|
|
|
await unlink(imageOutputPath).catch(() => {});
|
|
|
|
|
|
await job.updateProgress(100);
|
|
|
|
|
|
return { assetId, outputKey: imageOutputKey };
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Empty/truncated capture: probe returned a video stream but ffmpeg can't
|
|
|
|
|
|
// read any frames. Bail with a clear message instead of dumping ~3KB of
|
|
|
|
|
|
// ffmpeg stderr into the failed-jobs list.
|
|
|
|
|
|
if (mediaInfo.durationMs === null && mediaInfo.codec) {
|
|
|
|
|
|
throw new Error(
|
|
|
|
|
|
`Empty or truncated source: codec=${mediaInfo.codec}, ` +
|
|
|
|
|
|
`resolution=${mediaInfo.resolution || 'unknown'}, no readable frames.`
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
// Transcode using the operator-configured encoder. The proxy worker is
|
|
|
|
|
|
// the only consumer of these settings; recorders manage their own codecs.
|
2026-05-16 00:29:50 -04:00
|
|
|
|
await job.updateProgress(30);
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
const encSettings = await loadProxyEncodingSettings();
|
|
|
|
|
|
console.log(
|
|
|
|
|
|
`[proxy] Transcoding asset ${assetId} via ${encSettings._gpu ? 'GPU' : 'CPU'} ` +
|
2026-05-26 13:44:18 -04:00
|
|
|
|
`(${encSettings.videoCodec} ${encSettings.videoPreset} VBR ${encSettings.videoMinRate}-${encSettings.videoMaxRate} avg=${encSettings.videoBitrate})`
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
);
|
|
|
|
|
|
try {
|
|
|
|
|
|
await transcodeVideo(inputPath, outputPath, { ...encSettings, hasAudio });
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
if (encSettings._gpu) {
|
|
|
|
|
|
console.warn(`[proxy] GPU encode failed (${err.message}); falling back to libx264`);
|
|
|
|
|
|
await transcodeVideo(inputPath, outputPath, {
|
2026-05-26 13:44:18 -04:00
|
|
|
|
videoCodec: 'libx264', videoPreset: 'fast',
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
videoBitrate: encSettings.videoBitrate,
|
2026-05-26 13:44:18 -04:00
|
|
|
|
videoMinRate: encSettings.videoMinRate,
|
|
|
|
|
|
videoMaxRate: encSettings.videoMaxRate,
|
|
|
|
|
|
videoBufSize: encSettings.videoBufSize,
|
|
|
|
|
|
audioCodec: encSettings.audioCodec,
|
|
|
|
|
|
audioBitrate: encSettings.audioBitrate,
|
feat: SDK deployment UI, proxy encoding global settings, S3 env fallback
- Settings: drop AMPP tab, rename GPU/Transcoding → Proxy encoding
with explicit 'applied to every ingested file' wording, expose
CPU codec/preset options when GPU is off
- New Capture SDKs tab (Settings): upload Blackmagic / AJA / Deltacast
SDK archives (.zip / .tar.gz) staged to /sdk/<vendor>/ inside mam-api;
BMD is fully wired into the FFmpeg build pipeline, AJA + Deltacast
staging-only pending FFmpeg patches
- mam-api: new /api/v1/sdk routes (multer upload, extract, list, delete);
Dockerfile gets unzip+tar; docker-compose mounts /mnt/NVME/MAM/sdk:/sdk
- proxy worker now reads proxy-encoding settings from DB on every job,
builds args for libx264 / NVENC / VAAPI, falls back to libx264 on
hardware-encode failure
- settings GET /s3 falls back to S3_* env vars when DB is empty so the
UI reflects what's actually wired (fixes 'not configured' false alarm)
2026-05-22 22:58:32 -04:00
|
|
|
|
hasAudio,
|
|
|
|
|
|
});
|
|
|
|
|
|
} else { throw err; }
|
|
|
|
|
|
}
|
2026-04-07 21:58:19 -04:00
|
|
|
|
|
2026-05-15 21:26:16 -04:00
|
|
|
|
// Upload proxy to S3
|
2026-05-16 00:29:50 -04:00
|
|
|
|
await job.updateProgress(70);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
console.log(`[proxy] Uploading to ${outputKey}`);
|
|
|
|
|
|
await uploadToS3(S3_BUCKET, outputKey, outputPath);
|
|
|
|
|
|
|
2026-05-18 23:22:56 -04:00
|
|
|
|
// Update asset record — store extracted metadata + proxy key
|
|
|
|
|
|
// Use COALESCE so we never overwrite fields the capture service already set
|
2026-05-16 00:29:50 -04:00
|
|
|
|
await job.updateProgress(90);
|
feat(audio-tab): full audio track inspector with meters, mute/solo, faders
Issue #80 — replaces the stub AudioTab (two static waveforms) with a
broadcast-ops-grade audio panel:
- DB: add audio_metadata JSONB column to assets (migration 022)
- Worker: getMediaInfo now extracts per-stream audio metadata
(codec, channels, channel_layout, sample_rate, bit_depth, bit_rate,
language, title, disposition)
- Worker: proxy job persists audio_metadata into the assets row
- API: new GET /assets/:id/audio returns structured track list
- Frontend AudioTab: per-track rows with:
- Track name/index with language badge
- SVG waveform per track (color-coded)
- L/R level meters via Web Audio API AnalyserNode
- Per-track metadata row (codec, layout, sample rate, bit depth, bitrate)
- Mute / Solo buttons with proper solo-logic
- Per-track volume fader
- Master section with summed L/R meters and master fader
- MetadataTab: show audio track summary when audio_metadata present
- CSS: full audio-tab layout, responsive collapse at 900px
2026-05-27 00:53:52 -04:00
|
|
|
|
await query(
|
|
|
|
|
|
`UPDATE assets
|
|
|
|
|
|
SET proxy_s3_key = $1,
|
|
|
|
|
|
fps = COALESCE($2, fps),
|
|
|
|
|
|
codec = COALESCE($3, codec),
|
|
|
|
|
|
resolution = COALESCE($4, resolution),
|
|
|
|
|
|
duration_ms = COALESCE($5, duration_ms),
|
|
|
|
|
|
file_size = COALESCE($6, file_size),
|
|
|
|
|
|
audio_metadata = COALESCE($8, audio_metadata),
|
|
|
|
|
|
updated_at = NOW()
|
|
|
|
|
|
WHERE id = $7`,
|
|
|
|
|
|
[
|
|
|
|
|
|
outputKey,
|
|
|
|
|
|
mediaInfo.fps ?? null,
|
|
|
|
|
|
mediaInfo.codec ?? null,
|
|
|
|
|
|
mediaInfo.resolution ?? null,
|
|
|
|
|
|
mediaInfo.durationMs ?? null,
|
|
|
|
|
|
mediaInfo.fileSizeBytes ?? null,
|
|
|
|
|
|
assetId,
|
|
|
|
|
|
mediaInfo.audioMetadata ? JSON.stringify(mediaInfo.audioMetadata) : null,
|
|
|
|
|
|
]
|
|
|
|
|
|
);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
|
2026-05-15 21:26:16 -04:00
|
|
|
|
// Now proxy exists in S3 — safe to queue thumbnail generation
|
|
|
|
|
|
const thumbnailKey = `thumbnails/${assetId}.jpg`;
|
|
|
|
|
|
await thumbnailQueue.add('generate', {
|
|
|
|
|
|
assetId,
|
|
|
|
|
|
proxyKey: outputKey,
|
|
|
|
|
|
outputKey: thumbnailKey,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
console.log(`[proxy] Asset ${assetId} proxy complete, thumbnail job queued`);
|
2026-05-16 00:29:50 -04:00
|
|
|
|
await job.updateProgress(100);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
|
|
|
|
|
|
return { assetId, outputKey };
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error(`[proxy] Error processing asset ${assetId}:`, error);
|
|
|
|
|
|
await query(
|
2026-05-25 18:36:39 -04:00
|
|
|
|
`UPDATE assets SET status = 'error', updated_at = NOW()
|
|
|
|
|
|
WHERE id = $1 AND status NOT IN ('live', 'ingesting')`,
|
2026-05-15 21:26:16 -04:00
|
|
|
|
[assetId]
|
2026-04-07 21:58:19 -04:00
|
|
|
|
);
|
|
|
|
|
|
throw error;
|
|
|
|
|
|
} finally {
|
2026-05-15 21:26:16 -04:00
|
|
|
|
await Promise.all([
|
|
|
|
|
|
unlink(inputPath).catch(() => {}),
|
|
|
|
|
|
unlink(outputPath).catch(() => {}),
|
|
|
|
|
|
]);
|
2026-04-07 21:58:19 -04:00
|
|
|
|
}
|
|
|
|
|
|
};
|