Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rom1v committed Feb 27, 2023
0 parents commit d9c6da0
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This project hosts a script to generate a minimal FFmpeg Windows build for
[scrcpy].

[scrcpy]: https://github.com/Genymobile/scrcpy

The script is intended to be executred on Linux (typically Debian), with
`mingw-w64` installed.

The packages `libz-mingw-w64` and `libz-mingw-w64-dev` (necessary for zlib) must
be installed.

First, clone the official FFmpeg project anywhere:

```
git clone git://source.ffmpeg.org/ffmpeg.git
```

Checkout the expected version.

Then, from this `scrcpy-deps` repo, run:

```
./build_ffmpeg_windows.sh <ffmpeg_directory>
```
100 changes: 100 additions & 0 deletions build_ffmpeg_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#!/bin/bash
set -e

if [[ $# -lt 1 ]]
then
echo "Syntax: $0 <ffmpeg_directory>" >&2
exit 1
fi

FFMPEG_DIRECTORY="$1"

configure_ffmpeg() {
# -static-libgcc to avoid missing libgcc_s_dw2-1.dll
CFLAGS=-static-libgcc \
LDFLAGS=-static-libgcc \
"$FFMPEG_DIRECTORY"/configure \
--prefix=install \
--enable-cross-compile \
--target-os=mingw32 \
--arch="$ARCH" \
--cross-prefix="$CROSS_PREFIX" \
--cc="${CROSS_PREFIX}gcc" \
--extra-cflags="-O2 -fPIC" \
--enable-shared \
--disable-static \
--disable-programs \
--disable-doc \
--disable-swscale \
--disable-postproc \
--disable-avfilter \
--disable-avdevice \
--disable-network \
--disable-everything \
--enable-swresample \
--enable-decoder=h264 \
--enable-decoder=hevc \
--enable-decoder=av1 \
--enable-decoder=opus \
--enable-decoder=aac \
--enable-decoder=png \
--enable-protocol=file \
--enable-demuxer=image2 \
--enable-parser=png \
--enable-zlib \
--enable-muxer=matroska \
--enable-muxer=mp4 \
--disable-vulkan
}

configure_ffmpeg_win64() {
ARCH=x86_64
CROSS_PREFIX="x86_64-w64-mingw32-"
configure_ffmpeg
}

configure_ffmpeg_win32() {
ARCH=x86
CROSS_PREFIX="i686-w64-mingw32-"
configure_ffmpeg
}

build_install() {
local ABI="$1"
rm -rf build-"$ABI"
mkdir build-"$ABI"
cd build-"$ABI"
configure_ffmpeg_"$ABI"
make -j
make install
cd ..
}

copy_release_binaries() {
local ABI="$1"
mkdir -p "ffmpeg/$ABI/bin"
for name in avutil-57 avcodec-59 avformat-59 swresample-4
do
cp "../build-$ABI/install/bin/$name.dll" "ffmpeg/$ABI/bin/"
done
cp -r "../build-$ABI/install/include" "ffmpeg/$ABI/"
}

mkdir -p ffmpeg
cd ffmpeg

build_install win64
build_install win32

mkdir -p release/ffmpeg
cd release

copy_release_binaries win64
copy_release_binaries win32

# libz-mingw-w64 and libz-mingw-w64-dev must be installed
cp /usr/x86_64-w64-mingw32/lib/zlib1.dll ffmpeg/win64/bin/
cp /usr/i686-w64-mingw32/lib/zlib1.dll ffmpeg/win32/bin/

7z a ffmpeg-release.7z ffmpeg
echo "FFmpeg release written to $PWD/ffmpeg-release.7z"

0 comments on commit d9c6da0

Please sign in to comment.