-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for gpu_direct in ffmepg ffmpeg plugin
Introduces suport for experimental MTL_GPU_DIRECT feature to enhance the performance of the FFmpeg ST20p plugin by enabling direct GPU memory access. Update ffmpeg README.md -- include build instructions and description of the feature Modify build_ffmpeg_plugin.sh -- Add support for building with GPU_DIRECT
- Loading branch information
1 parent
c43152d
commit d815791
Showing
3 changed files
with
154 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,83 @@ | ||
#!/bin/bash | ||
|
||
# SPDX-License-Identifier: BSD-3-Clause | ||
# Copyright 2024 Intel Corporation | ||
# SPDX-FileCopyrightText: Copyright (c) 2024 Intel Corporation | ||
|
||
set -e | ||
|
||
if [ -n "$1" ]; then | ||
ffmpeg_ver=$1 | ||
else | ||
# default to latest 7.0 | ||
ffmpeg_ver=7.0 | ||
fi | ||
# Default values | ||
ffmpeg_ver="7.0" | ||
enable_gpu=false | ||
script_path="$(dirname "$(readlink -f "$0")")" | ||
|
||
# Help message function | ||
usage() { | ||
echo "Usage: $0 [options]" | ||
echo "Options:" | ||
echo " -v <version> Specify the FFmpeg version to build (default is 7.0)" | ||
echo " -g Enable GPU direct mode during compilation" | ||
echo " -h Display this help and exit" | ||
} | ||
|
||
# Parse command-line options | ||
while getopts ":v:hg" opt; do | ||
case "${opt}" in | ||
v) | ||
ffmpeg_ver=${OPTARG} | ||
;; | ||
g) | ||
enable_gpu=true | ||
;; | ||
h) | ||
usage | ||
exit 0 | ||
;; | ||
\?) | ||
echo "Invalid option: -$OPTARG" >&2 | ||
usage | ||
exit 1 | ||
;; | ||
:) | ||
echo "Option -$OPTARG requires an argument." >&2 | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
build_openh264() { | ||
rm openh264 -rf | ||
git clone https://github.com/cisco/openh264.git | ||
cd openh264 | ||
git checkout openh264v2.4.0 | ||
make -j "$(nproc)" | ||
sudo make install | ||
sudo ldconfig | ||
cd ../ | ||
rm -rf openh264 | ||
git clone https://github.com/cisco/openh264.git | ||
cd openh264 | ||
git checkout openh264v2.4.0 | ||
make -j "$(nproc)" | ||
sudo make install | ||
sudo ldconfig | ||
cd ../ | ||
} | ||
|
||
build_ffmpeg() { | ||
rm FFmpeg -rf | ||
git clone https://github.com/FFmpeg/FFmpeg.git | ||
cd FFmpeg | ||
git checkout release/"$ffmpeg_ver" | ||
cp -f ../mtl_* ./libavdevice/ | ||
git am ../"$ffmpeg_ver"/*.patch | ||
./configure --enable-shared --disable-static --enable-nonfree --enable-pic --enable-gpl --enable-libopenh264 --enable-encoder=libopenh264 --enable-mtl | ||
make -j "$(nproc)" | ||
sudo make install | ||
sudo ldconfig | ||
cd ../ | ||
rm -rf FFmpeg | ||
git clone https://github.com/FFmpeg/FFmpeg.git | ||
cd FFmpeg | ||
git checkout release/"$ffmpeg_ver" | ||
cp -f "$script_path"/mtl_* ./libavdevice/ | ||
git am "$script_path"/"$ffmpeg_ver"/*.patch | ||
|
||
if [ "$enable_gpu" = true ]; then | ||
echo "Building with MTL_GPU_DIRECT_ENABLED" | ||
extra_config_flags="--extra-cflags=-DMTL_GPU_DIRECT_ENABLED" | ||
else | ||
extra_config_flags="" | ||
fi | ||
|
||
./configure --enable-shared --disable-static --enable-nonfree --enable-pic --enable-gpl --enable-libopenh264 --enable-encoder=libopenh264 --enable-mtl $extra_config_flags | ||
make -j "$(nproc)" | ||
sudo make install | ||
sudo ldconfig | ||
cd ../ | ||
} | ||
|
||
build_openh264 | ||
build_ffmpeg | ||
|
||
echo "Building ffmpeg $ffmpeg_ver plugin is finished" | ||
echo "Building ffmpeg $ffmpeg_ver plugin is finished" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters