allow preprocessing to keep stereo; asks which files to use
This commit is contained in:
parent
f4adda912a
commit
5c50b33251
3 changed files with 47 additions and 11 deletions
|
@ -157,7 +157,9 @@ enum FfmpegFilter {
|
|||
filters: Vec<Filter>,
|
||||
output: Cow<'static, str>
|
||||
},
|
||||
Loudnorm,
|
||||
Loudnorm {
|
||||
stereo: bool
|
||||
},
|
||||
Rescale(Resolution)
|
||||
}
|
||||
|
||||
|
@ -216,10 +218,14 @@ impl Ffmpeg {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn enable_loudnorm(&mut self) -> &mut Self {
|
||||
pub fn enable_loudnorm(&mut self, loudnorm_stereo: bool) -> &mut Self {
|
||||
match &mut self.filter {
|
||||
FfmpegFilter::None => self.filter = FfmpegFilter::Loudnorm,
|
||||
FfmpegFilter::Loudnorm => {},
|
||||
FfmpegFilter::None => {
|
||||
self.filter = FfmpegFilter::Loudnorm {
|
||||
stereo: loudnorm_stereo
|
||||
}
|
||||
},
|
||||
FfmpegFilter::Loudnorm { stereo } if *stereo == loudnorm_stereo => {},
|
||||
_ => panic!("An incompatible type of filter has been set before")
|
||||
}
|
||||
self
|
||||
|
@ -228,7 +234,6 @@ impl Ffmpeg {
|
|||
pub fn rescale_video(&mut self, res: Resolution) -> &mut Self {
|
||||
match &mut self.filter {
|
||||
FfmpegFilter::None => self.filter = FfmpegFilter::Rescale(res),
|
||||
FfmpegFilter::Loudnorm => {},
|
||||
_ => panic!("An incompatible type of filter has been set before")
|
||||
}
|
||||
self
|
||||
|
@ -243,7 +248,7 @@ impl Ffmpeg {
|
|||
let (vdec, venc, aenc) = match &self.filter {
|
||||
FfmpegFilter::None => (false, false, false),
|
||||
FfmpegFilter::Filters { .. } => (false, true, true),
|
||||
FfmpegFilter::Loudnorm => (false, false, true),
|
||||
FfmpegFilter::Loudnorm { .. } => (false, false, true),
|
||||
FfmpegFilter::Rescale(_) => (true, true, false)
|
||||
};
|
||||
|
||||
|
@ -286,7 +291,7 @@ impl Ffmpeg {
|
|||
cmd.arg("-map").arg("[v]");
|
||||
cmd.arg("-map").arg(channel('a', &output));
|
||||
},
|
||||
FfmpegFilter::Loudnorm => {
|
||||
FfmpegFilter::Loudnorm { stereo: false } => {
|
||||
cmd.arg("-af").arg(concat!(
|
||||
"pan=mono|c0=FR,",
|
||||
"loudnorm=dual_mono=true:print_format=summary,",
|
||||
|
@ -294,6 +299,10 @@ impl Ffmpeg {
|
|||
"aformat=sample_rates=48000"
|
||||
));
|
||||
},
|
||||
FfmpegFilter::Loudnorm { stereo: true } => {
|
||||
cmd.arg("-af")
|
||||
.arg("loudnorm=print_format=summary,aformat=sample_rates=48000");
|
||||
},
|
||||
FfmpegFilter::Rescale(res) => {
|
||||
cmd.arg("-vf").arg(if vaapi {
|
||||
format!("scale_vaapi=w={}:h={}", res.width(), res.height())
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<'a> Renderer<'a> {
|
|||
concat: true,
|
||||
..FfmpegInput::new(recording_txt)
|
||||
});
|
||||
ffmpeg.enable_loudnorm();
|
||||
ffmpeg.enable_loudnorm(project.source.stereo);
|
||||
ffmpeg.run()?;
|
||||
|
||||
let width = ffprobe_video("stream=width", &recording_mkv)?.parse()?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue