fix: address CodeRabbit review — muxing error guard, dead code removal, i18n

- Add encoderError check after awaiting pendingMuxing to prevent
  finalization of corrupt exports (both exporters)
- Remove unreachable synchronous fast-path in getMediaDurationSec
- Set preload='metadata' before src for correct browser behavior
- Localize audio processing status text with t()
This commit is contained in:
webadderall
2026-04-18 20:43:48 +10:00
parent cbe0b9feac
commit 028fd91ffd
4 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -4454,7 +4454,7 @@ export default function VideoEditor() {
</p>
{isRenderingAudio ? (
<p className="mt-1 text-[11px] text-muted-foreground/70">
Processing audio with speed/overlay edits
{t("editor.export.processingAudioEdits", "Processing audio with speed/overlay edits")}
</p>
) : exportRenderSpeedLabel ? (
<p className="mt-1 text-[11px] text-muted-foreground/70">
+1 -10
View File
@@ -1149,17 +1149,8 @@ export class AudioProcessor {
const source = await resolveMediaElementSource(url);
try {
const media = document.createElement("video");
media.src = source.src;
media.preload = "metadata";
if (
Number.isFinite(media.duration) &&
media.readyState >= HTMLMediaElement.HAVE_METADATA
) {
const duration = media.duration;
media.src = "";
return duration;
}
media.src = source.src;
return await new Promise<number>((resolve, reject) => {
const timeout = setTimeout(() => {
+7 -1
View File
@@ -434,6 +434,11 @@ export class ModernVideoExporter {
"muxing queued video chunks",
);
// Surface muxing errors before proceeding with finalization
if (this.encoderError) {
throw this.encoderError;
}
if (nativeAudioPlan.audioMode !== "none" && !shouldUseFfmpegAudioFallback && !this.cancelled) {
const demuxer = this.streamingDecoder.getDemuxer();
if (
@@ -1399,8 +1404,9 @@ export class ModernVideoExporter {
}
} catch (error) {
console.error("Muxing error:", error);
const muxingError = error instanceof Error ? error : new Error(String(error));
if (!this.encoderError) {
this.encoderError = error instanceof Error ? error : new Error(String(error));
this.encoderError = muxingError;
}
this.cancelled = true;
}
+10
View File
@@ -293,6 +293,11 @@ export class VideoExporter {
"muxing queued video chunks",
);
// Surface muxing errors before proceeding with finalization
if (this.encoderError) {
throw this.encoderError;
}
if (hasAudio && !shouldUseFfmpegAudioFallback && !this.cancelled) {
const demuxer = this.streamingDecoder.getDemuxer();
if (demuxer || hasAudioRegions || hasSourceAudioFallback) {
@@ -979,6 +984,11 @@ export class VideoExporter {
}
} catch (error) {
console.error("Muxing error:", error);
const muxingError = error instanceof Error ? error : new Error(String(error));
if (!this.encoderError) {
this.encoderError = muxingError;
}
this.cancelled = true;
}
});
this.encodeQueue--;