Add ffmpeg with nvidia codec

This commit is contained in:
Digital Studium 2024-03-03 21:02:53 +03:00
parent 421fd71e11
commit 86af034ed6
3 changed files with 26 additions and 9 deletions

View File

@ -1,8 +1,6 @@
#!/bin/bash #!/bin/bash
sudo add-apt-repository ppa:ubuntuhandbook1/ffmpeg6 -y
sudo nala update sudo nala update
sudo nala install -y \ sudo nala install -y \
ffmpeg `# for video recording` \
mpv `# for video playing` \ mpv `# for video playing` \
sxiv `# for pictures` \ sxiv `# for pictures` \
strace `# for tracing` \ strace `# for tracing` \
@ -14,6 +12,21 @@ do
sudo usermod -a -G $group $USER sudo usermod -a -G $group $USER
done done
# install ffmpeg with nvidia
if ! command -v ffmpeg &> /dev/null
then
git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg/
git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
cd nv-codec-headers && sudo make install && cd -
sudo nala install -y build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev libasound2-dev
cd ffmpeg
./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --enable-libxcb --enable-indev=alsa --enable-outdev=alsa --extra-cflags=-I/usr/lib/cuda/include --extra-ldflags=-L/usr/lib/cuda/lib64 --disable-static --enable-shared
make -j 8
sudo make install
cd -
rm -rf ffmpeg nv-codec-headers
fi
# install pet # install pet
if ! command -v pet &> /dev/null if ! command -v pet &> /dev/null
then then

View File

@ -34,7 +34,6 @@ pulseaudio `# for sound` \
alsa-base `# for sound` \ alsa-base `# for sound` \
pavucontrol `# for audio control` \ pavucontrol `# for audio control` \
pasystray `# for audio control` \ pasystray `# for audio control` \
libnvidia-compute-545 `# for mpv + nvidia` \
iputils-ping `# ping etc.` \ iputils-ping `# ping etc.` \
xfe `# classic file manager` \ xfe `# classic file manager` \
surf `# suckless lightweight browser` \ surf `# suckless lightweight browser` \
@ -44,7 +43,10 @@ psmisc `# pstree etc.` \
slack \ slack \
firefox \ firefox \
python3 \ python3 \
python3-venv python3-venv \
libnvidia-compute-545 `# for mpv + nvidia` \
nvidia-driver-545 `# nvidia driver` \
nvidia-cuda-toolkit `# cuda driver`
# install telegram # install telegram
if [ ! -d /opt/Telegram ] if [ ! -d /opt/Telegram ]

View File

@ -1,7 +1,9 @@
#!/bin/bash #!/bin/bash
ffmpeg \ export LD_LIBRARY_PATH=/usr/local/lib
-f x11grab -framerate 30 -video_size 1920x1080 -i :0 `# this is screen` \ ffmpeg -hwaccel cuda -hwaccel_output_format cuda `# we need nvidia acceleration because of low fps without it` \
-f v4l2 -framerate 30 -video_size 640x480 -i /dev/video0 `# this is camera` \ -f x11grab -r 30 -video_size 1920x1080 -i :0 `# this is screen` \
-f alsa -i default `# this is audio` \ -f v4l2 -r 30 -video_size 640x480 -i /dev/video0 `# this is camera` \
-f alsa -i default `# this is audio. Why not pulse? Nvidia?` \
-c:v h264_nvenc `# this is video codec` \
-filter_complex "[0][1]overlay=main_w-overlay_w-2:main_h-overlay_h-2[v]" -map [v] -map 2 `# this is for placing camera in bottom right corner. IDK how it works` \ -filter_complex "[0][1]overlay=main_w-overlay_w-2:main_h-overlay_h-2[v]" -map [v] -map 2 `# this is for placing camera in bottom right corner. IDK how it works` \
video.mp4 # ouput file video.mp4 # output file