Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src-tauri/src/conversion/ffmpeg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ pub fn build_args(
));
}

// 既存の変換はこれまでと同様 FFmpeg に任せる
if input_format.is_video()
&& output_format.is_audio()
{
return Ok(build_video_to_audio_args(input_path, output_path, options));
}

Ok(build_default_args(input_path, output_path, options))
}

Expand Down Expand Up @@ -123,6 +128,23 @@ fn build_gif_to_video_args(
args
}

fn build_video_to_audio_args(
input_path: &Path,
output_path: &Path,
options: &ConversionOptions, // 現時点では不使用だが、将来的にオーディオ変換オプションを追加するため引数として受け取る
) -> Vec<String> {
let mut args = vec![
"-y".into(),
"-i".into(),
path_to_string(input_path),
"-vn".into(),
];

args.push(path_to_string(output_path));

args
}

fn append_video_output_options(args: &mut Vec<String>, format: FileFormat) {
match format {
FileFormat::Mp4 => {
Expand Down
14 changes: 14 additions & 0 deletions src-tauri/src/conversion/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ impl FileFormat {
pub fn is_video(self) -> bool {
matches!(self, Self::Mp4 | Self::Webm | Self::Avi | Self::Mov)
}
pub fn is_audio(self) -> bool {
matches!(
self,
Self::Mp3
| Self::M4a
| Self::Aac
| Self::Wav
| Self::Aiff
| Self::Flac
| Self::Wma
| Self::Ogg
| Self::Opus
)
}
}

#[derive(Debug, Clone, Deserialize, Default)]
Expand Down
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function App() {
}

if (VIDEO_FORMATS.includes(sourceFormat as VideoFormat)) {
return [...VIDEO_FORMATS, "GIF"];
return [...VIDEO_FORMATS, "GIF", ...AUDIO_FORMATS];
}

if (AUDIO_FORMATS.includes(sourceFormat as AudioFormat)) {
Expand Down