diff options
Diffstat (limited to 'multimedia/wl-screenrec/files/patch-ffmpeg7')
-rw-r--r-- | multimedia/wl-screenrec/files/patch-ffmpeg7 | 313 |
1 files changed, 313 insertions, 0 deletions
diff --git a/multimedia/wl-screenrec/files/patch-ffmpeg7 b/multimedia/wl-screenrec/files/patch-ffmpeg7 new file mode 100644 index 000000000000..392cca81ccf9 --- /dev/null +++ b/multimedia/wl-screenrec/files/patch-ffmpeg7 @@ -0,0 +1,313 @@ +https://github.com/russelltg/wl-screenrec/commit/f73841b8d270 +https://github.com/russelltg/wl-screenrec/commit/098b9735fbc1 + +--- Cargo.lock.orig 2024-02-16 05:09:17 UTC ++++ Cargo.lock +@@ -67,37 +67,31 @@ name = "bindgen" + + [[package]] + name = "bindgen" +-version = "0.64.0" ++version = "0.69.4" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" ++checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" + dependencies = [ +- "bitflags 1.3.2", ++ "bitflags", + "cexpr", + "clang-sys", ++ "itertools", + "lazy_static", + "lazycell", +- "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", +- "syn 1.0.109", ++ "syn", + ] + + [[package]] + name = "bitflags" +-version = "1.3.2" ++version = "2.5.0" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" ++checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + + [[package]] +-name = "bitflags" +-version = "2.4.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +- +-[[package]] + name = "cc" + version = "1.0.83" + source = "registry+https://github.com/rust-lang/crates.io-index" +@@ -163,7 +157,7 @@ dependencies = [ + "heck", + "proc-macro2", + "quote", +- "syn 2.0.49", ++ "syn", + ] + + [[package]] +@@ -200,6 +194,12 @@ checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a04 + checksum = "0aafbcdb8afc29c1a7ee5fbe53b5d62f4565b35a042a662ca9fecd0b54dae6f4" + + [[package]] ++name = "either" ++version = "1.12.0" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" ++ ++[[package]] + name = "errno" + version = "0.3.8" + source = "registry+https://github.com/rust-lang/crates.io-index" +@@ -211,20 +211,20 @@ name = "ffmpeg-next" + + [[package]] + name = "ffmpeg-next" +-version = "6.1.1" ++version = "7.0.1" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "4e72c72e8dcf638fb0fb03f033a954691662b5dabeaa3f85a6607d101569fccd" ++checksum = "a681d69bf41d1c9edc7c6a2b09b69d0b96e9b916d200b7ec5b10de61f559eb31" + dependencies = [ +- "bitflags 1.3.2", ++ "bitflags", + "ffmpeg-sys-next", + "libc", + ] + + [[package]] + name = "ffmpeg-sys-next" +-version = "6.1.0" ++version = "7.0.0" + source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "c2529ad916d08c3562c754c21bc9b17a26c7882c0f5706cc2cd69472175f1620" ++checksum = "972a460dd8e901b737ce0482bf71a837e1751e3dd7c8f8b0a4ead808e7f174a5" + dependencies = [ + "bindgen", + "cc", +@@ -259,6 +259,15 @@ checksum = "9994b79e8c1a39b3166c63ae7823bb2b00831e2a96 + checksum = "9994b79e8c1a39b3166c63ae7823bb2b00831e2a96a31399c50fe69df408eaeb" + + [[package]] ++name = "itertools" ++version = "0.12.1" ++source = "registry+https://github.com/rust-lang/crates.io-index" ++checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" ++dependencies = [ ++ "either", ++] ++ ++[[package]] + name = "itoa" + version = "1.0.10" + source = "registry+https://github.com/rust-lang/crates.io-index" +@@ -322,7 +331,7 @@ dependencies = [ + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" + dependencies = [ +- "bitflags 2.4.2", ++ "bitflags", + "cfg-if", + "libc", + ] +@@ -348,12 +357,6 @@ dependencies = [ + ] + + [[package]] +-name = "peeking_take_while" +-version = "0.1.2" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" +- +-[[package]] + name = "pkg-config" + version = "0.3.30" + source = "registry+https://github.com/rust-lang/crates.io-index" +@@ -427,7 +430,7 @@ dependencies = [ + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" + dependencies = [ +- "bitflags 2.4.2", ++ "bitflags", + "errno", + "libc", + "linux-raw-sys", +@@ -463,7 +466,7 @@ dependencies = [ + dependencies = [ + "proc-macro2", + "quote", +- "syn 2.0.49", ++ "syn", + ] + + [[package]] +@@ -516,17 +519,6 @@ name = "syn" + + [[package]] + name = "syn" +-version = "1.0.109" +-source = "registry+https://github.com/rust-lang/crates.io-index" +-checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +-dependencies = [ +- "proc-macro2", +- "quote", +- "unicode-ident", +-] +- +-[[package]] +-name = "syn" + version = "2.0.49" + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496" +@@ -553,7 +545,7 @@ dependencies = [ + dependencies = [ + "proc-macro2", + "quote", +- "syn 2.0.49", ++ "syn", + ] + + [[package]] +@@ -594,7 +586,7 @@ dependencies = [ + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" + dependencies = [ +- "bitflags 2.4.2", ++ "bitflags", + "rustix", + "wayland-backend", + "wayland-scanner", +@@ -606,7 +598,7 @@ dependencies = [ + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" + dependencies = [ +- "bitflags 2.4.2", ++ "bitflags", + "wayland-backend", + "wayland-client", + "wayland-scanner", +@@ -618,7 +610,7 @@ dependencies = [ + source = "registry+https://github.com/rust-lang/crates.io-index" + checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" + dependencies = [ +- "bitflags 2.4.2", ++ "bitflags", + "wayland-backend", + "wayland-client", + "wayland-protocols", +@@ -787,6 +779,7 @@ dependencies = [ + "clap", + "drm-fourcc", + "ffmpeg-next", ++ "ffmpeg-sys-next", + "human-size", + "libc", + "nix", +--- Cargo.toml.orig 2024-02-16 05:09:17 UTC ++++ Cargo.toml +@@ -28,7 +28,8 @@ wayland-protocols-wlr = { version = "0.2", features = + wayland-protocols-wlr = { version = "0.2", features = ["client"] } + + # ffmpeg-next does not support ffmpeg 6.1 yet, so grab from the 6.1 PR +-ffmpeg-next = "6.1" ++ffmpeg-next = "7.0.1" ++ffmpeg-sys-next = "7.0.0" # need direct dep on -sys to get metadata to consume in build.rs + thiserror = "1.0.38" + drm-fourcc = "2.2.0" + human-size = "0.4.2" +--- build.rs.orig 2024-05-20 06:35:34 UTC ++++ build.rs +@@ -0,0 +1,12 @@ ++use std::env; ++ ++fn main() { ++ for (name, _value) in env::vars() { ++ if name.starts_with("DEP_FFMPEG_") { ++ println!( ++ r#"cargo:rustc-cfg=feature="{}""#, ++ name["DEP_FFMPEG_".len()..name.len()].to_lowercase() ++ ); ++ } ++ } ++} +\ No newline at end of file +--- src/audio.rs.orig 2024-02-16 05:09:17 UTC ++++ src/audio.rs +@@ -1,6 +1,6 @@ use std::{ + use std::{ + cmp::max, +- ffi::{c_int, CString}, ++ ffi::{CStr, CString}, + sync::{ + atomic::{AtomicBool, Ordering}, + mpsc::{channel, Receiver, RecvError, Sender, TryRecvError}, +@@ -13,7 +13,7 @@ use ffmpeg::{ + use ffmpeg::{ + codec::Context, + decoder, encoder, +- ffi::{av_find_input_format, av_get_default_channel_layout, AVChannelOrder}, ++ ffi::{av_channel_layout_describe, av_find_input_format}, + filter, + format::{self, context::Input, Sample}, + frame, ChannelLayout, Dictionary, Format, Packet, Rational, +@@ -220,6 +220,7 @@ impl AudioHandle { + let audio_decoder_rate = dec_audio.rate() as i32; + enc_audio.set_rate(audio_decoder_rate); + enc_audio.set_channel_layout(enc_audio_channel_layout); ++ #[cfg(not(feature = "ffmpeg_7_0"))] // in ffmpeg 7, this is handled by set_channel_layout + enc_audio.set_channels(enc_audio_channel_layout.channels()); + let audio_encode_format = codec.formats().unwrap().next().unwrap(); + enc_audio.set_format(audio_encode_format); +@@ -322,24 +323,34 @@ fn audio_filter( + ) -> filter::Graph { + let mut g = ffmpeg::filter::graph::Graph::new(); + +- // let channel_format_str = avchannelformat_to_string(params.ch_layout); + let sample_format = input.format(); + + let ch_layout = unsafe { input.as_ptr().read().ch_layout }; +- let ch_layout_mask = if ch_layout.order == AVChannelOrder::AV_CHANNEL_ORDER_NATIVE { +- unsafe { ch_layout.u.mask } +- } else { +- unsafe { av_get_default_channel_layout(input.channels() as c_int) as u64 } ++ ++ let mut channel_layout_buf = [0u8; 128]; ++ let channel_layout_specifier = unsafe { ++ let bytes = av_channel_layout_describe( ++ &ch_layout, ++ channel_layout_buf.as_mut_ptr().cast(), ++ channel_layout_buf.len(), ++ ); ++ assert!(bytes > 0, "{:?}: {:?}", ch_layout.order, bytes); ++ std::str::from_utf8( ++ CStr::from_bytes_until_nul(&channel_layout_buf[..]) ++ .unwrap() ++ .to_bytes(), ++ ) ++ .unwrap() + }; + + g.add( + &filter::find("abuffer").unwrap(), + "in", + &format!( +- "sample_rate={}:sample_fmt={}:channel_layout={:#x}", ++ "sample_rate={}:sample_fmt={}:channel_layout={}", + input.rate(), + sample_format.name(), +- ch_layout_mask ++ channel_layout_specifier + ), + ) + .unwrap(); |