feat: support changing file name

This commit is contained in:
uku 2025-05-19 18:39:48 +02:00
parent 61c759d25e
commit a9837b7938
Signed by: uku
SSH key fingerprint: SHA256:4P0aN6M8ajKukNi6aPOaX0LacanGYtlfjmN+m/sHY/o
2 changed files with 11 additions and 3 deletions

View file

@ -98,7 +98,16 @@ pub async fn convert_video(
merge_tracks: bool,
sender: Sender<ProgressMessage>,
) -> 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 {
Codec::AV1 => &["-c:v", "libsvtav1"],
@ -118,7 +127,7 @@ pub async fn convert_video(
.args(["-c:a", "libopus", "-b:a", "96k"])
.args(codec_args)
.args(merge_args)
.args(["-loglevel", "error", "-progress", "-", "-nostats"])
.args(["-y", "-loglevel", "error", "-progress", "-", "-nostats"])
.arg(&out_path)
.stdout(Stdio::piped())
.spawn()?;

View file

@ -459,7 +459,6 @@ async fn the_process(app: UploadInfo, sender: &Sender<ProgressMessage>) -> Resul
.thumbnail_url(&app.config)
.ok_or_eyre("could not get thumbnail url")?;
// TODO get w&h from video
Ok(format!(
"https://autocompressor.net/av1?v={}&i={}&w={}&h={}",
Encoded(&zp_file.url),