Skip to content

Conversation

@defanator
Copy link
Member

Proposed changes

Recent ffmpeg versions (e.g. 7.1.2 on Fedora) do not have libx264 encoder available, but h264 does the same thing. This PR proposes dynamic selection of an encoder based on what's available in the environment.

Checklist

Before creating a PR, run through this checklist and mark each as complete:

@pluknet
Copy link
Contributor

pluknet commented Dec 24, 2025

@defanator
It's not about ffmpeg version but how H264 support was compiled.
In particular, alpine and/or other distributions we have in pipelines are known to have ffmpeg 7.1.2 or above, and do not experience these mp4 tests failure due to that, ref: https://repology.org/project/ffmpeg/versions

Specifically, ffmpeg has different options to include H264 support:

  • libx264, included with --enable-libx264
  • libopenh264, included with --enable-libopenh264

The latter seems started to be used instead at least in Fedora as seen in ffmpeg -version:

ffmpeg version 7.1.2 Copyright (c) 2000-2025 the FFmpeg developers
...
configuration: ... --enable-libopenh264

Same can be gained with FreeBSD ports:

# make showconfig | grep 264
     OPENH264=on: H.264 video codec support via OpenH264
     X264=off: H.264 video codec support via x264
# ffmpeg -version
ffmpeg version 8.0.1 Copyright (c) 2000-2025 the FFmpeg developers
...
configuration: ... --enable-libopenh264 ... --disable-libx264

The difference is that libopenh264 permits only -c h264, while libx264 supports both clauses -c h264 and -c libx264.

The tests are not sensitive enough to detect the difference, and since both codecs support acting as "h264",
it makes sense to change this to h264 unconditionally, or at least check libx264 support by a different command ffmpeg -loglevel quiet -encoders:

$ ffmpeg -loglevel quiet -encoders | grep libx264
 V..... libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
 V..... libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)

This won't match if it's built with openh264, such as ffmpeg on FreeBSD configured above:

$ ffmpeg -loglevel quiet -encoders | grep 264
 V....D libopenh264          OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)

@pluknet
Copy link
Contributor

pluknet commented Dec 24, 2025

I prefer this version instead, if you don't mind.

defanator and others added 2 commits December 24, 2025 20:23
Tests: adjusted mp4 tests to use h264 encoder.

ffmpeg can be built with the "libopenh264" codec to replace commonly
used "libx264", both listed in ffmpeg-codecs(1), as seen on recent
Fedora Linux.  Both codecs respond to "ffmpeg -codec h264", so use it
now instead of "libx264".
@pluknet pluknet force-pushed the use_dynamic_encoder_selection_in_mp4_tests branch from 5d9344e to 7566239 Compare December 24, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants