Skip to content

Instantly share code, notes, and snippets.

@Randy420Marsh
Last active June 30, 2025 18:25
Show Gist options
  • Select an option

  • Save Randy420Marsh/06b6af4cd2d4e0a1b4bdf1138696b3eb to your computer and use it in GitHub Desktop.

Select an option

Save Randy420Marsh/06b6af4cd2d4e0a1b4bdf1138696b3eb to your computer and use it in GitHub Desktop.
tests the ffmpeg cuda accelerated libvmaf_cuda build
#!/bin/bash
export PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig"
export LIBRARY_PATH="/etc/ld.so.conf.d:/usr/local/lib:/usr/local/cuda-12.8/lib64:/usr/local/cuda-12.8/targets/x86_64-linux/lib"
export CUDA_PATH="/usr/local/cuda-12.8"
export PATH="${CUDA_PATH}/bin:${PATH}"
export LD_LIBRARY_PATH="/usr/local/lib:${CUDA_PATH}/lib64:${CUDA_PATH}/targets/x86_64-linux/lib:${LD_LIBRARY_PATH}"
sudo bash -c "echo '${CUDA_PATH}/lib64/stubs/' > /etc/ld.so.conf.d/cuda-stubs.conf"
sudo bash -c "echo '/usr/local/lib' > /etc/ld.so.conf.d/vmaf-local.conf" # Explicitly add /usr/local/lib
sudo ldconfig
# Verify libvmaf.so.3 exists after installation
if [ -f "/usr/local/lib/libvmaf.so.3" ]; then
echo "Verification: libvmaf.so.3 found at /usr/local/lib/"
else
echo "ERROR: libvmaf.so.3 NOT found at /usr/local/lib/. VMAF installation might have failed."
exit 1
fi
# Download test video
if [ ! -f "${HOME}/build/data/ref.mp4" ]; then
curl -o ${HOME}/build/data/ref.mp4 https://videos.pexels.com/video-files/4307941/4307941-uhd_2560_1440_30fps.mp4
echo "Downloaded ref.mp4"
else
echo "ref.mp4 already exists, skipping download."
fi
# Convert reference video to MP4 (blue_sky_qp4.mp4)
echo "Converting ref.mp4 to dist.mp4 using libx264..."
# Ensure ffmpeg is found in PATH and LD_LIBRARY_PATH is set for this command too
ffmpeg -i "${HOME}/build/data/ref.mp4" -c:v libx264 -preset fast -pix_fmt yuv420p "${HOME}/build/data/dist-x264.mp4"
ffmpeg -i "${HOME}/build/data/ref.mp4" -c:v h264_nvenc -preset fast -pix_fmt yuv420p "${HOME}/build/data/dist-nvenc.mp4"
echo "Test video converted."
# --- 9. Verify FFmpeg Capabilities and Run VMAF Analysis ---
echo "Verifying FFmpeg hardware acceleration and encoders..."
ffmpeg -hwaccels
ffmpeg -encoders
echo "Running VMAF analysis with GPU decoding (this will output to null)..."
# This command uses CUDA for decoding both input files and then
# calculates VMAF using libvmaf_cuda filter.
# Ensure LD_LIBRARY_PATH is effective for this command as well.
ffmpeg -i "${HOME}/build/data/ref.mp4" -i "${HOME}/build/data/dist-x264.mp4" -filter_complex "[0:v]scale=1920:1080[ref];[1:v]scale=1920:1080[dist];[dist][ref]libvmaf" -f null -
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i "${HOME}/build/data/ref.mp4" -hwaccel cuda -hwaccel_output_format cuda -i "${HOME}/build/data/dist-x264.mp4" -filter_complex "[0:v]scale_cuda=1920:1080:format=yuv420p[ref];[1:v]scale_cuda=1920:1080:format=yuv420p[dist];[dist][ref]libvmaf_cuda" -f null -
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i "${HOME}/build/data/ref.mp4" -hwaccel cuda -hwaccel_output_format cuda -i "${HOME}/build/data/dist-nvenc.mp4" -filter_complex "[0:v]scale_cuda=1920:1080:format=yuv420p[ref];[1:v]scale_cuda=1920:1080:format=yuv420p[dist];[dist][ref]libvmaf_cuda" -f null -
echo "VMAF analysis command executed. Script will pause for 5 seconds."
sleep 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment