add format convert support

This commit is contained in:
Julian Freeman
2025-12-08 17:48:22 -04:00
parent 77407c7e28
commit eada45bd9c
5 changed files with 63 additions and 9 deletions

View File

@@ -77,7 +77,7 @@ pub async fn start_download(app: AppHandle, url: String, options: DownloadOption
output_path: output_dir,
timestamp: chrono::Utc::now(),
status: status.to_string(),
format: options.quality,
format: options.output_format,
};
let _ = storage::add_history_item(&app, item);

View File

@@ -36,6 +36,7 @@ pub struct DownloadOptions {
pub is_audio_only: bool,
pub quality: String, // e.g., "1080", "720", "best"
pub output_path: String, // Directory
pub output_format: String, // "original", "mp4", "webm", "mkv", "m4a", "aac", "opus", "vorbis", "wav", etc.
}
#[derive(Serialize, Clone, Debug)]
@@ -188,8 +189,11 @@ pub async fn download_video(
// Formats
if options.is_audio_only {
args.push("-x".to_string());
args.push("--audio-format".to_string());
args.push("mp3".to_string());
// Only set audio format if not "original"
if options.output_format != "original" {
args.push("--audio-format".to_string());
args.push(options.output_format.clone());
}
} else {
let format_arg = if options.quality == "best" {
"bestvideo+bestaudio/best".to_string()
@@ -198,6 +202,12 @@ pub async fn download_video(
};
args.push("-f".to_string());
args.push(format_arg);
// Only set merge output format if not "original"
if options.output_format != "original" {
args.push("--merge-output-format".to_string());
args.push(options.output_format.clone());
}
}
// Progress output

View File

@@ -12,7 +12,7 @@
"app": {
"windows": [
{
"title": "流萤 - 视频下载",
"title": "流萤 - 视频下载 v1.0.0",
"width": 1300,
"height": 900
}