Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions electron/ipc/export/native-video.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,16 @@ describe("buildNativeVideoAudioMuxArgs", () => {
expect(args.join(";")).not.toContain("-c:a;copy");
});

it("transcodes unknown source audio instead of copying unsafe codecs into MP4", () => {
const args = buildNativeVideoAudioMuxArgs("video.mp4", "source.wav", "out.mp4", {
audioMode: "copy-source",
outputDurationSec: 60,
});

expect(args).toEqual(expect.arrayContaining(["-c:a", "aac", "-b:a", "192k"]));
expect(args.join(";")).not.toContain("-c:a;copy");
});

it("keeps filtered audio on the AAC encode path", () => {
const args = buildNativeVideoAudioMuxArgs("video.mp4", "source.mp4", "out.mp4", {
audioMode: "trim-source",
Expand Down Expand Up @@ -906,6 +916,11 @@ describe("canCopyAudioCodecIntoMp4", () => {
it("blocks Opus so native exports transcode it to AAC for MP4", () => {
expect(canCopyAudioCodecIntoMp4("opus")).toBe(false);
});

it("blocks unknown codecs so sidecar WAV/PCM audio is encoded for MP4", () => {
expect(canCopyAudioCodecIntoMp4(undefined)).toBe(false);
expect(canCopyAudioCodecIntoMp4("")).toBe(false);
});
});

describe("validateNativeVideoStreamStats", () => {
Expand Down Expand Up @@ -1162,6 +1177,27 @@ describe("validateNvidiaCudaExportSummary", () => {
expect(issues).toEqual(["output audio duration is not positive"]);
});

it("rejects inline-audio CUDA output when the audio duration is missing", () => {
const issues = validateNvidiaCudaExportSummary(
{
success: true,
targetFrames: 300,
durationSec: 10,
nativeSummary: {
success: true,
frames: 300,
sourceTimestampMode: "pts",
selectionStage: "timestamp-mapped-callback",
},
outputVideo: { duration: "9.999900", nb_frames: "300" },
outputAudio: {},
},
{ durationSec: 10, targetFrames: 300, requiresTimelineSync: true },
);

expect(issues).toEqual(["missing output audio duration"]);
});

it("accepts audio CUDA output when the helper reports PTS-aligned selection", () => {
const issues = validateNvidiaCudaExportSummary(
{
Expand Down
6 changes: 4 additions & 2 deletions electron/ipc/export/native-video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ export function validateNvidiaCudaExportSummary(
if (expected.requiresTimelineSync) {
if (!summary.outputAudio) {
issues.push("missing output audio stream");
} else if (outputAudioDurationSec !== null && outputAudioDurationSec <= 0) {
} else if (outputAudioDurationSec === null) {
issues.push("missing output audio duration");
} else if (outputAudioDurationSec <= 0) {
issues.push("output audio duration is not positive");
}
}
Expand Down Expand Up @@ -3903,7 +3905,7 @@ export async function resolveNativeVideoEncoder(
export function canCopyAudioCodecIntoMp4(codec?: string | null) {
const normalized = (codec ?? "").trim().toLowerCase();
if (!normalized) {
return true;
return false;
}

return (
Expand Down