add format convert support
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"app": {
|
||||
"windows": [
|
||||
{
|
||||
"title": "流萤 - 视频下载",
|
||||
"title": "流萤 - 视频下载 v1.0.0",
|
||||
"width": 1300,
|
||||
"height": 900
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user