refactor: restructure project into a workspace by introducing a plugin API crate and modularizing individual plugin definitions.
Release / check-release (push) Successful in 17s
Release / build (push) Skipped
Release / package (deb) (push) Skipped
Release / package (rpm) (push) Skipped
Release / publish (push) Skipped
CI / test (push) Failing after 2m6s

This commit is contained in:
Elias Wendland
2026-07-17 15:50:50 +02:00
parent 2ea317e117
commit eb76ed1937
43 changed files with 4243 additions and 2296 deletions
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "convertis-ffmpeg-audio"
build = "../../plugin-build.rs"
version.workspace = true
edition.workspace = true
authors.workspace = true
license.workspace = true
repository.workspace = true
[lib]
crate-type = ["cdylib"]
[dependencies]
convertis-plugin-api.workspace = true
+83
View File
@@ -0,0 +1,83 @@
// Copyright (C) 2026 Elias Wendland <eliaswendland@pm.me>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3 exclusively.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use convertis_plugin_api::{Conversion, ConversionRequest, Plugin, PluginMetadata};
use std::process::Command;
const FORMATS: &[&str] = &[
"mp3", "ogg", "aac", "m4a", "opus", "wma", "wav", "flac", "aiff", "au",
];
struct FfmpegAudio;
fn available(binary: &str) -> Result<(), String> {
Command::new(binary)
.arg("-version")
.output()
.map_err(|_| format!("'{binary}' is required"))?
.status
.success()
.then_some(())
.ok_or_else(|| format!("'{binary}' is unavailable"))
}
impl Plugin for FfmpegAudio {
fn metadata(&self) -> PluginMetadata {
PluginMetadata {
id: "ffmpeg-audio".into(),
package: "convertis-ffmpeg-audio".into(),
description: "FFmpeg audio conversion".into(),
conversions: FORMATS
.iter()
.flat_map(|from| {
FORMATS
.iter()
.filter(move |to| to != &from)
.map(move |to| Conversion::file(from, to, (240, 220, 190)))
})
.collect(),
options: vec![],
}
}
fn availability(&self) -> Result<(), String> {
available("ffmpeg")
}
fn convert(&self, request: &ConversionRequest) -> Result<(), String> {
let codec: &[&str] = match request.to.as_str() {
"mp3" => &["-c:a", "libmp3lame", "-q:a", "2"],
"ogg" => &["-c:a", "libvorbis", "-q:a", "4"],
"aac" | "m4a" => &["-c:a", "aac", "-b:a", "192k"],
"opus" => &["-c:a", "libopus", "-b:a", "128k"],
"flac" => &["-c:a", "flac"],
"wav" | "aiff" | "au" => &["-c:a", "pcm_s16le"],
"wma" => &["-c:a", "wmav2", "-b:a", "192k"],
_ => &[],
};
let output = Command::new("ffmpeg")
.arg("-v")
.arg("error")
.arg("-y")
.arg("-i")
.arg(&request.input)
.args(codec)
.arg(&request.output)
.output()
.map_err(|error| error.to_string())?;
if output.status.success() {
Ok(())
} else {
Err(String::from_utf8_lossy(&output.stderr).into_owned())
}
}
}
convertis_plugin_api::export_plugin!(FfmpegAudio, "ffmpeg-audio");