Skip to content

Commit 4bb47e7

Browse files
authored
Merge pull request #61 from AkashiSN/full-static
add static build option
2 parents abc585e + 48b202b commit 4bb47e7

File tree

6 files changed

+333
-199
lines changed

6 files changed

+333
-199
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ jobs:
2020
while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done &
2121
SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build
2222
kill %1
23-
23+
- name: check shared library
24+
run: |
25+
ldd ./workspace/bin/ffmpeg
26+
- name: test run ffmepg
27+
run: |
28+
./workspace/bin/ffmpeg -buildconf
2429
- name: clean up
2530
run: |
2631
./build-ffmpeg --cleanup
@@ -37,7 +42,12 @@ jobs:
3742
while sleep 300; do echo "=====[ $SECONDS seconds still running ]====="; done &
3843
SKIPINSTALL=yes VERBOSE=yes ./build-ffmpeg --build
3944
kill %1
40-
45+
- name: check shared library
46+
run: |
47+
otool -L ./workspace/bin/ffmpeg
48+
- name: test run ffmepg
49+
run: |
50+
./workspace/bin/ffmpeg -buildconf
4151
- name: clean up
4252
run: |
4353
./build-ffmpeg --cleanup
@@ -53,19 +63,16 @@ jobs:
5363
id: ubuntu_pull
5464
run: |
5565
docker pull ubuntu:20.04
56-
5766
- name: run if ubuntu_pull failed
5867
if: failure() && steps.ubuntu_pull.outcome == 'failure'
5968
run: |
6069
docker pull ubuntu:20.04
61-
6270
- name: build ffmpeg
6371
run: |
6472
docker build -t ffmpeg:ubuntu -f Dockerfile .
65-
6673
- name: test run ffmepg
6774
run: |
68-
docker run --rm ffmpeg:ubuntu
75+
docker run --rm ffmpeg:ubuntu -buildconf
6976
7077
build-cuda-docker:
7178
name: build in docker with cuda
@@ -78,16 +85,39 @@ jobs:
7885
id: cuda_ubuntu_pull
7986
run: |
8087
docker pull nvidia/cuda:11.1-devel-ubuntu20.04
81-
88+
docker pull nvidia/cuda:11.1-runtime-ubuntu20.04
8289
- name: run if cuda_ubuntu_pull failed
8390
if: failure() && steps.cuda_ubuntu_pull.outcome == 'failure'
8491
run: |
85-
docker pull nvidia/cuda:11.1-devel-ubuntu20.04
86-
92+
docker pull nvidia/cuda:11.1-devel-ubuntu20.04
93+
docker pull nvidia/cuda:11.1-runtime-ubuntu20.04
8794
- name: build ffmpeg
8895
run: |
8996
docker build -t ffmpeg:cuda -f cuda-ubuntu.dockerfile .
97+
- name: test run ffmepg
98+
run: |
99+
docker run --rm ffmpeg:cuda -buildconf
100+
101+
build-full-static:
102+
name: build full static linking in docker
103+
runs-on: ubuntu-20.04
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v2
90107

108+
- name: pull base image
109+
id: cuda_ubuntu_centos_pull
110+
run: |
111+
docker pull nvidia/cuda:11.1-devel-ubuntu20.04
112+
docker pull centos:8
113+
- name: run if cuda_ubuntu_centos_pull failed
114+
if: failure() && steps.cuda_ubuntu_centos_pull.outcome == 'failure'
115+
run: |
116+
docker pull nvidia/cuda:11.1-devel-ubuntu20.04
117+
docker pull centos:8
118+
- name: build ffmpeg
119+
run: |
120+
docker build -t ffmpeg:cuda-static -f full-static.dockerfile .
91121
- name: test run ffmepg
92122
run: |
93-
docker run --rm ffmpeg:cuda
123+
docker run --rm ffmpeg:cuda-static -buildconf

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ FROM ubuntu:20.04
1515
COPY --from=build /app/workspace/bin/ffmpeg /usr/bin/ffmpeg
1616
COPY --from=build /app/workspace/bin/ffprobe /usr/bin/ffprobe
1717

18-
RUN ldd /usr/bin/ffmpeg
19-
RUN ldd /usr/bin/ffprobe
18+
RUN ldd /usr/bin/ffmpeg ; exit 0
19+
RUN ldd /usr/bin/ffprobe ; exit 0
2020

