How can I build libmpv.so, which includes ffmpeg?
Hi everybody. Thanks for the useful build-scripts!
I'm trying to build libmpv.so, which includes ffmpeg. Yes, I want one giant libmpv.so library.
Reason: I want to distribute my electron application to different os/arch without external dependencies.
Currently, I have to use the FFmpeg from system because libffmpeg.so from electron has the wrong version, and libmpv.so doesn't work with it. So I need additional actions e.g - gcc -Wl,--no-as-needed -shared -lavformat -o /path/to/libffmpeg.so. I want to avoid it.
I created the following Dockerfile and added --enable-static-build option. But it didn't have the desired effect. Maybe I don’t understand what I’m doing.
How can I build libmpv.so which includes ffmpeg?
FROM ubuntu as builder
RUN apt update -y && \
apt install -y \
python \
python3\
pkg-config \
libtool\
libfreetype6-dev\
autoconf \
fontconfig \
devscripts\
equivs \
libfdk-aac-dev\
automake \
build-essential\
cmake \
git-core \
libtool\
checkinstall \
nasm \
yasm \
libass-dev \
libsdl2-dev \
p11-kit\
libva-dev \
libvdpau-dev \
libxcb1-dev \
libxcb-shm0-dev\
libxcb-xfixes0-dev \
texinfo \
wget \
zlib1g-dev \
libchromaprint-dev\
frei0r-plugins-dev \
gnutls-dev \
ladspa-sdk \
libcaca-dev \
libcdio-paranoia-dev\
libcodec2-dev \
libfontconfig1-dev \
libfribidi-dev \
libgme-dev\
libgsm1-dev \
libmodplug-dev \
libmp3lame-dev \
libopencore-amrnb-dev\
libopencore-amrwb-dev \
libopenjp2-7-dev \
libopenmpt-dev \
libopus-dev\
libpulse-dev \
librsvg2-dev \
librubberband-dev \
librtmp-dev \
libshine-dev\
libsmbclient-dev \
libsnappy-dev \
libsoxr-dev \
libspeex-dev \
libssh-dev\
libtesseract-dev \
libtheora-dev \
libtwolame-dev \
libv4l-dev \
libvo-amrwbenc-dev\
libvorbis-dev \
libvpx-dev \
libwavpack-dev \
libwebp-dev \
libx264-dev \
libx265-dev\
libxvidcore-dev \
libxml2-dev \
libzmq3-dev \
libzvbi-dev \
liblilv-dev\
libopenal-dev \
opencl-dev \
libjack-dev
RUN git clone https://github.com/mpv-player/mpv-build.git
WORKDIR mpv-build
RUN echo --enable-nonfree >> ffmpeg_options
RUN echo --enable-gpl >> ffmpeg_options
RUN echo --enable-version3 >> ffmpeg_options
RUN echo --enable-vdpau >> ffmpeg_options
RUN echo --enable-libass >> ffmpeg_options
RUN echo --enable-libfdk-aac >> ffmpeg_options
RUN echo --enable-libfreetype >> ffmpeg_options
RUN echo --enable-libmp3lame >> ffmpeg_options
RUN echo --enable-libopus >> ffmpeg_options
RUN echo --enable-libtheora >> ffmpeg_options
RUN echo --enable-libvorbis >> ffmpeg_options
RUN echo --enable-libvpx >> ffmpeg_options
RUN echo --enable-libpulse >> ffmpeg_options
RUN echo --enable-libv4l2 >> ffmpeg_options
RUN echo --enable-libx264 >> ffmpeg_options
RUN echo --enable-libx265 >> ffmpeg_options
RUN echo --enable-static-build >> mpv_options
RUN echo --enable-libmpv-shared >> mpv_options
RUN ./use-ffmpeg-release
RUN ./rebuild -j4
FROM alpine as final
COPY --from=builder /mpv-build /prebuilt
CMD [ "/bin/sh" ]
I use mpv-build too.
echo --enable-libmpv-shared >> mpv_options
ldd libmpv.so
can see that not used external links to any libav*.so from ffmpeg
but if run ./mpv
built on Fri Aug 6 01:07:45 EEST 2021
FFmpeg library versions:
libavutil 57.3.100
libavcodec 59.4.100
libavformat 59.4.101
libswscale 6.0.100
libavfilter 8.1.103
libswresample 4.0.100
FFmpeg version: N-103152-gef54590f83
Usage: mpv [options] [url|path/]filename
Old but if you just enable libmpv (e.g. printf "%s\n" -Dlibmpv=true > mpv_options), ffmpeg will be linked to it statically.