support setting album art codec in transcode configs, set to png for g726 in mkv
This commit is contained in:
parent
5bef3f39fe
commit
4b6ad42c8b
|
@ -14,6 +14,7 @@ pub fn add_presets(preset_categories: &mut Vec<PresetCategory>) {
|
||||||
sample_rate: Some("8000".to_string()),
|
sample_rate: Some("8000".to_string()),
|
||||||
channels: Some("1".to_string()),
|
channels: Some("1".to_string()),
|
||||||
bitrate: Some(format!("{}k", bitrate).to_string()),
|
bitrate: Some(format!("{}k", bitrate).to_string()),
|
||||||
|
album_art_codec: Some("h264".to_string()),
|
||||||
..TranscodeConfig::default()
|
..TranscodeConfig::default()
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -102,7 +102,13 @@ pub fn progress_monitor(
|
||||||
|
|
||||||
match res.kind {
|
match res.kind {
|
||||||
EventKind::Modify(_) => {
|
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();
|
file.seek(SeekFrom::Start(pos)).unwrap();
|
||||||
|
|
||||||
pos = file.metadata().unwrap().len();
|
pos = file.metadata().unwrap().len();
|
||||||
|
|
|
@ -43,6 +43,27 @@ pub fn transcode(
|
||||||
command_args.extend(vec!["-b:a".to_string(), bitrate.to_string()]);
|
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);
|
command_args.push(dest);
|
||||||
|
|
||||||
let mut progress_thread: Option<JoinHandle<()>> = None;
|
let mut progress_thread: Option<JoinHandle<()>> = None;
|
||||||
|
@ -72,7 +93,7 @@ pub fn transcode(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(thread) = progress_thread {
|
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");
|
thread.join().expect("thread couldn't join");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@ pub struct TranscodeConfig {
|
||||||
pub quality: Option<String>,
|
pub quality: Option<String>,
|
||||||
pub sample_rate: Option<String>,
|
pub sample_rate: Option<String>,
|
||||||
pub channels: 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 {
|
impl TranscodeConfig {
|
||||||
|
|
Loading…
Reference in a new issue