fix still defaulting to av1, allow aac to be paired with flac
All checks were successful
Trigger quay.io Webhook / run (push) Successful in 4s
All checks were successful
Trigger quay.io Webhook / run (push) Successful in 4s
This commit is contained in:
parent
330515d6b4
commit
5808bff395
3 changed files with 37 additions and 23 deletions
|
@ -122,7 +122,7 @@ fn main() {
|
||||||
project
|
project
|
||||||
};
|
};
|
||||||
|
|
||||||
let renderer = Renderer::new(&directory, &project).unwrap();
|
let mut renderer = Renderer::new(&directory, &project).unwrap();
|
||||||
let recording = renderer.recording_mkv();
|
let recording = renderer.recording_mkv();
|
||||||
|
|
||||||
// preprocess the video
|
// preprocess the video
|
||||||
|
|
|
@ -59,10 +59,22 @@ pub(crate) enum FfmpegOutputFormat {
|
||||||
Av1Flac,
|
Av1Flac,
|
||||||
/// AV1 / OPUS
|
/// AV1 / OPUS
|
||||||
Av1Opus,
|
Av1Opus,
|
||||||
|
/// AVC (H.264) / FLAC
|
||||||
|
AvcFlac,
|
||||||
/// AVC (H.264) / AAC
|
/// AVC (H.264) / AAC
|
||||||
AvcAac
|
AvcAac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl FfmpegOutputFormat {
|
||||||
|
pub(crate) fn with_flac_audio(self) -> Self {
|
||||||
|
match self {
|
||||||
|
Self::Av1Flac | Self::AvcFlac => self,
|
||||||
|
Self::Av1Opus => Self::Av1Flac,
|
||||||
|
Self::AvcAac => Self::AvcFlac
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) enum FfmpegOutputQuality {
|
pub(crate) enum FfmpegOutputQuality {
|
||||||
Default,
|
Default,
|
||||||
VisuallyLossless
|
VisuallyLossless
|
||||||
|
@ -132,8 +144,10 @@ impl FfmpegOutput {
|
||||||
| (FfmpegOutputFormat::Av1Opus, false) => "libsvtav1",
|
| (FfmpegOutputFormat::Av1Opus, false) => "libsvtav1",
|
||||||
(FfmpegOutputFormat::Av1Flac, true)
|
(FfmpegOutputFormat::Av1Flac, true)
|
||||||
| (FfmpegOutputFormat::Av1Opus, true) => "av1_vaapi",
|
| (FfmpegOutputFormat::Av1Opus, true) => "av1_vaapi",
|
||||||
(FfmpegOutputFormat::AvcAac, false) => "h264",
|
(FfmpegOutputFormat::AvcAac, false)
|
||||||
(FfmpegOutputFormat::AvcAac, true) => "h264_vaapi"
|
| (FfmpegOutputFormat::AvcFlac, false) => "h264",
|
||||||
|
(FfmpegOutputFormat::AvcAac, true)
|
||||||
|
| (FfmpegOutputFormat::AvcFlac, true) => "h264_vaapi"
|
||||||
};
|
};
|
||||||
cmd.arg("-c:v").arg(vcodec);
|
cmd.arg("-c:v").arg(vcodec);
|
||||||
|
|
||||||
|
@ -164,7 +178,7 @@ impl FfmpegOutput {
|
||||||
cmd.arg("-c:v").arg("copy");
|
cmd.arg("-c:v").arg("copy");
|
||||||
}
|
}
|
||||||
cmd.arg("-c:a").arg(match self.format {
|
cmd.arg("-c:a").arg(match self.format {
|
||||||
FfmpegOutputFormat::Av1Flac => "flac",
|
FfmpegOutputFormat::Av1Flac | FfmpegOutputFormat::AvcFlac => "flac",
|
||||||
FfmpegOutputFormat::Av1Opus => "libopus",
|
FfmpegOutputFormat::Av1Opus => "libopus",
|
||||||
FfmpegOutputFormat::AvcAac => "aac"
|
FfmpegOutputFormat::AvcAac => "aac"
|
||||||
});
|
});
|
||||||
|
|
|
@ -140,6 +140,7 @@ fn svg2mkv(
|
||||||
duration: Time
|
duration: Time
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let mut ffmpeg = Ffmpeg::new(FfmpegOutput {
|
let mut ffmpeg = Ffmpeg::new(FfmpegOutput {
|
||||||
|
quality: FfmpegOutputQuality::VisuallyLossless,
|
||||||
duration: Some(duration),
|
duration: Some(duration),
|
||||||
time_base: Some(meta.source_tbn),
|
time_base: Some(meta.source_tbn),
|
||||||
fps_mode_vfr: true,
|
fps_mode_vfr: true,
|
||||||
|
@ -185,23 +186,21 @@ impl<'a> Renderer<'a> {
|
||||||
let target = directory.join(&slug);
|
let target = directory.join(&slug);
|
||||||
fs::create_dir_all(&target)?;
|
fs::create_dir_all(&target)?;
|
||||||
|
|
||||||
let first: PathBuf = directory.join(
|
// Ensure we have at least one input file.
|
||||||
project
|
project
|
||||||
.source
|
.source
|
||||||
.files
|
.files
|
||||||
.first()
|
.first()
|
||||||
.context("No source files present")?
|
.context("No source files present")?;
|
||||||
);
|
|
||||||
let height: u32 = ffprobe_video("stream=height", &first)?
|
// In case we don't have a resolution yet, we'll asign this after preprocessing.
|
||||||
.split('\n')
|
let format = project
|
||||||
.next()
|
.source
|
||||||
.unwrap()
|
.metadata
|
||||||
.parse()?;
|
.as_ref()
|
||||||
let format = if height < 1080 {
|
.map(|meta| meta.source_res.default_codec())
|
||||||
FfmpegOutputFormat::AvcAac
|
.unwrap_or(FfmpegOutputFormat::Av1Flac)
|
||||||
} else {
|
.with_flac_audio();
|
||||||
FfmpegOutputFormat::Av1Flac
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
directory,
|
directory,
|
||||||
|
@ -231,7 +230,7 @@ impl<'a> Renderer<'a> {
|
||||||
self.target.join(format!("question{q_idx}.png"))
|
self.target.join(format!("question{q_idx}.png"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn preprocess(&self, project: &mut Project) -> anyhow::Result<()> {
|
pub fn preprocess(&mut self, project: &mut Project) -> anyhow::Result<()> {
|
||||||
assert!(!project.progress.preprocessed);
|
assert!(!project.progress.preprocessed);
|
||||||
|
|
||||||
let recording_txt = self.target.join("recording.txt");
|
let recording_txt = self.target.join("recording.txt");
|
||||||
|
@ -272,6 +271,7 @@ impl<'a> Renderer<'a> {
|
||||||
source_res,
|
source_res,
|
||||||
source_sample_rate
|
source_sample_rate
|
||||||
});
|
});
|
||||||
|
self.format = source_res.default_codec().with_flac_audio();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ impl<'a> Renderer<'a> {
|
||||||
/// Get the video file for a specific resolution, completely finished.
|
/// Get the video file for a specific resolution, completely finished.
|
||||||
fn video_file_res(&self, res: Resolution) -> PathBuf {
|
fn video_file_res(&self, res: Resolution) -> PathBuf {
|
||||||
let extension = match res.default_codec() {
|
let extension = match res.default_codec() {
|
||||||
FfmpegOutputFormat::Av1Flac => "mkv",
|
FfmpegOutputFormat::Av1Flac | FfmpegOutputFormat::AvcFlac => "mkv",
|
||||||
FfmpegOutputFormat::Av1Opus => "webm",
|
FfmpegOutputFormat::Av1Opus => "webm",
|
||||||
FfmpegOutputFormat::AvcAac => "mp4"
|
FfmpegOutputFormat::AvcAac => "mp4"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue