BtbN / FFmpeg-Builds

MIT License
6.97k stars 956 forks source link

nvenc not listed when running ffmpeg -hwaccels #374

Closed skier233 closed 1 month ago

skier233 commented 1 month ago

I'm trying to install ffmpeg with nvenc/nvdec support inside a conda environment but when trying to verify if the installation has nvenc support with fmpeg -hwaccels, it is not one of the listed hardware accelerators: Hardware acceleration methods: cuda vaapi dxva2 qsv d3d11va d3d12va

CUDA is installed in the conda environment and working.

Conda environment and installation script for reference in case some dependency is missing:

name: ai_model_server_experiment
channels:
  - defaults
  - pytorch
  - nvidia
dependencies:
  - python=3.11
  - pytorch=2.3.0
  - torchvision=0.18.0
  - pytorch-cuda=12.1
  - pyyaml
  - pip
  - cudnn
  - nvidia-ml-py
  - pip:
    - fastapi==0.111.0
    - uvicorn==0.29.0
    - requests
    - aiohttp

Install.ps1:

# Define the download URL for the BtbN prebuilt FFmpeg
$ffmpegUrl = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"

# Download FFmpeg
Invoke-WebRequest -Uri $ffmpegUrl -OutFile ffmpeg.zip

# Extract the zip file using built-in tools
Expand-Archive -Path ffmpeg.zip -DestinationPath .\ffmpeg

# Move ffmpeg binaries to conda environment
Copy-Item -Path .\ffmpeg\ffmpeg-*\bin\ffmpeg.exe -Destination "$env:CONDA_PREFIX\Scripts\"
Copy-Item -Path .\ffmpeg\ffmpeg-*\bin\ffprobe.exe -Destination "$env:CONDA_PREFIX\Scripts\"

# Clean up the downloaded zip and extracted files
Remove-Item -Recurse -Force .\ffmpeg
Remove-Item -Force ffmpeg.zip

# Ensure the conda environment's Scripts directory is prioritized in PATH
$env:PATH = "$env:CONDA_PREFIX\Scripts;$env:PATH"

# Verify installation using the full path
$ffmpegPath = "$env:CONDA_PREFIX\Scripts\ffmpeg.exe"
& $ffmpegPath -hwaccels

# Confirm the correct ffmpeg is being used
Get-Command ffmpeg

# Check hardware acceleration support again
ffmpeg -hwaccels
BtbN commented 1 month ago

nvenc is not a hwaccel, but an encoder.

skier233 commented 1 month ago

nvenc is not a hwaccel, but an encoder.

I see. My misunderstanding and GPT4o led me astray. I do see it in the list of encoders. Thanks for the clarififcation!

ValeZAA commented 1 month ago

It is hidden: -hwaccel nvdec

Basically almost the same as cuda, but one forces output format cuda another does not.

GPT4o was right.

BtbN commented 1 month ago

It's not hidden. nvdec is not nvenc, and nvenc is simply not a hwaccel, but an encoder.