Skip to content

Commit 1b982c8

Browse files
committed
Fix rsmpeg multiple version compilation issue
- Removed feature-based rsmpeg selection that was causing all versions to compile - Now using simple platform-specific dependencies in Cargo.toml - Only the platform-appropriate rsmpeg version will be downloaded and compiled - Linux: rsmpeg 0.14.2 (FFmpeg 6) - Windows: rsmpeg 0.17.0 (FFmpeg 7) - macOS: rsmpeg 0.18.0 (FFmpeg 8) - Simplified rsmpeg_compat module to just re-export rsmpeg - Removed unnecessary feature flags and complexity
1 parent 4f38c33 commit 1b982c8

File tree

3 files changed

+21
-53
lines changed

3 files changed

+21
-53
lines changed

src/rust/Cargo.toml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ lib_ccxr = { path = "lib_ccxr" }
2626
url = "2.5.4"
2727
encoding_rs = "0.8.5"
2828

29-
# FFmpeg version-specific rsmpeg dependencies
30-
# Use feature flags to select: --features ffmpeg6, ffmpeg7, or ffmpeg8 (default)
31-
rsmpeg_ffmpeg6 = { package = "rsmpeg", version = "=0.14.2", default-features = false, features = ["link_system_ffmpeg"], optional = true }
32-
rsmpeg_ffmpeg7 = { package = "rsmpeg", version = "=0.17.0", default-features = false, features = ["link_system_ffmpeg"], optional = true }
33-
rsmpeg_ffmpeg8 = { package = "rsmpeg", version = "=0.18.0", default-features = false, features = ["link_system_ffmpeg"], optional = true }
29+
# Platform-specific rsmpeg versions
30+
[target.'cfg(target_os = "linux")'.dependencies]
31+
rsmpeg = { version = "=0.14.2", default-features = false, features = ["link_system_ffmpeg"], optional = true }
32+
33+
[target.'cfg(target_os = "windows")'.dependencies]
34+
rsmpeg = { version = "=0.17.0", default-features = false, features = ["link_system_ffmpeg"], optional = true }
35+
36+
[target.'cfg(target_os = "macos")'.dependencies]
37+
rsmpeg = { version = "=0.18.0", default-features = false, features = ["link_system_ffmpeg"], optional = true }
38+
39+
# Fallback for other platforms (FreeBSD, etc.)
40+
[target.'cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))'.dependencies]
41+
rsmpeg = { version = "=0.18.0", default-features = false, features = ["link_system_ffmpeg"], optional = true }
3442

3543
[build-dependencies]
3644
bindgen = "0.64.0"
@@ -41,14 +49,8 @@ wtv_debug = []
4149
enable_ffmpeg = []
4250
with_libcurl = []
4351

44-
# FFmpeg version selection features (for manual override)
45-
ffmpeg6 = ["rsmpeg_ffmpeg6"]
46-
ffmpeg7 = ["rsmpeg_ffmpeg7"]
47-
ffmpeg8 = ["rsmpeg_ffmpeg8"]
48-
49-
# hardsubx_ocr includes all FFmpeg versions, platform defaults: Linux=6, Windows=7, macOS/others=8
50-
# Override with --features "hardsubx_ocr,ffmpeg8" to force a specific version
51-
hardsubx_ocr = ["rsmpeg_ffmpeg6", "rsmpeg_ffmpeg7", "rsmpeg_ffmpeg8", "tesseract-sys", "leptonica-sys"]
52+
# hardsubx_ocr enables OCR and the platform-appropriate rsmpeg
53+
hardsubx_ocr = ["rsmpeg", "tesseract-sys", "leptonica-sys"]
5254

5355
[profile.release-with-debug]
5456
inherits = "release"

src/rust/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub mod decoder;
2020
pub mod encoder;
2121
pub mod es;
2222

23-
#[cfg(any(feature = "ffmpeg6", feature = "ffmpeg7", feature = "ffmpeg8"))]
23+
#[cfg(feature = "hardsubx_ocr")]
2424
pub mod rsmpeg_compat;
2525

2626
#[cfg(feature = "hardsubx_ocr")]

src/rust/src/rsmpeg_compat.rs

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
1-
// Re-export rsmpeg based on selected FFmpeg version feature or platform defaults
1+
// Re-export rsmpeg - the version is determined by platform-specific dependencies in Cargo.toml
2+
// Linux: rsmpeg 0.14.2 (FFmpeg 6)
3+
// Windows: rsmpeg 0.17.0 (FFmpeg 7)
4+
// macOS/others: rsmpeg 0.18.0 (FFmpeg 8)
25

3-
// Explicit feature flags take precedence
4-
#[cfg(feature = "ffmpeg6")]
5-
pub use rsmpeg_ffmpeg6 as rsmpeg;
6-
7-
#[cfg(all(feature = "ffmpeg7", not(feature = "ffmpeg6")))]
8-
pub use rsmpeg_ffmpeg7 as rsmpeg;
9-
10-
#[cfg(all(feature = "ffmpeg8", not(feature = "ffmpeg6"), not(feature = "ffmpeg7")))]
11-
pub use rsmpeg_ffmpeg8 as rsmpeg;
12-
13-
// Platform-specific defaults when no explicit feature is selected
14-
// Linux defaults to FFmpeg 6
15-
#[cfg(all(
16-
target_os = "linux",
17-
not(feature = "ffmpeg6"),
18-
not(feature = "ffmpeg7"),
19-
not(feature = "ffmpeg8")
20-
))]
21-
pub use rsmpeg_ffmpeg6 as rsmpeg;
22-
23-
// Windows defaults to FFmpeg 7
24-
#[cfg(all(
25-
target_os = "windows",
26-
not(feature = "ffmpeg6"),
27-
not(feature = "ffmpeg7"),
28-
not(feature = "ffmpeg8")
29-
))]
30-
pub use rsmpeg_ffmpeg7 as rsmpeg;
31-
32-
// macOS and other platforms default to FFmpeg 8
33-
#[cfg(all(
34-
not(target_os = "linux"),
35-
not(target_os = "windows"),
36-
not(feature = "ffmpeg6"),
37-
not(feature = "ffmpeg7"),
38-
not(feature = "ffmpeg8")
39-
))]
40-
pub use rsmpeg_ffmpeg8 as rsmpeg;
6+
pub use rsmpeg;

0 commit comments

Comments
 (0)