feat: support changing file name
This commit is contained in:
parent
61c759d25e
commit
a9837b7938
2 changed files with 11 additions and 3 deletions
|
@ -98,7 +98,16 @@ pub async fn convert_video(
|
||||||
merge_tracks: bool,
|
merge_tracks: bool,
|
||||||
sender: Sender<ProgressMessage>,
|
sender: Sender<ProgressMessage>,
|
||||||
) -> Result<PathBuf> {
|
) -> Result<PathBuf> {
|
||||||
let out_path = PathBuf::from("/tmp/out.webm");
|
let out_filename = out_filename
|
||||||
|
.or_else(|| {
|
||||||
|
path.file_name()
|
||||||
|
.and_then(|s| s.to_str())
|
||||||
|
.map(|s| s.to_owned())
|
||||||
|
})
|
||||||
|
.unwrap_or("out.webm".into());
|
||||||
|
|
||||||
|
let mut out_path = std::env::temp_dir().join(out_filename);
|
||||||
|
out_path.set_extension("webm");
|
||||||
|
|
||||||
let codec_args: &[&str] = match out_codec {
|
let codec_args: &[&str] = match out_codec {
|
||||||
Codec::AV1 => &["-c:v", "libsvtav1"],
|
Codec::AV1 => &["-c:v", "libsvtav1"],
|
||||||
|
@ -118,7 +127,7 @@ pub async fn convert_video(
|
||||||
.args(["-c:a", "libopus", "-b:a", "96k"])
|
.args(["-c:a", "libopus", "-b:a", "96k"])
|
||||||
.args(codec_args)
|
.args(codec_args)
|
||||||
.args(merge_args)
|
.args(merge_args)
|
||||||
.args(["-loglevel", "error", "-progress", "-", "-nostats"])
|
.args(["-y", "-loglevel", "error", "-progress", "-", "-nostats"])
|
||||||
.arg(&out_path)
|
.arg(&out_path)
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.spawn()?;
|
.spawn()?;
|
||||||
|
|
|
@ -459,7 +459,6 @@ async fn the_process(app: UploadInfo, sender: &Sender<ProgressMessage>) -> Resul
|
||||||
.thumbnail_url(&app.config)
|
.thumbnail_url(&app.config)
|
||||||
.ok_or_eyre("could not get thumbnail url")?;
|
.ok_or_eyre("could not get thumbnail url")?;
|
||||||
|
|
||||||
// TODO get w&h from video
|
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"https://autocompressor.net/av1?v={}&i={}&w={}&h={}",
|
"https://autocompressor.net/av1?v={}&i={}&w={}&h={}",
|
||||||
Encoded(&zp_file.url),
|
Encoded(&zp_file.url),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue