Skip to content
Open
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
13 changes: 6 additions & 7 deletions src/lib/exporter/modernFrameRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,14 +623,13 @@ export class FrameRenderer {
};

const preferredRenderBackend = this.config.preferredRenderBackend;
// Default to WebGL to match the preview renderer (VideoPlayback.tsx) and
// the legacy export renderer, so exported frames render on the same
// backend users see while editing. WebGPU remains available when it is
// explicitly requested; unproven WebGPU support has failed mid-export
// inside PixiJS bind-group setup on some Linux drivers.
const backendOrder: ExportRenderBackend[] =
preferredRenderBackend === "webgl"
? ["webgl", "webgpu"]
: preferredRenderBackend === "webgpu"
? ["webgpu", "webgl"]
: typeof navigator !== "undefined" && "gpu" in navigator
? ["webgpu", "webgl"]
: ["webgl"];
preferredRenderBackend === "webgpu" ? ["webgpu", "webgl"] : ["webgl", "webgpu"];
const failures: PixiRendererAttempt[] = [];

for (const backend of backendOrder) {
Expand Down
27 changes: 22 additions & 5 deletions src/lib/exporter/modernVideoExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2780,21 +2780,38 @@ export class ModernVideoExporter {
return false;
}

const encoderConfig: VideoEncoderConfig = {
const buildEncoderConfig = (
hardwareAcceleration: VideoEncoderConfig["hardwareAcceleration"],
): VideoEncoderConfig => ({
codec: "avc1.640034",
width: this.config.width,
height: this.config.height,
bitrate: this.config.bitrate,
framerate: this.config.frameRate,
hardwareAcceleration: "prefer-hardware",
hardwareAcceleration,
avc: { format: "annexb" },
};
});

// Prefer hardware H.264, but fall back to software. Recordly disables
// VA-API on Linux (see electron/gpuSwitches.ts), so hardware encoding is
// frequently unavailable there even though software encoding works.
let encoderConfig = buildEncoderConfig("prefer-hardware");

try {
const support = await VideoEncoder.isConfigSupported(encoderConfig);
if (!support.supported) {
this.lastNativeExportError = `H.264 Annex B encoding is not supported at ${this.config.width}x${this.config.height}.`;
return false;
const softwareConfig = buildEncoderConfig("prefer-software");
const softwareSupport = await VideoEncoder.isConfigSupported(softwareConfig);

if (!softwareSupport.supported) {
this.lastNativeExportError = `H.264 Annex B encoding is not supported at ${this.config.width}x${this.config.height}.`;
return false;
}

encoderConfig = softwareConfig;
console.warn(
`[VideoExporter] ${NATIVE_EXPORT_ENGINE_NAME} hardware H.264 encoding is unavailable at ${this.config.width}x${this.config.height}; using software encoding instead.`,
);
}
} catch (error) {
this.lastNativeExportError = error instanceof Error ? error.message : String(error);
Expand Down
26 changes: 21 additions & 5 deletions src/lib/exporter/videoExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,23 +686,39 @@ export class VideoExporter {
return false;
}

const encoderConfig: VideoEncoderConfig = {
const buildEncoderConfig = (
hardwareAcceleration: VideoEncoderConfig["hardwareAcceleration"],
): VideoEncoderConfig => ({
codec: "avc1.640034",
width: this.config.width,
height: this.config.height,
bitrate: this.config.bitrate,
framerate: this.config.frameRate,
hardwareAcceleration: "prefer-hardware",
hardwareAcceleration,
avc: { format: "annexb" },
};
});

// Hardware H.264 is unavailable on many Linux builds because VA-API is
// disabled (see electron/gpuSwitches.ts); software encoding still works.
let encoderConfig = buildEncoderConfig("prefer-hardware");

try {
const support = await VideoEncoder.isConfigSupported(encoderConfig);
if (!support.supported) {
const softwareConfig = buildEncoderConfig("prefer-software");
const softwareSupport = await VideoEncoder.isConfigSupported(softwareConfig);

if (!softwareSupport.supported) {
console.warn(
`[VideoExporter] Native H.264 Annex B encoding is unsupported at ${this.config.width}x${this.config.height}`,
);
return false;
}

encoderConfig = softwareConfig;
console.warn(
`[VideoExporter] Native H.264 Annex B encoding is unsupported at ${this.config.width}x${this.config.height}`,
`[VideoExporter] Native hardware H.264 encoding is unavailable at ${this.config.width}x${this.config.height}; using software encoding instead.`,
);
return false;
}
} catch (error) {
console.warn("[VideoExporter] Native encoder support check failed:", error);
Expand Down