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

Meson wrap for FFmpeg #335

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Meson wrap for FFmpeg #335

wants to merge 7 commits into from

Conversation

res2k
Copy link
Contributor

@res2k res2k commented Nov 13, 2023

Adds a Meson wrap for FFmpeg (utilizing gstreamer's meson port), allowing it to be automatically built, if not available on the system.
Tested Windows/MSVC and Linux/GCC, both 64 bit, those seem to work fine.

@skullernet
Copy link
Owner

Is it correct that this builds FFmpeg with all demuxers and decoders? How big is resulting Q2PRO binary when statically linking to this?

For static linking, FFmpeg needs to be built in smallest possible configuration to facilitate Ogg Theora videos and Vorbis music playback (in addition to original "idcin" cinematic format of course). For example, these are upstream FFmpeg configure script options I currently use for nightly builds:

./configure \
    --disable-everything \
    --enable-decoder=theora \
    --enable-decoder=vorbis \
    --enable-decoder=idcin \
    --enable-decoder=pcm_* \
    --disable-decoder=pcm_bluray \
    --disable-decoder=pcm_dvd \
    --disable-decoder=pcm_alaw_at \
    --disable-decoder=pcm_mulaw_at \
    --enable-demuxer=ogg \
    --enable-demuxer=idcin \
    --enable-demuxer=wav \
    --enable-parser=vp3 \
    --enable-parser=vorbis \
    --disable-protocols \
    --enable-protocol=file \
    --disable-avdevice \
    --disable-avfilter \
    --disable-postproc \
    --disable-programs \
    --disable-autodetect \
    --disable-network \
    --disable-doc \
    --disable-swscale-alpha \
    --enable-small

For 64-bit Windows build, resulting overhead is about 1 MiB. If Meson port of FFmpeg is to be used similar set of options needs to be enabled, so that binary size overhead is comparable.

@res2k
Copy link
Contributor Author

res2k commented Nov 15, 2023

Is it correct that this builds FFmpeg with all demuxers and decoders?

Yes.

How big is resulting Q2PRO binary when statically linking to this?

20MB on MSVC x64. So, quite large.

The Meson wrap allows to disable various features... but there are a lot of options, see: https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg/-/blob/meson-6.0/meson_options.txt?ref_type=heads

If your options above can be translated into about the same amount of Meson wrap options, I think it would be fine; but if we have to disable (almost) every muxer, demuxer, decoder, parser, ..., this would really be a PITA. (And also an enormous amount of default_options.)

@res2k
Copy link
Contributor Author

res2k commented Nov 15, 2023

With tweaked defaults I got the overhead down to 2MB.

Most of the options above I could translate to Meson, except:
--disable-swscale-alpha - not offered by FFmpeg's meson.build
--enable-small - not supported by Meson (optimization can't be set per subproject) OK, this is not what this option means. However, it's not offered by FFmpeg's meson.build, either.

Unfortunately, at the current time, these efforts are moot, as there's a link error occuring due to an issue in upstream I discovered (https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg/-/issues/40).

@res2k
Copy link
Contributor Author

res2k commented Dec 2, 2023

Unfortunately, at the current time, these efforts are moot, as there's a link error occuring due to an issue in upstream I discovered (https://gitlab.freedesktop.org/gstreamer/meson-ports/ffmpeg/-/issues/40).

This has been addressed upstream now.

I tried to hack the equivalent of --disable-swscale-alpha and --enable-small into the Meson build, but I didn't measure much difference in code size... I think as it is now, the added size is "ok enough".

@rorgoroth
Copy link

Is it possible to force the use of this meson wrap and ignore the system ffmpeg libraries?

I cannot slim down my ffmpeg in cross compiler environment because it's used for a useful ffmpeg.exe and libraries for media players. The end result is that my q2pro.exe is 52MB heavier than If I pass -Davcodec=disabled.

@res2k
Copy link
Contributor Author

res2k commented Mar 15, 2024

Is it possible to force the use of this meson wrap and ignore the system ffmpeg libraries?

Should be doable using meson's --force-fallback-for argument.

@rorgoroth
Copy link

Should be doable using meson's --force-fallback-for argument.

Got it, --force-fallback-for=ffmpeg is a big improvement. Thanks.

@res2k res2k mentioned this pull request Nov 3, 2024
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.

3 participants