mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Fix subtitle burn-in error (#198)
This commit is contained in:
parent
ce358041be
commit
7b1ed30b20
1 changed files with 34 additions and 29 deletions
|
|
@ -252,6 +252,13 @@ impl Downloader {
|
||||||
format!("title={}", meta.title),
|
format!("title={}", meta.title),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this formats are supporting embedding subtitles into the video container instead of
|
||||||
|
// burning it into the video stream directly
|
||||||
|
let container_supports_softsubs =
|
||||||
|
["mkv", "mp4"].contains(&dst.extension().unwrap_or_default().to_str().unwrap());
|
||||||
|
|
||||||
|
if container_supports_softsubs {
|
||||||
for (i, meta) in subtitles.iter().enumerate() {
|
for (i, meta) in subtitles.iter().enumerate() {
|
||||||
input.extend(["-i".to_string(), meta.path.to_string_lossy().to_string()]);
|
input.extend(["-i".to_string(), meta.path.to_string_lossy().to_string()]);
|
||||||
maps.extend([
|
maps.extend([
|
||||||
|
|
@ -267,6 +274,7 @@ impl Downloader {
|
||||||
format!("title={}", meta.title),
|
format!("title={}", meta.title),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (input_presets, mut output_presets) = self.ffmpeg_preset.into_input_output_args();
|
let (input_presets, mut output_presets) = self.ffmpeg_preset.into_input_output_args();
|
||||||
|
|
||||||
|
|
@ -283,17 +291,12 @@ impl Downloader {
|
||||||
.position(|m| m.language == default_subtitle)
|
.position(|m| m.language == default_subtitle)
|
||||||
{
|
{
|
||||||
match dst.extension().unwrap_or_default().to_str().unwrap() {
|
match dst.extension().unwrap_or_default().to_str().unwrap() {
|
||||||
|
"mkv" => (),
|
||||||
"mp4" => output_presets.extend([
|
"mp4" => output_presets.extend([
|
||||||
"-movflags".to_string(),
|
"-movflags".to_string(),
|
||||||
"faststart".to_string(),
|
"faststart".to_string(),
|
||||||
"-c:s".to_string(),
|
"-c:s".to_string(),
|
||||||
"mov_text".to_string(),
|
"mov_text".to_string(),
|
||||||
format!("-disposition:s:s:{}", position),
|
|
||||||
"forced".to_string(),
|
|
||||||
]),
|
|
||||||
"mkv" => output_presets.extend([
|
|
||||||
format!("-disposition:s:s:{}", position),
|
|
||||||
"forced".to_string(),
|
|
||||||
]),
|
]),
|
||||||
_ => {
|
_ => {
|
||||||
// remove '-c:v copy' and '-c:a copy' from output presets as its causes issues with
|
// remove '-c:v copy' and '-c:a copy' from output presets as its causes issues with
|
||||||
|
|
@ -314,7 +317,7 @@ impl Downloader {
|
||||||
output_presets.extend([
|
output_presets.extend([
|
||||||
"-vf".to_string(),
|
"-vf".to_string(),
|
||||||
format!(
|
format!(
|
||||||
"subtitles={}",
|
"ass={}",
|
||||||
subtitles.get(position).unwrap().path.to_str().unwrap()
|
subtitles.get(position).unwrap().path.to_str().unwrap()
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
|
|
@ -322,6 +325,7 @@ impl Downloader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if container_supports_softsubs {
|
||||||
if let Some(position) = subtitles
|
if let Some(position) = subtitles
|
||||||
.iter()
|
.iter()
|
||||||
.position(|meta| meta.language == default_subtitle)
|
.position(|meta| meta.language == default_subtitle)
|
||||||
|
|
@ -332,6 +336,7 @@ impl Downloader {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
command_args.extend(output_presets);
|
command_args.extend(output_presets);
|
||||||
if let Some(output_format) = self.output_format {
|
if let Some(output_format) = self.output_format {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue