Skip to content

Commit

Permalink
Add script to compile ffmpeg as static PIE binary
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian-George Dumitrache <adrian.dumitrache02@stud.acs.upb.ro>

Fixed formatting

Signed-off-by: Adrian-George Dumitrache <adrian.dumitrache02@stud.acs.upb.ro>
  • Loading branch information
dumitrache-adrian92 committed Oct 12, 2022
1 parent 46635a4 commit 0f38c8c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ffmpeg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/ffmpeg-5.1.2/
/ffmpeg-5.1.2.tar.bz2*
20 changes: 20 additions & 0 deletions ffmpeg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build ffmpeg as static PIE

Script to build ffmpeg as a static PIE binary.

## Requirements

Make sure that you have the following packages installed:
* GCC
* GNU Make

## Build

Run the build.sh file.
It will create a folder where the static PIE ffmpeg will be located.

## Running

```bash
./ffmpeg -i rootfs/drop.avi drop_new.mp4
```
30 changes: 30 additions & 0 deletions ffmpeg/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

link="https://ffmpeg.org/releases/ffmpeg-5.1.2.tar.bz2"

# Clean up
rm -fr ffmpeg-*

echo -n "Downloading ffmpeg source code ... "
wget -q "$link"
echo ""
echo -n "Unpacking ffmpeg ... "
tar -xf ffmpeg-5.1.2.tar.bz2
echo ""

pushd ffmpeg-5.1.2/ > /dev/null 2>&1 || exit 1

echo -n "Configuring ffmpeg ... "
# Add PIC/PIE compile/link flags.
./configure --extra-cflags="-fPIC" --extra-ldflags="-static-pie" --disable-shared --disable-opencl
echo ""

echo -n "Building ffmpeg ..."
make -j "$(nproc)"

echo ""
popd > /dev/null 2>&1 || exit

ln -fn ffmpeg-5.1.2/ffmpeg .

rm ffmpeg-5.1.2.tar.bz2*
Binary file added ffmpeg/ffmpeg
Binary file not shown.
Binary file added ffmpeg/rootfs/drop.avi
Binary file not shown.

0 comments on commit 0f38c8c

Please sign in to comment.