support setting album art codec in transcode configs, set to png for g726 in mkv

This commit is contained in:
chaos 2023-10-20 16:51:14 +01:00
parent 5bef3f39fe
commit 4b6ad42c8b
No known key found for this signature in database
4 changed files with 33 additions and 2 deletions

View file

@ -14,6 +14,7 @@ pub fn add_presets(preset_categories: &mut Vec<PresetCategory>) {
sample_rate: Some("8000".to_string()),
channels: Some("1".to_string()),
bitrate: Some(format!("{}k", bitrate).to_string()),
album_art_codec: Some("h264".to_string()),
..TranscodeConfig::default()
},
})

View file

@ -102,7 +102,13 @@ pub fn progress_monitor(
match res.kind {
EventKind::Modify(_) => {
let mut file = fs::File::open(&file_path).unwrap();
let file = fs::File::open(&file_path);
let mut file = match file {
Ok(f) => f,
Err(_e) => {
break 'outer;
}
};
file.seek(SeekFrom::Start(pos)).unwrap();
pos = file.metadata().unwrap().len();

View file

@ -43,6 +43,27 @@ pub fn transcode(
command_args.extend(vec!["-b:a".to_string(), bitrate.to_string()]);
}
if let Some(album_art_codec) = &config.album_art_codec {
println!("{}", album_art_codec);
command_args.extend(vec!["-c:v".to_string(), album_art_codec.to_string()]);
if config.album_art_height.is_some() && config.album_art_width.is_some() {
let mut height: i16 = config.album_art_height.unwrap() as i16;
if height == 0 {
height = -1;
}
let mut width = config.album_art_width.unwrap() as i16;
if width == 0 {
width = -1;
}
command_args.extend(vec!["-vf".to_string(), format!("scale={}:{}", width, height)]);
println!("{:#?}", command_args);
}
}
command_args.push(dest);
let mut progress_thread: Option<JoinHandle<()>> = None;
@ -72,7 +93,7 @@ pub fn transcode(
}
if let Some(thread) = progress_thread {
fs::remove_file(progress_file.unwrap())?;
let _ = fs::remove_file(progress_file.unwrap());
thread.join().expect("thread couldn't join");
}

View file

@ -24,6 +24,9 @@ pub struct TranscodeConfig {
pub quality: Option<String>,
pub sample_rate: Option<String>,
pub channels: Option<String>,
pub album_art_codec: Option<String>,
pub album_art_height: Option<u16>,
pub album_art_width: Option<u16>,
}
impl TranscodeConfig {