Fix VideoToolbox fallback and encode error reporting

This commit is contained in:
2026-04-01 21:00:48 -04:00
parent b35a130c3a
commit d9160f414c
4 changed files with 36 additions and 1 deletions

View File

@@ -20,6 +20,8 @@ pub fn append_args(
"0".to_string(),
"-q:v".to_string(),
cq.to_string(),
"-allow_sw".to_string(),
"1".to_string(),
]);
}
Encoder::HevcVideotoolbox => {
@@ -32,6 +34,8 @@ pub fn append_args(
cq.to_string(),
"-tag:v".to_string(),
"hvc1".to_string(),
"-allow_sw".to_string(),
"1".to_string(),
]);
}
Encoder::H264Videotoolbox => {
@@ -42,6 +46,8 @@ pub fn append_args(
"0".to_string(),
"-q:v".to_string(),
cq.to_string(),
"-allow_sw".to_string(),
"1".to_string(),
]);
}
_ => {}

View File

@@ -993,7 +993,9 @@ impl Pipeline {
.update_job_state(job.id, crate::db::JobState::Cancelled)
.await;
} else {
tracing::error!("Job {}: Transcode failed: {}", job.id, e);
let msg = format!("Transcode failed: {e}");
tracing::error!("Job {}: {}", job.id, msg);
let _ = self.db.add_log("error", Some(job.id), &msg).await;
let _ = self
.update_job_state(job.id, crate::db::JobState::Failed)
.await;

View File

@@ -1048,6 +1048,12 @@ fn plan_filters(
filters.push(FilterStep::HwUpload);
}
if encoder.backend() == crate::media::pipeline::EncoderBackend::Videotoolbox {
filters.push(FilterStep::Format {
pixel_format: "yuv420p".to_string(),
});
}
filters
}

View File

@@ -234,6 +234,27 @@ function explainFailureSummary(summary: string): string {
return "Encoding produced an empty output file. This usually means FFmpeg crashed silently. Check the logs below for FFmpeg output.";
}
if (
normalized.includes("videotoolbox") ||
normalized.includes("vt_compression") ||
normalized.includes("err=-12902") ||
normalized.includes("mediaserverd") ||
normalized.includes("no capable devices")
) {
return "The VideoToolbox hardware encoder failed. This can happen when the GPU is busy, the file uses an unsupported pixel format, or macOS Media Services are unavailable. Retry the job — if it keeps failing, CPU fallback is available in Settings → Hardware.";
}
if (
normalized.includes("encoder fallback") ||
normalized.includes("fallback detected")
) {
return "The hardware encoder was unavailable and fell back to software encoding, which was not allowed by your settings. Enable CPU fallback in Settings → Hardware, or retry when the GPU is less busy.";
}
if (normalized.includes("ffmpeg failed")) {
return "FFmpeg failed during encoding. Check the logs below for the specific error. Common causes: unsupported pixel format, codec not available, or corrupt source file.";
}
return summary;
}