mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02: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,20 +252,28 @@ impl Downloader {
|
||||||
format!("title={}", meta.title),
|
format!("title={}", meta.title),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
for (i, meta) in subtitles.iter().enumerate() {
|
|
||||||
input.extend(["-i".to_string(), meta.path.to_string_lossy().to_string()]);
|
// this formats are supporting embedding subtitles into the video container instead of
|
||||||
maps.extend([
|
// burning it into the video stream directly
|
||||||
"-map".to_string(),
|
let container_supports_softsubs =
|
||||||
(i + videos.len() + audios.len()).to_string(),
|
["mkv", "mp4"].contains(&dst.extension().unwrap_or_default().to_str().unwrap());
|
||||||
]);
|
|
||||||
metadata.extend([
|
if container_supports_softsubs {
|
||||||
format!("-metadata:s:s:{}", i),
|
for (i, meta) in subtitles.iter().enumerate() {
|
||||||
format!("language={}", meta.language),
|
input.extend(["-i".to_string(), meta.path.to_string_lossy().to_string()]);
|
||||||
]);
|
maps.extend([
|
||||||
metadata.extend([
|
"-map".to_string(),
|
||||||
format!("-metadata:s:s:{}", i),
|
(i + videos.len() + audios.len()).to_string(),
|
||||||
format!("title={}", meta.title),
|
]);
|
||||||
]);
|
metadata.extend([
|
||||||
|
format!("-metadata:s:s:{}", i),
|
||||||
|
format!("language={}", meta.language),
|
||||||
|
]);
|
||||||
|
metadata.extend([
|
||||||
|
format!("-metadata:s:s:{}", i),
|
||||||
|
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,14 +325,16 @@ impl Downloader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(position) = subtitles
|
if container_supports_softsubs {
|
||||||
.iter()
|
if let Some(position) = subtitles
|
||||||
.position(|meta| meta.language == default_subtitle)
|
.iter()
|
||||||
{
|
.position(|meta| meta.language == default_subtitle)
|
||||||
command_args.extend([
|
{
|
||||||
format!("-disposition:s:s:{}", position),
|
command_args.extend([
|
||||||
"forced".to_string(),
|
format!("-disposition:s:s:{}", position),
|
||||||
])
|
"forced".to_string(),
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue