Skip to content

Commit 0f531da

Browse files
authored
Merge pull request #200 from jtbr/nvidia-fixes
Nvidia and other fixes
2 parents 6d40ffa + e1a73d9 commit 0f531da

File tree

2 files changed

+172
-120
lines changed

2 files changed

+172
-120
lines changed

README.md

Lines changed: 123 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,33 @@ By downloading and using this script, you are fully aware of this.
2222
Use this script at your own risk. I maintain this script in my spare time. Please do not file bug reports for systems
2323
other than Debian and macOS, because I don't have the resources or time to maintain different systems.
2424

25-
## Installation
25+
## Requirements to build
2626

27-
### Quick install and run (macOS, Linux)
27+
### macOS
2828

29-
Open your command line and run (curl needs to be installed):
29+
* XCode 10.x or greater
30+
31+
### Linux
32+
33+
* Debian >= Buster, Ubuntu => Focal Fossa; other distributions might work too
34+
* Rocky Linux 8
3035

3136
```bash
37+
# Debian and Ubuntu
38+
$ sudo apt install build-essential curl
3239

40+
# Fedora
41+
$ sudo dnf install @development-tools curl
42+
```
43+
44+
## Quick Script Installation
45+
46+
Note: to enable hardware acceleration, see details below.
47+
### Quick install and build (macOS, Linux)
48+
49+
Open your command line and run (curl needs to be installed):
50+
51+
```bash
3352
# Without GPL and non-free codes, see https://ffmpeg.org/legal.html
3453
$ bash <(curl -s "https://github.com/raw/markus-perl/ffmpeg-build-script/master/web-install.sh?v1")
3554

@@ -39,12 +58,15 @@ $ bash <(curl -s "https://github.com/raw/markus-perl/ffmpeg-build-scr
3958

4059
This command downloads the build script and automatically starts the build process.
4160

42-
### Common installation (macOS, Linux)
61+
### Common install and build (macOS, Linux)
4362

4463
```bash
4564
$ git clone https://github.com/markus-perl/ffmpeg-build-script.git
4665
$ cd ffmpeg-build-script
66+
# Without GPL and non-free codecs
4767
$ ./build-ffmpeg --build
68+
# With GPL and non-free codecs
69+
$ ./build-ffmpeg --enable-gpl-and-non-free --build
4870
```
4971

5072
## Supported Codecs
@@ -54,7 +76,7 @@ $ ./build-ffmpeg --build
5476
* `libsvtav1`: SVT-AV1 Encoder and Decoder
5577
* `aom`: AV1 Video Codec (Experimental and very slow!)
5678
* `librav1e`: rust based AV1 encoder (only available if [`cargo` is installed](https://doc.rust-lang.org/cargo/getting-started/installation.html))
57-
* `libdav1d`: Fastest AV1 decoder developed by the VideoLAN and FFmpeg communities and sponsored by the AOMedia (only available if `meson` and `ninja` are installed)
79+
* `libdav1d`: Fastest AV1 decoder developed by the VideoLAN and FFmpeg communities and sponsored by the AOMedia (only available if `meson` and `ninja` are available)
5880
* `fdk_aac`: Fraunhofer FDK AAC Codec
5981
* `xvidcore`: MPEG-4 video coding standard
6082
* `VP8/VP9/webm`: VP8 / VP9 Video Codec for the WebM video file format
@@ -100,45 +122,113 @@ $ ./build-ffmpeg --build
100122
* H264 `h264_amf`
101123

102124

103-
### Apple M1 (Apple Silicon) Support
125+
## Build Script Usage
104126

105-
The script also builds FFmpeg on a new MacBook with an Apple Silicon M1 processor.
127+
```bash
128+
Usage: build-ffmpeg [OPTIONS]
129+
Options:
130+
-h, --help Display usage information
131+
--version Display version information
132+
-b, --build Starts the build process
133+
--enable-gpl-and-non-free Enable non-free codecs - https://ffmpeg.org/legal.html
134+
--latest Build latest version of dependencies if newer available
135+
-c, --cleanup Remove all working dirs
136+
--small Prioritize small size over speed and usability; don't build manpages.
137+
--full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux**
138+
Note: Because of the NSS (Name Service Switch), glibc does not recommend static links.
139+
```
106140
107-
### LV2 Plugin Support
141+
### Notes on static linking
108142
109-
If Python is available, the script will build a ffmpeg binary with lv2 plugin support.
143+
- Because of the NSS (Name Service Switch), glibc does **not recommend** static links. See [more details here](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).
110144
111-
## Continuous Integration
145+
- The libnpp in the CUDA SDK cannot be statically linked.
146+
- Vaapi cannot be statically linked.
112147
113-
ffmpeg-build-script is very stable. Every commit runs against Linux and macOS
114-
with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure everything works as expected.
115148
116-
## Requirements
149+
## Common full build (macOS, Linux)
117150
118-
### macOS
151+
1) Install the [prerequisites](#requirements-to-build), above.
152+
1) Install optional dependencies, as desired.
153+
- If you have an NVIDIA GPU and want to enable CUDA acceleration, please refer to [these instructions](#Cuda-installation) to install the SDK.
119154
120-
* XCode 10.x or greater
155+
- If you have an AMD GPU and want to enable AMF acceleration, please refer to [these instructions](#amf-installation) to install the drivers.
121156
122-
### Linux
157+
- If you want to enable Vaapi acceleration (for most GPUs), please refer to [these instructions](#Vaapi-installation) to install the driver.
123158
124-
* Debian >= Buster, Ubuntu => Focal Fossa, other Distributions might work too
125-
* Rocky Linux 8
126-
* A development environment and curl is required
159+
- If you want the `librav1e` AV1 encoder, please install [rust](https://doc.rust-lang.org/cargo/getting-started/installation.html) to get `cargo` for the build process. Be sure to start a new shell before building, so that `cargo` is in the new path. If desired, it can be removed with `rustup self uninstall` after the build is complete.
160+
161+
- If you want the `dav1d` AV1 decoder, please ensure that `python3` is installed. If using the system python installation, also ensure that `meson` and `ninja` are installed before running (otherwise the script will try to install them using `pip3`).
162+
163+
- If you want the `Lv2` filter plugin, please ensure that `python3` is installed.
164+
165+
1) Run the downoaded build script from the current directory, with your desired [options](#build-script-usage).
166+
```bash
167+
$ ./build-ffmpeg [your parameters here] --build
168+
```
169+
- Packages will be under the `packages/` subdirectory.
170+
- Build results will be under the `workspace/` subdirectory.
171+
172+
Upon completion, build-ffmpeg will prompt you for whether to install.
173+
174+
1) Once installed, if you are satisfied with your ffmpeg build, the ffmpeg-build-script directory can be removed completely.
175+
176+
### CUDA installation
177+
178+
CUDA is a parallel computing platform developed by NVIDIA. To be able to compile ffmpeg with CUDA support, you first
179+
need a compatible NVIDIA GPU and the NVIDIA compiler nvcc from the CUDA toolkit.
180+
181+
- Ubuntu: To install the CUDA toolkit on Ubuntu, run
182+
```bash
183+
sudo apt install nvidia-cuda-toolkit
184+
```
185+
After compilation, you can run
186+
```bash
187+
sudo apt install nvidia-cuda-dev && sudo apt remove nvidia-cuda-toolkit
188+
```
189+
This removes the compilers but leaves the needed shared library `libnpp`.
190+
191+
- Other Linux distributions: Once you have the GPU and display driver installed, you can follow the
192+
[official instructions](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)
193+
or [this blog](https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-1-on-Ubuntu-19-04-1405/)
194+
to setup the CUDA toolkit.
195+
196+
### Vaapi installation
197+
198+
You will need the libva driver, so please install it below.
127199
128200
```bash
129201
# Debian and Ubuntu
130-
$ sudo apt install build-essential curl
202+
$ sudo apt install libva-dev vainfo
131203
132-
# Fedora
133-
$ sudo dnf install @development-tools curl
204+
# Fedora and CentOS
205+
$ sudo dnf install libva-devel libva-intel-driver libva-utils
134206
```
135207
136-
### Build in Docker (Linux)
208+
### AMF installation
209+
210+
To use the AMF encoder, you will need to be using the AMD GPU Pro drivers with OpenCL support.
211+
Download the drivers from https://www.amd.com/en/support and install the appropriate opencl versions.
212+
213+
```bash
214+
./amdgpu-pro-install -y --opencl=rocr,legacy
215+
```
216+
217+
### LV2 Plugin Support
218+
219+
If python 3 is available, the script will build a ffmpeg binary with [Lv2 filter](https://github.com/lv2/lv2/wiki) plugin support.
220+
221+
### Apple M1 (Apple Silicon) Support
222+
223+
The script also builds FFmpeg on a new MacBook with an Apple Silicon M1 processor.
224+
225+
226+
## Build in Docker (Linux)
137227
138228
With Docker, FFmpeg can be built reliably without altering the host system. Also, there is no need to have the CUDA SDK
139229
installed outside of the Docker image.
140230
141-
##### Default
231+
#### Default
142232
143233
If you're running an operating system other than the one above, a completely static build may work. To build a full
144234
statically linked binary inside Docker, just run the following command:
@@ -147,10 +237,10 @@ statically linked binary inside Docker, just run the following command:
147237
$ docker build --tag=ffmpeg:default --output type=local,dest=build -f Dockerfile .
148238
```
149239

150-
##### CUDA
240+
#### CUDA
151241
These builds are always built with the --enable-gpl-and-non-free switch, as CUDA is non-free. See https://ffmpeg.org/legal.html
152-
```bash
153242

243+
```bash
154244
## Start the build
155245
$ docker build --tag=ffmpeg:cuda --output type=local,dest=build -f cuda-ubuntu.dockerfile .
156246
```
@@ -170,7 +260,7 @@ $ ls build/lib
170260
libnppc.so.11 libnppicc.so.11 libnppidei.so.11 libnppig.so.11
171261
```
172262
173-
##### Full static version
263+
#### Full static version
174264
175265
If you're running an operating system other than the one above, a completely static build may work. To build a full
176266
statically linked binary inside Docker, just run the following command:
@@ -204,70 +294,6 @@ $ sudo docker build --tag=ffmpeg:cuda -f cuda-ubuntu.dockerfile .
204294
$ 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 - > test.mp4
205295
```
206296

207-
### Common build (macOS, Linux)
208-
209-
If you want to enable CUDA, please refer to [these](#Cuda-installation) and install the SDK.
210-
211-
If you want to enable Vaapi, please refer to [these](#Vaapi-installation) and install the driver.
212-
213-
```bash
214-
$ ./build-ffmpeg --build
215-
```
216-
217-
## Cuda installation
218-
219-
CUDA is a parallel computing platform developed by NVIDIA. To be able to compile ffmpeg with CUDA support, you first
220-
need a compatible NVIDIA GPU.
221-
222-
- Ubuntu: To install the CUDA toolkit on Ubuntu, run "sudo apt install nvidia-cuda-toolkit"
223-
- Other Linux distributions: Once you have the GPU and display driver installed, you can follow the
224-
[official instructions](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html)
225-
or [this blog](https://www.pugetsystems.com/labs/hpc/How-To-Install-CUDA-10-1-on-Ubuntu-19-04-1405/)
226-
to setup the CUDA toolkit.
227-
228-
## Vaapi installation
229-
230-
You will need the libva driver, so please install it below.
231-
232-
```bash
233-
# Debian and Ubuntu
234-
$ sudo apt install libva-dev vainfo
235-
236-
# Fedora and CentOS
237-
$ sudo dnf install libva-devel libva-intel-driver libva-utils
238-
```
239-
240-
## AMF installation
241-
242-
To use the AMF encoder, you will need to be using the AMD GPU Pro drivers with OpenCL support.
243-
Download the drivers from https://www.amd.com/en/support and install the appropriate opencl versions.
244-
245-
```bash
246-
./amdgpu-pro-install -y --opencl=rocr,legacy
247-
```
248-
249-
## Usage
250-
251-
```bash
252-
Usage: build-ffmpeg [OPTIONS]
253-
Options:
254-
-h, --help Display usage information
255-
--version Display version information
256-
-b, --build Starts the build process
257-
--enable-gpl-and-non-free Enable non-free codecs - https://ffmpeg.org/legal.html
258-
--latest Build latest version of dependencies if newer available
259-
-c, --cleanup Remove all working dirs
260-
--full-static Complete static build of ffmpeg (eg. glibc, pthreads etc...) **only Linux**
261-
Note: Because of the NSS (Name Service Switch), glibc does not recommend static links.
262-
```
263-
264-
## Notes of static link
265-
266-
- Because of the NSS (Name Service Switch), glibc does **not recommend** static links. See detail
267-
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
268-
269-
- The libnpp in the CUDA SDK cannot be statically linked.
270-
- Vaapi cannot be statically linked.
271297

272298
Contact
273299
-------
@@ -281,6 +307,12 @@ Tested on
281307
* Debian 10
282308
* Ubuntu 20.04
283309

310+
## Continuous Integration
311+
312+
ffmpeg-build-script is very stable. Every commit runs against Linux and macOS
313+
with https://github.com/markus-perl/ffmpeg-build-script/actions to make sure everything works as expected.
314+
315+
284316
Example
285317
-------
286318

0 commit comments

Comments
 (0)