Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for FFmpeg < 4.2 #72

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
ffmpeg_version:
["3.4", "4.0", "4.1", "4.2", "4.3", "4.4", "5.0", "5.1", "6.0", "6.1", "7.0"]
["4.2", "4.3", "4.4", "5.0", "5.1", "6.0", "6.1", "7.0"]
fail-fast: false

steps:
Expand Down
23 changes: 10 additions & 13 deletions ffmpeg-sys-the-third/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ This is a fork of the abandoned [ffmpeg-sys](https://github.com/meh/rust-ffmpeg-

This crate contains low level bindings to FFmpeg. You're probably interested in the high level bindings instead: [ffmpeg-next](https://github.com/shssoichiro/ffmpeg-the-third).

A word on versioning: major and minor versions track major and minor versions of FFmpeg, e.g. 4.2.x of this crate has been updated to support the 4.2.x series of FFmpeg. Patch level is reserved for bug fixes of this crate and does not track FFmpeg patch versions.
A word on versioning: The crate version includes the **maximum supported** FFmpeg version for each release. E.g. `[email protected]+ffmpeg-7.0` supports *up to* FFmpeg 7.0. The minimum supported FFmpeg version at the moment is 4.2.

## Feature flags

In addition to feature flags declared in `Cargo.toml`, this crate performs various compile-time version and feature detections and exposes the results in additional flags. These flags are briefly documented below; run `cargo build -vv` to view more details.

- `ffmpeg_<x>_<y>` flags (new in v4.3.2), e.g. `ffmpeg_4_4`, indicating the FFmpeg installation being compiled against is at least version `<x>.<y>`. Currently available:
- `ffmpeg_<x>_<y>` flags, e.g. `ffmpeg_4_4`, indicating the FFmpeg installation being compiled against is at least version `<x>.<y>`. Currently available:

- `ffmpeg_3_0`
- `ffmpeg_3_1`
- `ffmpeg_3_2`
- `ffmpeg_3_3`
- `ffmpeg_3_1`
- `ffmpeg_4_0`
- `ffmpeg_4_1`
- `ffmpeg_4_2`
- `ffmpeg_4_3`
- `ffmpeg_4_4`
- "ffmpeg_4_3"
- "ffmpeg_4_4"
- "ffmpeg_5_0"
- "ffmpeg_5_1"
- "ffmpeg_6_0"
- "ffmpeg_6_1"
- "ffmpeg_7_0"

- `avcodec_version_greater_than_<x>_<y>` (new in v4.3.2), e.g., `avcodec_version_greater_than_58_90`. The name should be self-explanatory.
- `avcodec_version_greater_than_<x>_<y>`, e.g., `avcodec_version_greater_than_58_90`. The name should be self-explanatory.

- `ff_api_<feature>`, e.g. `ff_api_vaapi`, corresponding to whether their respective uppercase deprecation guards evaluate to true.

Expand Down
13 changes: 4 additions & 9 deletions ffmpeg-sys-the-third/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ fn check_features(include_paths: &[PathBuf]) {
}
}

let version_check_info = [("avcodec", 56, 62, 0, 108)];
let version_check_info = [("avcodec", 57, 62, 0, 101)];
for &(lib, begin_version_major, end_version_major, begin_version_minor, end_version_minor) in
&version_check_info
{
Expand All @@ -830,14 +830,6 @@ fn check_features(include_paths: &[PathBuf]) {
}

let ffmpeg_lavc_versions = [
("ffmpeg_3_0", 57, 24),
("ffmpeg_3_1", 57, 48),
("ffmpeg_3_2", 57, 64),
("ffmpeg_3_3", 57, 89),
("ffmpeg_3_1", 57, 107),
("ffmpeg_4_0", 58, 18),
("ffmpeg_4_1", 58, 35),
("ffmpeg_4_2", 58, 54),
("ffmpeg_4_3", 58, 91),
("ffmpeg_4_4", 58, 100),
("ffmpeg_5_0", 59, 18),
Expand All @@ -851,6 +843,9 @@ fn check_features(include_paths: &[PathBuf]) {
.get("avcodec")
.expect("Unable to find the version for lib{lib}");

// This allows removing a lot of #[cfg] attributes.
assert!(lavc_version >= (58, 54), "FFmpeg 4.2 or higher is required, but found avcodec version {lavc_version:?}");

for &(ffmpeg_version_flag, lavc_version_major, lavc_version_minor) in &ffmpeg_lavc_versions {
// Every possible feature needs an unconditional check-cfg to prevent warnings
println!(
Expand Down
2 changes: 0 additions & 2 deletions src/codec/capabilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ bitflags! {
const TRUNCATED = AV_CODEC_CAP_TRUNCATED;
const DELAY = AV_CODEC_CAP_DELAY;
const SMALL_LAST_FRAME = AV_CODEC_CAP_SMALL_LAST_FRAME;
#[cfg(not(feature = "ffmpeg_4_0"))]
const HWACCEL_VDPAU = AV_CODEC_CAP_HWACCEL_VDPAU;
const SUBFRAMES = AV_CODEC_CAP_SUBFRAMES;
const EXPERIMENTAL = AV_CODEC_CAP_EXPERIMENTAL;
const CHANNEL_CONF = AV_CODEC_CAP_CHANNEL_CONF;
Expand Down
8 changes: 0 additions & 8 deletions src/codec/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,12 @@ bitflags! {
const BITSTREAM = FF_DEBUG_BITSTREAM;
const MB_TYPE = FF_DEBUG_MB_TYPE;
const QP = FF_DEBUG_QP;
#[cfg(not(feature = "ffmpeg_4_0"))]
const MV = FF_DEBUG_MV;
const DCT_COEFF = FF_DEBUG_DCT_COEFF;
const SKIP = FF_DEBUG_SKIP;
const STARTCODE = FF_DEBUG_STARTCODE;
#[cfg(not(feature = "ffmpeg_4_0"))]
const PTS = FF_DEBUG_PTS;
const ER = FF_DEBUG_ER;
const MMCO = FF_DEBUG_MMCO;
const BUGS = FF_DEBUG_BUGS;
#[cfg(not(feature = "ffmpeg_4_0"))]
const VIS_QP = FF_DEBUG_VIS_QP;
#[cfg(not(feature = "ffmpeg_4_0"))]
const VIS_MB_TYPE = FF_DEBUG_VIS_MB_TYPE;
const BUFFERS = FF_DEBUG_BUFFERS;
const THREADS = FF_DEBUG_THREADS;
const NOMC = FF_DEBUG_NOMC;
Expand Down
63 changes: 0 additions & 63 deletions src/codec/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ pub enum Id {
ON2AVC,
DSS_SP,

#[cfg(feature = "ffmpeg_4_0")]
CODEC2,
FFWAVESYNTH,
SONIC,
Expand Down Expand Up @@ -487,47 +486,27 @@ pub enum Id {
GREMLIN_DPCM,
DOLBY_E,

#[cfg(feature = "ffmpeg_4_0")]
APTX,
#[cfg(feature = "ffmpeg_4_0")]
APTX_HD,
#[cfg(feature = "ffmpeg_4_0")]
SBC,

#[cfg(feature = "ffmpeg_4_1")]
AVS2,
#[cfg(feature = "ffmpeg_4_1")]
IMM4,
#[cfg(feature = "ffmpeg_4_1")]
PROSUMER,
#[cfg(feature = "ffmpeg_4_1")]
MWSC,
#[cfg(feature = "ffmpeg_4_1")]
WCMV,
#[cfg(feature = "ffmpeg_4_1")]
RASC,
#[cfg(feature = "ffmpeg_4_1")]
PCM_VIDC,
#[cfg(feature = "ffmpeg_4_1")]
ATRAC9,
#[cfg(feature = "ffmpeg_4_1")]
TTML,

#[cfg(feature = "ffmpeg_4_2")]
HYMT,
#[cfg(feature = "ffmpeg_4_2")]
ARBC,
#[cfg(feature = "ffmpeg_4_2")]
AGM,
#[cfg(feature = "ffmpeg_4_2")]
LSCR,
#[cfg(feature = "ffmpeg_4_2")]
VP4,
#[cfg(feature = "ffmpeg_4_2")]
ADPCM_AGM,
#[cfg(feature = "ffmpeg_4_2")]
HCOM,
#[cfg(feature = "ffmpeg_4_2")]
ARIB_CAPTION,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down Expand Up @@ -1073,7 +1052,6 @@ impl From<AVCodecID> for Id {
AV_CODEC_ID_ON2AVC => Id::ON2AVC,
AV_CODEC_ID_DSS_SP => Id::DSS_SP,

#[cfg(feature = "ffmpeg_4_0")]
AV_CODEC_ID_CODEC2 => Id::CODEC2,
AV_CODEC_ID_FFWAVESYNTH => Id::FFWAVESYNTH,
AV_CODEC_ID_SONIC => Id::SONIC,
Expand Down Expand Up @@ -1158,47 +1136,27 @@ impl From<AVCodecID> for Id {
AV_CODEC_ID_GREMLIN_DPCM => Id::GREMLIN_DPCM,
AV_CODEC_ID_DOLBY_E => Id::DOLBY_E,

#[cfg(feature = "ffmpeg_4_0")]
AV_CODEC_ID_APTX => Id::APTX,
#[cfg(feature = "ffmpeg_4_0")]
AV_CODEC_ID_APTX_HD => Id::APTX_HD,
#[cfg(feature = "ffmpeg_4_0")]
AV_CODEC_ID_SBC => Id::SBC,

#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_AVS2 => Id::AVS2,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_IMM4 => Id::IMM4,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_PROSUMER => Id::PROSUMER,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_MWSC => Id::MWSC,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_WCMV => Id::WCMV,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_RASC => Id::RASC,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_PCM_VIDC => Id::PCM_VIDC,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_ATRAC9 => Id::ATRAC9,
#[cfg(feature = "ffmpeg_4_1")]
AV_CODEC_ID_TTML => Id::TTML,

#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_HYMT => Id::HYMT,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_ARBC => Id::ARBC,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_AGM => Id::AGM,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_LSCR => Id::LSCR,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_VP4 => Id::VP4,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_ADPCM_AGM => Id::ADPCM_AGM,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_HCOM => Id::HCOM,
#[cfg(feature = "ffmpeg_4_2")]
AV_CODEC_ID_ARIB_CAPTION => Id::ARIB_CAPTION,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down Expand Up @@ -1738,7 +1696,6 @@ impl From<Id> for AVCodecID {
Id::ON2AVC => AV_CODEC_ID_ON2AVC,
Id::DSS_SP => AV_CODEC_ID_DSS_SP,

#[cfg(feature = "ffmpeg_4_0")]
Id::CODEC2 => AV_CODEC_ID_CODEC2,
Id::FFWAVESYNTH => AV_CODEC_ID_FFWAVESYNTH,
Id::SONIC => AV_CODEC_ID_SONIC,
Expand Down Expand Up @@ -1824,47 +1781,27 @@ impl From<Id> for AVCodecID {
Id::GREMLIN_DPCM => AV_CODEC_ID_GREMLIN_DPCM,
Id::DOLBY_E => AV_CODEC_ID_DOLBY_E,

#[cfg(feature = "ffmpeg_4_0")]
Id::APTX => AV_CODEC_ID_APTX,
#[cfg(feature = "ffmpeg_4_0")]
Id::APTX_HD => AV_CODEC_ID_APTX_HD,
#[cfg(feature = "ffmpeg_4_0")]
Id::SBC => AV_CODEC_ID_SBC,

#[cfg(feature = "ffmpeg_4_1")]
Id::AVS2 => AV_CODEC_ID_AVS2,
#[cfg(feature = "ffmpeg_4_1")]
Id::IMM4 => AV_CODEC_ID_IMM4,
#[cfg(feature = "ffmpeg_4_1")]
Id::PROSUMER => AV_CODEC_ID_PROSUMER,
#[cfg(feature = "ffmpeg_4_1")]
Id::MWSC => AV_CODEC_ID_MWSC,
#[cfg(feature = "ffmpeg_4_1")]
Id::WCMV => AV_CODEC_ID_WCMV,
#[cfg(feature = "ffmpeg_4_1")]
Id::RASC => AV_CODEC_ID_RASC,
#[cfg(feature = "ffmpeg_4_1")]
Id::PCM_VIDC => AV_CODEC_ID_PCM_VIDC,
#[cfg(feature = "ffmpeg_4_1")]
Id::ATRAC9 => AV_CODEC_ID_ATRAC9,
#[cfg(feature = "ffmpeg_4_1")]
Id::TTML => AV_CODEC_ID_TTML,

#[cfg(feature = "ffmpeg_4_2")]
Id::HYMT => AV_CODEC_ID_HYMT,
#[cfg(feature = "ffmpeg_4_2")]
Id::ARBC => AV_CODEC_ID_ARBC,
#[cfg(feature = "ffmpeg_4_2")]
Id::AGM => AV_CODEC_ID_AGM,
#[cfg(feature = "ffmpeg_4_2")]
Id::LSCR => AV_CODEC_ID_LSCR,
#[cfg(feature = "ffmpeg_4_2")]
Id::VP4 => AV_CODEC_ID_VP4,
#[cfg(feature = "ffmpeg_4_2")]
Id::ADPCM_AGM => AV_CODEC_ID_ADPCM_AGM,
#[cfg(feature = "ffmpeg_4_2")]
Id::HCOM => AV_CODEC_ID_HCOM,
#[cfg(feature = "ffmpeg_4_2")]
Id::ARIB_CAPTION => AV_CODEC_ID_ARIB_CAPTION,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down
5 changes: 0 additions & 5 deletions src/codec/packet/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,10 @@ impl Clone for Packet {

#[inline]
fn clone_from(&mut self, source: &Self) {
#[cfg(feature = "ffmpeg_4_0")]
unsafe {
av_packet_ref(&mut self.0, &source.0);
av_packet_make_writable(&mut self.0);
}
#[cfg(not(feature = "ffmpeg_4_0"))]
unsafe {
av_copy_packet(&mut self.0, &source.0);
}
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/codec/packet/side_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ pub enum Type {
ContentLightLevel,
A53CC,

#[cfg(feature = "ffmpeg_4_0")]
EncryptionInitInfo,
#[cfg(feature = "ffmpeg_4_0")]
EncryptionInfo,

#[cfg(feature = "ffmpeg_4_1")]
AFD,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down Expand Up @@ -98,12 +95,9 @@ impl From<AVPacketSideDataType> for Type {
AV_PKT_DATA_CONTENT_LIGHT_LEVEL => Type::ContentLightLevel,
AV_PKT_DATA_A53_CC => Type::A53CC,

#[cfg(feature = "ffmpeg_4_0")]
AV_PKT_DATA_ENCRYPTION_INIT_INFO => Type::EncryptionInitInfo,
#[cfg(feature = "ffmpeg_4_0")]
AV_PKT_DATA_ENCRYPTION_INFO => Type::EncryptionInfo,

#[cfg(feature = "ffmpeg_4_1")]
AV_PKT_DATA_AFD => Type::AFD,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down Expand Up @@ -164,12 +158,9 @@ impl From<Type> for AVPacketSideDataType {
Type::ContentLightLevel => AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
Type::A53CC => AV_PKT_DATA_A53_CC,

#[cfg(feature = "ffmpeg_4_0")]
Type::EncryptionInitInfo => AV_PKT_DATA_ENCRYPTION_INIT_INFO,
#[cfg(feature = "ffmpeg_4_0")]
Type::EncryptionInfo => AV_PKT_DATA_ENCRYPTION_INFO,

#[cfg(feature = "ffmpeg_4_1")]
Type::AFD => AV_PKT_DATA_AFD,

#[cfg(feature = "ffmpeg_4_3")]
Expand Down
2 changes: 0 additions & 2 deletions src/format/format/flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ bitflags! {
const NO_FILE = AVFMT_NOFILE;
const NEED_NUMBER = AVFMT_NEEDNUMBER;
const SHOW_IDS = AVFMT_SHOW_IDS;
#[cfg(not(feature = "ffmpeg_4_0"))]
const RAW_PICTURE = AVFMT_RAWPICTURE;
const GLOBAL_HEADER = AVFMT_GLOBALHEADER;
const NO_TIMESTAMPS = AVFMT_NOTIMESTAMPS;
const GENERIC_INDEX = AVFMT_GENERIC_INDEX;
Expand Down
4 changes: 0 additions & 4 deletions src/format/format/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@ pub use self::input::Input;
mod output;
pub use self::output::Output;

#[cfg(feature = "ffmpeg_4_0")]
mod iter;
#[cfg(feature = "ffmpeg_4_0")]
pub use self::iter::{DemuxerIter, MuxerIter};

#[cfg(feature = "ffmpeg_4_0")]
pub fn list_demuxers() -> DemuxerIter {
DemuxerIter::new()
}

#[cfg(feature = "ffmpeg_4_0")]
pub fn list_muxers() -> MuxerIter {
MuxerIter::new()
}
Loading
Loading