How to build ffmpeg/x264/x265/fdkaac into one single ffmpeg file?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
qw
Reply | Threaded
Open this post in threaded view
|

How to build ffmpeg/x264/x265/fdkaac into one single ffmpeg file?

qw
Hi,

I have one question about building ffmpeg.

How to build ffmpeg/x264/x265/fdkaac and other external libraries into one single ffmpeg file in linux?

Thanks!

regards

andrew
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to build ffmpeg/x264/x265/fdkaac into one single ffmpeg file?

Reindl Harald


Am 02.07.2018 um 20:08 schrieb qw:
> How to build ffmpeg/x264/x265/fdkaac and other external libraries into one single ffmpeg file in linux?

that's with static x264

look at --extra-ldflags in the scond part which links the previously
built "libx264.a"

[builduser@testserver:/rpmbuild/SPECS]$ cat
/rpmbuild/SPECS/ffmpeg-latest.spec
#############################################################################################################################
# command 'rpmbuild -bb ffmpeg-latest.spec --with production' will tune
for current hardware while default stays compatible #
#############################################################################################################################

%global ffmpeg_snapshot 20180617
%global x264_snapshot   20180210
%global x264_version    0.155.2901
%global pgo_build       1

%if %{?_with_production:1}%{!?_with_production:0}
 %global rpmsuffix native
 %global build_native_release 1
 %global optflags $(sed "s/sandybridge/native/g" <<< "%{optflags}")
 %global optflags $(sed "s/-mavx/-m%{mavx_native}/g" <<< "%{optflags}")
%else
 %global rpmsuffix %{mtune2}
 %global build_native_release 0
 %global optflags $(sed "s/sandybridge/%{mtune2}/g" <<< "%{optflags}")
 %global optflags $(sed "s/-mavx/-m%{mavx2}/g" <<< "%{optflags}")
%endif

Summary:           Hyper fast Audio and Video encoder (static build)
Name:              ffmpeg-latest
Version:           4.0.1
Release:
3.%{build_native_release}%{?dist}.x264.%{x264_version}.%{rpmsuffix}
License:           GPLv3+
URL:               http://ffmpeg.org/
Source0:           ffmpeg-%{ffmpeg_snapshot}.tar.xz
Source1:           x264-%{x264_snapshot}.tar.xz
Source2:           ffmpeg-snapshot-latest.sh
Source3:           x264-snapshot-latest.sh
Source4:           720x400.yuv
BuildRequires:     bzip2-devel
BuildRequires:     imlib2-devel
BuildRequires:     lame-devel
BuildRequires:     libtheora-devel
BuildRequires:     libvpx-devel
BuildRequires:     openssl-devel
BuildRequires:     x265-devel
BuildRequires:     nasm
BuildRequires:     yasm
BuildRequires:     zlib-devel
Provides:          ffmpeg
Obsoletes:         ffmpeg

%description
A complete, cross-platform solution to record, convert and stream audio
and video

%package           manpages
Summary:           Manpages for ffmpeg-latest
BuildArch:         noarch
%description       manpages

%prep
%setup -q -n ffmpeg-%{ffmpeg_snapshot}

%build
# build x264-static with profile-guided-optimization for current
architecture
tar xJf %{SOURCE1}
pushd x264-%{x264_snapshot}
./configure \
 --prefix=/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot} \
 --exec-prefix=/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static \
 --bindir=/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static \
 --libdir=/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static \
 --includedir=/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static \
 --extra-cflags="%{optflags} %{OS_flags} -fno-tree-vectorize
-fno-tree-loop-vectorize -fno-tree-slp-vectorize
-fexpensive-optimizations -foptimize-strlen -fdce -fdse -ftree-ch
-ftree-dce -ftree-dse -fsplit-paths -fpeel-loops -Wno-pointer-sign
-Wno-array-bounds -Wno-format-truncation -Wno-deprecated-declarations
-Wno-strict-overflow -Wno-discarded-qualifiers -Wno-address
-Wno-unused-variable -Wno-unused-function -Wno-unused-result
-Wno-misleading-indentation -fuse-ld=gold -fuse-linker-plugin" \
 --extra-ldflags="-Wl,--as-needed -Wl,-z,now -Wl,-z,relro
-Wl,-z,noexecstack %{optflags} %{OS_flags} -fno-tree-vectorize
-fno-tree-loop-vectorize -fno-tree-slp-vectorize
-fexpensive-optimizations -foptimize-strlen -fdce -fdse -ftree-ch
-ftree-dce -ftree-dse -fsplit-paths -fpeel-loops -Wno-pointer-sign
-Wno-array-bounds -Wno-format-truncation -Wno-deprecated-declarations
-Wno-strict-overflow -Wno-discarded-qualifiers -Wno-address
-Wno-unused-variable -Wno-unused-function -Wno-unused-result
-Wno-misleading-indentation -fuse-ld=gold -fuse-linker-plugin" \
 --enable-static \
 --enable-pic \
 --enable-strip \
 --disable-avs \
 --disable-cli \
 --disable-ffms \
 --disable-gpac \
 --disable-lavf \
 --disable-opencl \
 --disable-swscale
