mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-12-03 10:47:06 +03:00
Fix deletes on defaulted ffmpeg args (#25145)
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Build (push) Waiting to run
CI / AMD64 Smoke Test (push) Blocked by required conditions
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
/**
|
||||
* Hardware acceleration args widget -- MEDIUM tier.
|
||||
* FFmpeg args widget -- MEDIUM tier.
|
||||
*
|
||||
* Global hwaccel offers Auto (writes "auto") and Disabled (writes []).
|
||||
* Cameras offer Disabled next to "Inherit from global setting".
|
||||
* Global input and record args offer Default, and record_sub offers
|
||||
* "Same as record" (writes []).
|
||||
*/
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
import { resolve, dirname } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { Locator } from "@playwright/test";
|
||||
import { test, expect, type FrigateApp } from "../../fixtures/frigate-test";
|
||||
import {
|
||||
configFactory,
|
||||
@@ -49,7 +52,10 @@ async function openSettings(
|
||||
json: {
|
||||
hwaccel_args: ["preset-vaapi", "preset-nvidia"],
|
||||
input_args: ["preset-rtsp-generic"],
|
||||
output_args: { record: ["preset-record-generic"], detect: [] },
|
||||
output_args: {
|
||||
record: ["preset-record-generic", "preset-record-generic-audio-aac"],
|
||||
detect: [],
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
@@ -576,3 +582,242 @@ test.describe("hwaccel args widget @medium", () => {
|
||||
).toBeChecked();
|
||||
});
|
||||
});
|
||||
|
||||
const DEFAULT_MODE = "default";
|
||||
const DEFAULTED_FIELDS = ["root_input_args", "root_output_args_record"];
|
||||
const RECORD_SUB = "root_output_args_record_sub";
|
||||
|
||||
// Sections also open on their own when a field inside them has a pending
|
||||
// change, so a blind click can close one again. Clicks inside a section
|
||||
// wait for its open animation to finish.
|
||||
const expand = async (trigger: Locator) => {
|
||||
await expect(async () => {
|
||||
if ((await trigger.getAttribute("aria-expanded")) !== "true") {
|
||||
await trigger.click();
|
||||
}
|
||||
await expect(trigger).toHaveAttribute("aria-expanded", "true", {
|
||||
timeout: 1_000,
|
||||
});
|
||||
}).toPass();
|
||||
await trigger.page().waitForFunction(() =>
|
||||
document
|
||||
.getAnimations()
|
||||
.filter((animation) =>
|
||||
(animation as CSSAnimation).animationName?.startsWith("collapsible"),
|
||||
)
|
||||
.every((animation) => animation.playState === "finished"),
|
||||
);
|
||||
};
|
||||
|
||||
const showOutputArgs = (app: FrigateApp) =>
|
||||
expand(
|
||||
app.page
|
||||
.locator("[aria-expanded]")
|
||||
.filter({ has: app.page.getByText("Output arguments", { exact: true }) }),
|
||||
);
|
||||
|
||||
// A sidebar switch lands after a delay, so wait for the FFmpeg form before
|
||||
// opening its sections.
|
||||
const showGlobalArgs = async (app: FrigateApp) => {
|
||||
await expect(radio(app, "root_hwaccel_args", "auto")).toBeVisible();
|
||||
await expand(app.page.getByRole("button", { name: /Advanced/ }).first());
|
||||
await showOutputArgs(app);
|
||||
};
|
||||
|
||||
const switchSection = (app: FrigateApp, name: string) =>
|
||||
app.page
|
||||
.locator('[data-sidebar="menu-sub-button"]', {
|
||||
hasText: new RegExp(`^${name}$`),
|
||||
})
|
||||
.click();
|
||||
|
||||
// The sidebar commits a switch after a delay, and a second click before
|
||||
// then cancels the first, so wait for the FFmpeg form to unmount.
|
||||
const leaveFfmpegAndReturn = async (app: FrigateApp) => {
|
||||
await switchSection(app, "Recording");
|
||||
await expect(radio(app, "root_hwaccel_args", "auto")).toHaveCount(0);
|
||||
await switchSection(app, "FFmpeg");
|
||||
};
|
||||
|
||||
test.describe("ffmpeg default args @medium", () => {
|
||||
test("global defaults show Default", async ({ frigateApp }) => {
|
||||
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
|
||||
}
|
||||
});
|
||||
|
||||
test("global Default on defaults sends no delete", async ({ frigateApp }) => {
|
||||
const capture = await openSettings(
|
||||
frigateApp,
|
||||
"/settings?page=globalFfmpeg",
|
||||
);
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
const unset = radio(frigateApp, field, DEFAULT_MODE);
|
||||
await radio(frigateApp, field, "manual").click();
|
||||
await manualInput(frigateApp, field).fill("-x 1");
|
||||
await unset.click();
|
||||
await expect(unset).toBeChecked();
|
||||
}
|
||||
|
||||
await frigateApp.page
|
||||
.getByRole("switch", { name: "Apple compatibility" })
|
||||
.click();
|
||||
await save(frigateApp).click();
|
||||
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
|
||||
config_data: { ffmpeg: { apple_compatibility: true } },
|
||||
});
|
||||
const { ffmpeg } = (
|
||||
capture.saved() as { config_data: { ffmpeg: Record<string, unknown> } }
|
||||
).config_data;
|
||||
expect(ffmpeg).not.toHaveProperty("input_args");
|
||||
expect(ffmpeg).not.toHaveProperty("output_args");
|
||||
});
|
||||
|
||||
test("Default then Manual starts with an empty box", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
const manual = radio(frigateApp, field, "manual");
|
||||
await manual.click();
|
||||
|
||||
await expect(manual).toBeChecked();
|
||||
await expect(manualInput(frigateApp, field)).toHaveValue("");
|
||||
}
|
||||
await expect(save(frigateApp)).toBeDisabled();
|
||||
});
|
||||
|
||||
test("global Default on defaults stays across a section switch", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
test.skip(frigateApp.isMobile, "the section sidebar is desktop only");
|
||||
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
await radio(frigateApp, field, "manual").click();
|
||||
await manualInput(frigateApp, field).fill("-x 1");
|
||||
await radio(frigateApp, field, DEFAULT_MODE).click();
|
||||
}
|
||||
await leaveFfmpegAndReturn(frigateApp);
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
|
||||
}
|
||||
await expect(save(frigateApp)).toBeDisabled();
|
||||
});
|
||||
|
||||
test("global Default on saved args deletes them", async ({ frigateApp }) => {
|
||||
test.skip(frigateApp.isMobile, "the section sidebar is desktop only");
|
||||
const capture = await openSettings(
|
||||
frigateApp,
|
||||
"/settings?page=globalFfmpeg",
|
||||
{ ffmpeg: { input_args: "-in 1", output_args: { record: "-out 1" } } },
|
||||
);
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
await radio(frigateApp, field, DEFAULT_MODE).click();
|
||||
}
|
||||
await leaveFfmpegAndReturn(frigateApp);
|
||||
await showGlobalArgs(frigateApp);
|
||||
for (const field of DEFAULTED_FIELDS) {
|
||||
await expect(radio(frigateApp, field, DEFAULT_MODE)).toBeChecked();
|
||||
}
|
||||
|
||||
await save(frigateApp).click();
|
||||
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
|
||||
config_data: {
|
||||
ffmpeg: { input_args: "", output_args: { record: "" } },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test("Same as record on defaults leaves nothing to save", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
await openSettings(frigateApp, "/settings?page=globalFfmpeg");
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
const sameAsRecord = radio(frigateApp, RECORD_SUB, "inherit");
|
||||
await expect(sameAsRecord).toBeChecked();
|
||||
await radio(frigateApp, RECORD_SUB, "preset").click();
|
||||
await expect(save(frigateApp)).toBeEnabled();
|
||||
await sameAsRecord.click();
|
||||
|
||||
await expect(sameAsRecord).toBeChecked();
|
||||
await expect(save(frigateApp)).toBeDisabled();
|
||||
});
|
||||
|
||||
test("global Same as record on saved args saves an empty list", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
const capture = await openSettings(
|
||||
frigateApp,
|
||||
"/settings?page=globalFfmpeg",
|
||||
{ ffmpeg: { output_args: { record_sub: "preset-record-generic" } } },
|
||||
);
|
||||
await showGlobalArgs(frigateApp);
|
||||
|
||||
await radio(frigateApp, RECORD_SUB, "inherit").click();
|
||||
await save(frigateApp).click();
|
||||
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
|
||||
config_data: { ffmpeg: { output_args: { record_sub: [] } } },
|
||||
});
|
||||
});
|
||||
|
||||
test("camera Same as record over a global value saves an empty list", async ({
|
||||
frigateApp,
|
||||
}) => {
|
||||
const recordSub = { output_args: { record_sub: "preset-record-generic" } };
|
||||
const capture = await openSettings(
|
||||
frigateApp,
|
||||
"/settings?page=cameraFfmpeg&camera=front_door",
|
||||
{
|
||||
ffmpeg: recordSub,
|
||||
cameras: {
|
||||
front_door: { ffmpeg: recordSub },
|
||||
backyard: { ffmpeg: { input_args: "-backyard 1" } },
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
// Only Backyard has manual input args, which shows which camera's form
|
||||
// is on screen.
|
||||
const inputArgs = (mode: string) =>
|
||||
radio(frigateApp, "root_input_args", mode);
|
||||
const sameAsRecord = radio(frigateApp, RECORD_SUB, "inherit");
|
||||
await expect(inputArgs("inherit")).toBeChecked();
|
||||
await showOutputArgs(frigateApp);
|
||||
await sameAsRecord.click();
|
||||
await frigateApp.page
|
||||
.getByRole("button", { name: "Select a camera" })
|
||||
.click();
|
||||
await frigateApp.page.getByRole("switch", { name: "Backyard" }).click();
|
||||
await expect(inputArgs("manual")).toBeChecked();
|
||||
await frigateApp.page
|
||||
.getByRole("button", { name: "Select a camera" })
|
||||
.click();
|
||||
await frigateApp.page.getByRole("switch", { name: "Front Door" }).click();
|
||||
await expect(inputArgs("inherit")).toBeChecked();
|
||||
await showOutputArgs(frigateApp);
|
||||
await expect(sameAsRecord).toBeChecked();
|
||||
|
||||
await save(frigateApp).click();
|
||||
await expect.poll(capture.saved, { timeout: 5_000 }).toMatchObject({
|
||||
config_data: {
|
||||
cameras: {
|
||||
front_door: { ffmpeg: { output_args: { record_sub: [] } } },
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user