2121
CMD ["--help"]
2222
ENTRYPOINT ["/usr/bin/ffmpeg"]

README.md

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ Requirements Linux
6262

6363
```
6464
# Debian and Ubuntu
65-
sudo apt-get install build-essential curl g++
65+
$ sudo apt-get install build-essential curl g++
6666
6767
# Fedora
68-
sudo dnf install @development-tools
68+
$ sudo dnf install @development-tools
6969
```
7070

7171
Installation
@@ -76,37 +76,36 @@ Installation
7676
Open your command line and run (needs curl to be installed):
7777

7878
```bash
79-
bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1")
79+
$ bash <(curl -s "https://raw.githubusercontent.com/markus-perl/ffmpeg-build-script/master/web-install.sh?v1")
8080
```
8181
This command downloads the build script and automatically starts the build process.
8282

8383
### Run with Docker
8484

8585
#### Default - Without CUDA
8686
```bash
87-
git clone https://github.com/markus-perl/ffmpeg-build-script.git
88-
cd ffmpeg-build-script
89-
docker build --tag=ffmpeg .
90-
docker run ffmpeg -i https://files.coconut.co.s3.amazonaws.com/test.mp4 -f webm -c:v libvpx -c:a libvorbis - > /tmp/test.mp4
87+
$ git clone https://github.com/markus-perl/ffmpeg-build-script.git
88+
$ cd ffmpeg-build-script
89+
$ sudo docker build --tag=ffmpeg .
90+
$ docker run ffmpeg -i https://files.coconut.co.s3.amazonaws.com/test.mp4 -f webm -c:v libvpx -c:a libvorbis - > /tmp/test.mp4
9191
```
9292

9393
#### With CUDA
9494
```bash
95-
git clone https://github.com/markus-perl/ffmpeg-build-script.git
96-
cd ffmpeg-build-script
97-
docker build --tag=ffmpeg-cuda -f cuda-ubuntu.dockerfile .
98-
docker run --gpus all ffmpeg-cuda -hwaccel cuvid -c:v h264_cuvid -i https://files.coconut.co.s3.amazonaws.com/test.mp4 -c:v hevc_nvenc -vf scale_npp=-1:1080 - > /tmp/test.mp4
95+
$ git clone https://github.com/markus-perl/ffmpeg-build-script.git
96+
$ cd ffmpeg-build-script
97+
$ sudo docker build --tag=ffmpeg-cuda -f cuda-ubuntu.dockerfile .
98+
$ sudo docker run --gpus all ffmpeg-cuda -hwaccel cuvid -c:v h264_cuvid -i https://files.coconut.co.s3.amazonaws.com/test.mp4 -c:v hevc_nvenc -vf scale_npp=-1:1080 - > /tmp/test.mp4
9999
```
100100

101101
### Common installation
102102

103103
```bash
104-
git clone https://github.com/markus-perl/ffmpeg-build-script.git
105-
cd ffmpeg-build-script
106-
./build-ffmpeg --help
104+
$ git clone https://github.com/markus-perl/ffmpeg-build-script.git
105+
$ cd ffmpeg-build-script
106+
$ ./build-ffmpeg --help
107107
```
108108

109-
110109
### Cuda installation
111110

112111
CUDA is a parallel computing platform developed by NVIDIA.
@@ -121,11 +120,22 @@ Usage
121120
------
122121

123122
```bash
124-
./build-ffmpeg --help Display usage information
125-
./build-ffmpeg --build Starts the build process
126-
./build-ffmpeg --cleanup Remove all working dirs
123+
Usage: build-ffmpeg [OPTIONS]
124+
Options:
125+
-h, --help Display usage information
126+
--version Display version information
127+
-b, --build Starts the build process
128+
-c, --cleanup Remove all working dirs
129+
-f, --full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **not recommend**
130+
Note: Because of the NSS (Name Service Switch), glibc does not recommend static links.
127131
```
128132

133+
## Notes of static link
134+
- Because of the NSS (Name Service Switch), glibc does **not recommend** static links.
135+
See detail below: https://sourceware.org/glibc/wiki/FAQ#Even_statically_linked_programs_need_some_shared_libraries_which_is_not_acceptable_for_me.__What_can_I_do.3F
136+
137+
- The libnpp in the CUDA SDK cannot be statically linked.
138+
129139
Contact
130140
-------
131141

0 commit comments

Comments
 (0)