%if %pgo_build
 make fprofiled VIDS="%{SOURCE4}" %{?_smp_mflags}
%else
 make %{?_smp_mflags}
%endif
make install
strip --strip-unneeded --strip-debug
/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static/libx264.a
popd
# build ffmpeg-static and link with x264-static from previous build
mkdir generic
pushd generic
../configure \
 --prefix=%{_prefix}/local \
 --bindir=%{_prefix}/local/bin \
 --mandir=%{_prefix}/local/man \
 --extra-cflags="-I/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static
%{optflags} %{O3_flags} %{OS_flags} -fexpensive-optimizations
-foptimize-strlen -fdce -fdse -ftree-ch -ftree-dce -ftree-dse
-fsplit-paths -fpeel-loops -fPIC -flto=%(nproc) -ffat-lto-objects
-fwhole-program -Wno-pointer-sign -Wno-array-bounds
-Wno-format-truncation -Wno-deprecated-declarations -Wno-strict-overflow
-Wno-discarded-qualifiers -Wno-address -Wno-unused-variable
-Wno-unused-function -Wno-unused-result -Wno-misleading-indentation
-fuse-ld=gold -fuse-linker-plugin -Wa,--noexecstack" \
 --extra-ldflags="-I/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static -L/rpmbuild/BUILD/ffmpeg-%{ffmpeg_snapshot}/x264-static -ldl -Wl,--as-needed -Wl,-z,now -Wl,-z,relro -Wl,-z,noexecstack %{optflags} %{O3_flags} %{OS_flags} -fexpensive-optimizations -foptimize-strlen -fdce -fdse -ftree-ch -ftree-dce -ftree-dse -fsplit-paths -fpeel-loops -fPIC -flto=%(nproc) -ffat-lto-objects -fwhole-program -Wno-pointer-sign -Wno-array-bounds -Wno-format-truncation -Wno-deprecated-declarations -Wno-strict-overflow -Wno-discarded-qualifiers -Wno-address -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-misleading-indentation -pie -fPIE -fuse-ld=gold -fuse-linker-plugin -Wa,--noexecstack" \
 --ar=gcc-ar \
 --ranlib=true \
 --enable-lto \
 --enable-gpl \
 --enable-libmp3lame \
 --enable-libtheora \
 --enable-libvpx \
 --enable-libx264 \
 --enable-libx265 \
 --enable-nonfree \
 --enable-openssl \
 --enable-pic \
 --enable-runtime-cpudetect \
 --enable-static \
 --enable-version3 \
 --disable-amd3dnow \
 --disable-amd3dnowext \
 --disable-avdevice \
 --disable-debug \
 --disable-devices \
 --disable-ffplay \
 --disable-ffprobe \
 --disable-htmlpages \
 --disable-hwaccels \
 --disable-iconv \
 --disable-libdc1394 \
 --disable-libfreetype \
 --disable-libgsm \
 --disable-libopencore-amrnb \
 --disable-libopencore-amrwb \
 --disable-libopencv \
 --disable-libopenjpeg \
 --disable-libopus \
 --disable-librtmp \
 --disable-libspeex \
 --disable-libvorbis \
 --disable-libxcb \
 --disable-libxcb-shm \
 --disable-libxcb-xfixes \
 --disable-libxcb-shape \
 --disable-libxvid \
 --disable-podpages \
 --disable-postproc \
 --disable-protocol=gopher \
 --disable-shared \
 --disable-txtpages \
 --disable-xlib
%{__make} %{?_smp_mflags}
make documentation
popd

%install
pushd generic
make install DESTDIR=%{buildroot}
popd
mkdir %{buildroot}%{_bindir}
ln -s %{_prefix}/local/bin/ffmpeg %{buildroot}%{_bindir}/ffmpeg
rm -rf %{buildroot}%{_prefix}/local/include
%{buildroot}%{_prefix}/local/lib %{buildroot}%{_prefix}/local/lib64
%{buildroot}%{_prefix}/local/share
strip -s %{buildroot}%{_prefix}/local/bin/ffmpeg

%files
%{_prefix}/local/bin/ffmpeg
%{_bindir}/ffmpeg

%files manpages
%{_prefix}/local/man/man1/*
%{_prefix}/local/man/man3/*

%changelog
* Sun Jul 1 2018 Reindl Harald <[hidden email]>
- merge static x264/ffmpeg-build to support '--with production' for
-mtune=native
- link against x264 snapshot 0.155.2901
- minimize dependencies
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to build ffmpeg/x264/x265/fdkaac into one single ffmpeg file?

Carl Eugen Hoyos-2
In reply to this post by qw
2018-07-02 20:08 GMT+02:00, qw <[hidden email]>:

> I have one question about building ffmpeg.
>
> How to build ffmpeg/x264/x265/fdkaac and other external
> libraries into one single ffmpeg file in linux?

Not sure what exactly "one single ffmpeg file" means here
but the musl toolchain allows you to create true static
binaries, note that musl x86 is not supported by FFmpeg,
musl x86_64 is supported.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".