我的 ffmpeg 命令
command = f"ffmpeg -hwaccel cuda -loglevel error -y -i input.mp4 -filter_complex \"subtitles='subtitles.srt'\" output.mp4"
subprocess.run(command, shell=True)
给了我错误
[AVFilterGraph @ 0x5cdf3b4c7980] No option name near 'subtitles.srt'
[AVFilterGraph @ 0x5cdf3b4c7980] Error parsing a filter description around:
[AVFilterGraph @ 0x5cdf3b4c7980] Error parsing filterchain 'subtitles='subtitles.srt'' around:
Failed to set value 'subtitles='subtitles.srt'' for option 'filter_complex': Invalid argument
Error parsing global options: Invalid argument
使用此版本的ffmpeg:
ffmpeg version N-114442-g9df1182065 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04)
configuration: --enable-libharfbuzz --enable-libfreetype --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --enable-libfreetype
libavutil 59. 7.100 / 59. 7.100
libavcodec 61. 2.100 / 61. 2.100
libavformat 61. 0.100 / 61. 0.100
libavdevice 61. 0.100 / 61. 0.100
libavfilter 10. 0.100 / 10. 0.100
libswscale 8. 0.100 / 8. 0.100
libswresample 5. 0.100 / 5. 0.100
知道为什么吗?这看起来像是引号的问题,但这个完全相同的命令适用于先前版本的 ffmpeg(不使用 Cuda)。
如果您想尝试复制该问题,这是我在 google colab 上用于安装 ffmpeg 的代码(运行大约需要 24 分钟):
!apt install nvidia-driver-525
!apt install nvidia-cuda-toolkit
!mkdir ~/nvidia/
%cd ~/nvidia/
!git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
%cd nv-codec-headers
!make install
%cd ~/nvidia/
!git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/
!apt install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev
%cd ~/nvidia/ffmpeg/
!./configure --enable-libharfbuzz --enable-libfreetype --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --enable-libfreetype
!make -j $(nproc)
!ls -l ffmpeg
!./ffmpeg
!sudo make install
!ls -l /usr/local/bin/ffmpeg
!type -a ffmpeg
!echo "$PATH"
!export PATH=$PATH:/usr/local/bin
!echo "$PATH"
%cd /content