From ea3dc4dcd4d429929c2ba7160e3912cf2b8135bb Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Mon, 4 Dec 2023 10:28:08 +0000 Subject: [PATCH] Use string as ffmpeg version type Ffmpeg 6 seems to not provide a semver version, as this is only used to report the version being used a `String` works fine here. --- Cargo.lock | 1 - Cargo.toml | 1 - agent/Cargo.toml | 1 - agent/src/ffmpeg/version.rs | 37 ++++++++++++++++++++++++++++--------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7439e169..16b3bd8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2319,7 +2319,6 @@ dependencies = [ "nix", "regex", "satori-common", - "semver", "serde", "serde_with", "tempfile", diff --git a/Cargo.toml b/Cargo.toml index 76daf98f..0ccc3d0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,6 @@ rust-s3 = "0.34.0-rc4" satori-common = { path = "./common" } satori-storage = { path = "./storage" } satori-testing-utils = { path = "./testing-utils" } -semver = "1.0.14" serde = { version = "1.0", features = ["derive"] } serde_with = "3.0" serde_json = "1.0.91" diff --git a/agent/Cargo.toml b/agent/Cargo.toml index eccb2327..d96a3bee 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -12,7 +12,6 @@ kagiyama.workspace = true nix.workspace = true regex.workspace = true satori-common.workspace = true -semver.workspace = true serde.workspace = true serde_with.workspace = true tempfile.workspace = true diff --git a/agent/src/ffmpeg/version.rs b/agent/src/ffmpeg/version.rs index 3eac0951..40b2ae4a 100644 --- a/agent/src/ffmpeg/version.rs +++ b/agent/src/ffmpeg/version.rs @@ -1,10 +1,9 @@ use regex::Regex; -use semver::Version; use std::process::Command; use tracing::info; /// Gets the version of ffmpeg based on the output of the `ffmpeg -version` command. -pub(crate) fn get_ffmpeg_version() -> Version { +pub(crate) fn get_ffmpeg_version() -> String { let ffmpeg_process = Command::new("ffmpeg") .arg("-version") .output() @@ -13,18 +12,36 @@ pub(crate) fn get_ffmpeg_version() -> Version { } /// Parses the output of `ffmpeg -version` to extract the version. -fn extract_version_from_version_output(text: &str) -> Version { - let version_string_regex = Regex::new(r"ffmpeg version.+(\d\.\d\.\d)").unwrap(); +fn extract_version_from_version_output(text: &str) -> String { + let version_string_regex = Regex::new(r"ffmpeg version (.*) Copyright").unwrap(); let version_string = version_string_regex.captures(text).unwrap(); - let version = Version::parse(&version_string[1]).unwrap(); - info!("Detected ffmpeg version: {}", version); - version + let version_string = version_string[1].to_string(); + info!("Detected ffmpeg version: {}", version_string); + version_string } #[cfg(test)] mod test { use super::*; + #[test] + fn test_version_6() { + let text = "ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers +built with gcc 12.3.0 (GCC) +configuration: --disable-static --prefix=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0 --target_os=linux --arch=x86_64 --pkg-config=pkg-config --enable-gpl --enable-version3 --disable-nonfree --enable-shared --enable-pic --disable-small --enable-runtime-cpudetect --disable-gray --enable-swscale-alpha --enable-hardcoded-tables --enable-safe-bitstream-reader --enable-pthreads --disable-w32threads --disable-os2threads --enable-network --enable-pixelutils --datadir=/nix/store/hj2xwsm8jigjc3ld27gcqmdv8fghs8qg-ffmpeg-6.0-data/share/ffmpeg --enable-ffmpeg --disable-ffplay --enable-ffprobe --bindir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-bin/bin --enable-avcodec --enable-avdevice --enable-avfilter --enable-avformat --enable-avutil --enable-postproc --enable-swresample --enable-swscale --libdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-lib/lib --incdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-dev/include --enable-doc --enable-htmlpages --enable-manpages --mandir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-man/share/man --enable-podpages --enable-txtpages --docdir=/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-ffmpeg-6.0-doc/share/doc/ffmpeg --enable-alsa --enable-bzlib --disable-libcelt --disable-cuda --disable-cuda-llvm --enable-libdav1d --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --disable-frei0r --disable-libfribidi --disable-libgme --enable-gnutls --disable-libgsm --disable-ladspa --enable-libmp3lame --disable-libaom --enable-libass --disable-libbluray --disable-libbs2b --disable-libdc1394 --enable-libdrm --enable-iconv --disable-libjack --disable-libmfx --disable-libmodplug --disable-libmysofa --enable-libopus --disable-librsvg --enable-libsrt --enable-libssh --disable-libtensorflow --enable-libtheora --enable-libv4l2 --enable-v4l2-m2m --enable-vaapi --enable-vdpau --enable-libvorbis --disable-libvmaf --enable-libvpx --disable-libwebp --disable-xlib --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --disable-libxcb-shape --disable-libxml2 --enable-lzma --enable-cuvid --enable-nvdec --enable-nvenc --disable-openal --disable-opencl --disable-libopencore-amrnb --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --enable-libpulse --disable-librav1e --enable-libsvtav1 --disable-librtmp --enable-sdl2 --enable-libsoxr --enable-libspeex --disable-libvidstab --disable-libvo-amrwbenc --enable-libx264 --enable-libx265 --disable-libxavs --enable-libxvid --disable-libzmq --enable-libzimg --enable-zlib --disable-vulkan --disable-libglslang --disable-libsmbclient --disable-debug --enable-optimizations --disable-extra-warnings --disable-stripping +libavutil 58. 2.100 / 58. 2.100 +libavcodec 60. 3.100 / 60. 3.100 +libavformat 60. 3.100 / 60. 3.100 +libavdevice 60. 1.100 / 60. 1.100 +libavfilter 9. 3.100 / 9. 3.100 +libswscale 7. 1.100 / 7. 1.100 +libswresample 4. 10.100 / 4. 10.100 +libpostproc 57. 1.100 / 57. 1.100 +"; + + assert_eq!(extract_version_from_version_output(text), "6.0".to_string()); + } + #[test] fn test_version_5() { let text = "ffmpeg version n5.1.2 Copyright (c) 2000-2022 the FFmpeg developers @@ -39,9 +56,10 @@ libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 "; + assert_eq!( extract_version_from_version_output(text), - Version::new(5, 1, 2) + "n5.1.2".to_string() ); } @@ -60,9 +78,10 @@ libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 "; + assert_eq!( extract_version_from_version_output(text), - Version::new(4, 3, 5) + "4.3.5-0+deb11u1".to_string() ); } }