Bump ffmpeg to 6.0

This commit is contained in:
Polochon-street 2023-03-16 19:35:12 +01:00
parent 97f563dd6e
commit 0fc9f8d966
6 changed files with 42 additions and 19 deletions

View File

@ -1,5 +1,8 @@
#Changelog #Changelog
## bliss 0.6.7
* Fix compatibility for ffmpeg 6.0, and bump ffmpeg version to 6.0
## bliss 0.6.6 ## bliss 0.6.6
* Add a `delete_everything_else` function in `library`'s update functions. * Add a `delete_everything_else` function in `library`'s update functions.
* Use Rust 2021 * Use Rust 2021

16
Cargo.lock generated
View File

@ -71,9 +71,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "bindgen" name = "bindgen"
version = "0.59.2" version = "0.64.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"cexpr", "cexpr",
@ -86,6 +86,7 @@ dependencies = [
"regex 1.7.1", "regex 1.7.1",
"rustc-hash", "rustc-hash",
"shlex", "shlex",
"syn",
] ]
[[package]] [[package]]
@ -96,7 +97,7 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bliss-audio" name = "bliss-audio"
version = "0.6.6" version = "0.6.7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bliss-audio-aubio-rs", "bliss-audio-aubio-rs",
@ -105,6 +106,7 @@ dependencies = [
"dirs", "dirs",
"env_logger", "env_logger",
"ffmpeg-next", "ffmpeg-next",
"ffmpeg-sys-next",
"glob", "glob",
"indicatif", "indicatif",
"lazy_static 1.4.0", "lazy_static 1.4.0",
@ -456,9 +458,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]] [[package]]
name = "ffmpeg-next" name = "ffmpeg-next"
version = "5.1.1" version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a80971eee67be0079a1c8890bde68226fe9bd0441740fd6ddd0cee131486b321" checksum = "8af03c47ad26832ab3aabc4cdbf210af3d3b878783edd5a7ba044ba33aab7a60"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"ffmpeg-sys-next", "ffmpeg-sys-next",
@ -467,9 +469,9 @@ dependencies = [
[[package]] [[package]]
name = "ffmpeg-sys-next" name = "ffmpeg-sys-next"
version = "5.1.1" version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d780b36e092254367e2f1f21191992735c8e23f31a5a5a8678db3a79f775021f" checksum = "cf650f461ccf130f4eef4927affed703cc387b183bfc4a7dfee86a076c131127"
dependencies = [ dependencies = [
"bindgen", "bindgen",
"cc", "cc",

View File

@ -1,6 +1,7 @@
[package] [package]
name = "bliss-audio" name = "bliss-audio"
version = "0.6.6" version = "0.6.7"
build = "build.rs"
authors = ["Polochon-street <polochonstreet@gmx.fr>"] authors = ["Polochon-street <polochonstreet@gmx.fr>"]
edition = "2021" edition = "2021"
license = "GPL-3.0-only" license = "GPL-3.0-only"
@ -41,7 +42,8 @@ lazy_static = "1.4.0"
rayon = "1.5.0" rayon = "1.5.0"
crossbeam = "0.8.0" crossbeam = "0.8.0"
noisy_float = "0.2.0" noisy_float = "0.2.0"
ffmpeg-next = "5.1.1" ffmpeg-next = "6.0.0"
ffmpeg-sys-next = { version = "6.0.1", default-features = false }
log = "0.4.14" log = "0.4.14"
env_logger = "0.8.3" env_logger = "0.8.3"
thiserror = "1.0.24" thiserror = "1.0.24"

12
build.rs Normal file
View File

@ -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()
);
}
}
}

View File

@ -1051,7 +1051,6 @@ impl<Config: AppConfigTrait> Library<Config> {
internal_analysis: stmt internal_analysis: stmt
.query_map(params![song_path], |row| row.get(0)) .query_map(params![song_path], |row| row.get(0))
.unwrap() .unwrap()
.into_iter()
.map(|x| x.unwrap()) .map(|x| x.unwrap())
.collect::<Vec<f32>>() .collect::<Vec<f32>>()
.try_into() .try_into()

View File

@ -459,6 +459,7 @@ impl Song {
context.set_threading(Config { context.set_threading(Config {
kind: ThreadingType::Frame, kind: ThreadingType::Frame,
count: 0, count: 0,
#[cfg(not(feature = "ffmpeg_6_0"))]
safe: true, safe: true,
}); });
let decoder = context.decoder().audio().map_err(|e| { let decoder = context.decoder().audio().map_err(|e| {
@ -519,11 +520,11 @@ impl Song {
t => Some(t.to_string()), t => Some(t.to_string()),
}; };
}; };
let in_channel_layout = { let (empty_in_channel_layout, in_channel_layout) = {
if decoder.channel_layout() == ChannelLayout::empty() { if decoder.channel_layout() == ChannelLayout::empty() {
ChannelLayout::default(decoder.channels().into()) (true, ChannelLayout::default(decoder.channels().into()))
} else { } else {
decoder.channel_layout() (false, decoder.channel_layout())
} }
}; };
decoder.set_channel_layout(in_channel_layout); decoder.set_channel_layout(in_channel_layout);
@ -538,6 +539,7 @@ impl Song {
in_channel_layout, in_channel_layout,
in_codec_rate, in_codec_rate,
sample_array, sample_array,
empty_in_channel_layout,
) )
}); });
for (s, packet) in ictx.packets() { for (s, packet) in ictx.packets() {
@ -646,6 +648,7 @@ fn resample_frame(
in_channel_layout: ChannelLayout, in_channel_layout: ChannelLayout,
in_rate: u32, in_rate: u32,
mut sample_array: Vec<f32>, mut sample_array: Vec<f32>,
empty_in_channel_layout: bool,
) -> BlissResult<Vec<f32>> { ) -> BlissResult<Vec<f32>> {
let mut resample_context = ffmpeg::software::resampling::context::Context::get( let mut resample_context = ffmpeg::software::resampling::context::Context::get(
in_codec_format, in_codec_format,
@ -660,15 +663,17 @@ fn resample_frame(
"while trying to allocate resampling context: {e:?}", "while trying to allocate resampling context: {e:?}",
)) ))
})?; })?;
let mut resampled = ffmpeg::frame::Audio::empty(); let mut resampled = ffmpeg::frame::Audio::empty();
let mut something_happened = false; let mut something_happened = false;
for decoded in rx.iter() { for mut decoded in rx.iter() {
if in_codec_format != decoded.format() // If the decoded layout is empty, it means we forced the
// "in_channel_layout" to something default, not that
// the format is wrong.
if empty_in_channel_layout && decoded.channel_layout() == ChannelLayout::empty() {
decoded.set_channel_layout(in_channel_layout);
} else if in_codec_format != decoded.format()
|| (in_channel_layout != decoded.channel_layout()) || (in_channel_layout != decoded.channel_layout())
// If the decoded layout is empty, it means we forced the
// "in_channel_layout" to something default, not that
// the format is wrong.
&& (decoded.channel_layout() != ChannelLayout::empty())
|| in_rate != decoded.rate() || in_rate != decoded.rate()
{ {
warn!("received decoded packet with wrong format; file might be corrupted."); warn!("received decoded packet with wrong format; file might be corrupted.");