switch to hgaiser's patched ffmpeg_next
(Also patches places where we accidentally were relying on the ffmpeg_the_third crate instead of the re-exported name. Oops) This will allow for hardware encoding fun in a bit.. :)
This commit is contained in:
parent
f388eb32b2
commit
45a8d60e7a
5 changed files with 43 additions and 29 deletions
41
server/Cargo.lock
generated
41
server/Cargo.lock
generated
|
@ -296,29 +296,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "ffmpeg-sys-the-third"
|
||||
version = "2.0.0+ffmpeg-7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a82bfdb0a7925996707f0a7dc37b2f3251ff5a15d26e78c586adb60c240dedc5"
|
||||
name = "ffmpeg-next"
|
||||
version = "7.0.0"
|
||||
source = "git+https://github.com/hgaiser/rust-ffmpeg?branch=codec-context-settable#d0619becf37f3ac463d344002dd353f8aed2a21f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"ffmpeg-sys-next",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ffmpeg-sys-next"
|
||||
version = "7.0.0"
|
||||
source = "git+https://github.com/hgaiser/rust-ffmpeg-sys?branch=cuda#c684bec7a322d7531648d7fc3b559970a7673806"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"libc",
|
||||
"num_cpus",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ffmpeg-the-third"
|
||||
version = "2.0.1+ffmpeg-7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4aa99eb55979d5c1db3b0b7a807a5e50dda07f5f6c2dbc6e9b50c205f611646"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"ffmpeg-sys-the-third",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.33"
|
||||
|
@ -700,6 +699,16 @@ dependencies = [
|
|||
"minimal-lexical",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_cpus"
|
||||
version = "1.16.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.36.4"
|
||||
|
@ -1308,7 +1317,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
"ffmpeg-the-third",
|
||||
"ffmpeg-next",
|
||||
"futures",
|
||||
"futures-util",
|
||||
"rand",
|
||||
|
|
|
@ -17,9 +17,14 @@ futures = "0.3"
|
|||
futures-util = { version = "0.3", default-features = false, features = ["sink", "std"] }
|
||||
|
||||
# ffmpeg
|
||||
ffmpeg-the-third = "2.0.1"
|
||||
ffmpeg = { version = "7.0.0", package = "ffmpeg-next" }
|
||||
|
||||
# misc stuff
|
||||
rand = "0.8.5"
|
||||
serde = "1.0.209"
|
||||
serde_json = "1.0.128"
|
||||
|
||||
|
||||
[patch.crates-io]
|
||||
ffmpeg = { version = "7.0.0", package = "ffmpeg-next", git = "https://github.com/hgaiser/rust-ffmpeg", branch = "codec-context-settable" }
|
||||
ffmpeg-sys-next = { version = "7.0.0", git = "https://github.com/hgaiser/rust-ffmpeg-sys", branch = "cuda" }
|
|
@ -143,8 +143,8 @@ async fn main() -> anyhow::Result<()> {
|
|||
// make a new frame for the encoder
|
||||
{
|
||||
let mut lk_frame = frame_clone.lock().expect("Couldn't lock frame");
|
||||
*lk_frame = Some(ffmpeg_the_third::frame::Video::new(
|
||||
ffmpeg_the_third::format::Pixel::BGRA,
|
||||
*lk_frame = Some(ffmpeg::frame::Video::new(
|
||||
ffmpeg::format::Pixel::BGRA,
|
||||
size.clone().width,
|
||||
size.clone().height,
|
||||
));
|
||||
|
|
|
@ -19,11 +19,11 @@ pub enum EncodeThreadOutput {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn set_frame_flags(frame: &mut ffmpeg_the_third::Frame, force_keyframe: bool) {
|
||||
fn set_frame_flags(frame: &mut ffmpeg::Frame, force_keyframe: bool) {
|
||||
unsafe {
|
||||
if force_keyframe {
|
||||
(*frame.as_mut_ptr()).pict_type = ffmpeg::sys::AVPictureType::AV_PICTURE_TYPE_I;
|
||||
(*frame.as_mut_ptr()).flags = ffmpeg_the_third::sys::AV_FRAME_FLAG_KEY;
|
||||
(*frame.as_mut_ptr()).flags = ffmpeg::sys::AV_FRAME_FLAG_KEY;
|
||||
(*frame.as_mut_ptr()).key_frame = 1;
|
||||
} else {
|
||||
(*frame.as_mut_ptr()).pict_type = ffmpeg::sys::AVPictureType::AV_PICTURE_TYPE_NONE;
|
||||
|
@ -40,7 +40,6 @@ fn encoder_thread_main(
|
|||
) {
|
||||
let mut packet = ffmpeg::Packet::empty();
|
||||
|
||||
|
||||
let mut encoder: Option<H264Encoder> = None;
|
||||
let mut sws = None;
|
||||
|
||||
|
@ -59,17 +58,17 @@ fn encoder_thread_main(
|
|||
force_keyframe = false;
|
||||
}
|
||||
|
||||
yuv_frame = Some(ffmpeg_the_third::frame::Video::new(
|
||||
ffmpeg_the_third::format::Pixel::YUV420P,
|
||||
yuv_frame = Some(ffmpeg::frame::Video::new(
|
||||
ffmpeg::format::Pixel::YUV420P,
|
||||
size.clone().width,
|
||||
size.clone().height,
|
||||
));
|
||||
|
||||
sws = Some(
|
||||
ffmpeg_the_third::software::converter(
|
||||
ffmpeg::software::converter(
|
||||
size.clone().into(),
|
||||
ffmpeg_the_third::format::Pixel::BGRA,
|
||||
ffmpeg_the_third::format::Pixel::YUV420P,
|
||||
ffmpeg::format::Pixel::BGRA,
|
||||
ffmpeg::format::Pixel::YUV420P,
|
||||
)
|
||||
.expect("Failed to create SWS conversion context"),
|
||||
);
|
||||
|
@ -156,7 +155,7 @@ fn encoder_thread_main(
|
|||
}
|
||||
|
||||
pub fn encoder_thread_spawn(
|
||||
frame: &Arc<Mutex<Option<ffmpeg_the_third::frame::Video>>>,
|
||||
frame: &Arc<Mutex<Option<ffmpeg::frame::Video>>>,
|
||||
) -> (
|
||||
mpsc::Receiver<EncodeThreadOutput>,
|
||||
mpsc::Sender<EncodeThreadInput>,
|
||||
|
|
|
@ -3,6 +3,7 @@ pub mod h264_encoder;
|
|||
//pub mod lc_muxer;
|
||||
|
||||
/// Re-export of `ffmpeg_the_third` crate in an infinitely less obtuse name.
|
||||
pub use ffmpeg_the_third as ffmpeg;
|
||||
pub use ffmpeg as ffmpeg;
|
||||
|
||||
|
||||
pub use encoder_thread::*;
|
||||
|
|
Loading…
Reference in a new issue