使用 Nvidia GPU 加速的 Ffmpeg 帧提取抛出 "Output file #0 does not contain any stream"
Ffmpeg frame extraction with Nvidia GPU acceleration throws "Output file #0 does not contain any stream"
我正在尝试将 nvidia gpu 加速解码器 api 与 ffmpeg 一起使用,以将视频文件 (.MTS
) 中的所有帧提取到文件夹中,但由于某种原因它似乎失败了;我找不到答案或类似问题。
使用的命令:
ffmpeg -vsync 0 -hwaccel cuvid -c:v mpeg2_cuvid -i raw_video.MTS -q:v 2 -f image2 output_folder/image_%05d.jpg
回溯:
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Arch Linux 9.3.0-1)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mpegts @ 0x563fcc5616c0] start time for stream 0 is not set in estimate_timings_from_pts
[mpegts @ 0x563fcc5616c0] PES packet size mismatch
[mpegts @ 0x563fcc5616c0] Could not find codec parameters for stream 0 (Video: mpeg2video (HDMV / 0x564D4448), none(tv)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'raw_video.MTS':
Duration: 00:07:15.68, start: 1010.210356, bitrate: 41186 kb/s
Program 1
Stream #0:0[0x1011]: Video: mpeg2video (HDMV / 0x564D4448), none(tv), 90k tbr, 90k tbn, 90k tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Output #0, image2, to 'output_folder/image_%05d.jpg':
Output file #0 does not contain any stream
我很确定 -hwaccel cuvid -c:v mpeg2_cuvid
是正确的,因为文件属性中的文件类型似乎是 MPEG-2,但其他 cuvid 解码器也会出现类似问题:
我也尝试过 运行 没有 -c:v
标志,但是随后出现了一个 cuda 错误并且 运行s 在 cpu:
[h264 @ 0x55949e6d7e00] decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[h264 @ 0x55949e6d7e00] Failed setup for format cuda: hwaccel initialisation returned error.
任何帮助将不胜感激。
编辑:
- OS:拱门Linux
- 显卡:英伟达 1050Ti
- CUDA 版本:10.2
- NVIDIA-SMI:440.82
编辑 2:
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Arch Linux 9.3.0-1)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[mpegts @ 0x55714390c540] PES packet size mismatch
Input #0, mpegts, from 'raw_video.MTS':
Duration: 00:18:30.97, start: 113.284733, bitrate: 16850 kb/s
Program 1
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
At least one output file must be specified
视频编解码器实际上是h264
。 MPEG2-TS 是一种 container/packaging 格式,不需要只包含 MPEG-2 视频流。
使用 cuvid
等硬件解码器解码视频时,解码帧在硬件设备内存中采用特定于硬件的数据布局。在将它们传输到系统内存之前,需要将它们转换为可接受的布局。
添加过滤器 hwdownload 以将帧复制到系统内存,然后立即添加格式过滤器以指定 hwdownload 的下载格式。 nv12
是 yuv420p
的一个变体,在 ffmpeg 中可以进行 hW->SW 转换。
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i raw_video.MTS -vf hwdownload,format=nv12 -vsync 0 -q:v 2 -f image2 output_folder/image_%05d.jpg
我正在尝试将 nvidia gpu 加速解码器 api 与 ffmpeg 一起使用,以将视频文件 (.MTS
) 中的所有帧提取到文件夹中,但由于某种原因它似乎失败了;我找不到答案或类似问题。
使用的命令:
ffmpeg -vsync 0 -hwaccel cuvid -c:v mpeg2_cuvid -i raw_video.MTS -q:v 2 -f image2 output_folder/image_%05d.jpg
回溯:
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Arch Linux 9.3.0-1)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[mpegts @ 0x563fcc5616c0] start time for stream 0 is not set in estimate_timings_from_pts
[mpegts @ 0x563fcc5616c0] PES packet size mismatch
[mpegts @ 0x563fcc5616c0] Could not find codec parameters for stream 0 (Video: mpeg2video (HDMV / 0x564D4448), none(tv)): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, mpegts, from 'raw_video.MTS':
Duration: 00:07:15.68, start: 1010.210356, bitrate: 41186 kb/s
Program 1
Stream #0:0[0x1011]: Video: mpeg2video (HDMV / 0x564D4448), none(tv), 90k tbr, 90k tbn, 90k tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Output #0, image2, to 'output_folder/image_%05d.jpg':
Output file #0 does not contain any stream
我很确定 -hwaccel cuvid -c:v mpeg2_cuvid
是正确的,因为文件属性中的文件类型似乎是 MPEG-2,但其他 cuvid 解码器也会出现类似问题:
我也尝试过 运行 没有 -c:v
标志,但是随后出现了一个 cuda 错误并且 运行s 在 cpu:
[h264 @ 0x55949e6d7e00] decoder->cvdl->cuvidCreateDecoder(&decoder->decoder, params) failed -> CUDA_ERROR_INVALID_VALUE: invalid argument
[h264 @ 0x55949e6d7e00] Failed setup for format cuda: hwaccel initialisation returned error.
任何帮助将不胜感激。
编辑:
- OS:拱门Linux
- 显卡:英伟达 1050Ti
- CUDA 版本:10.2
- NVIDIA-SMI:440.82
编辑 2:
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.3.0 (Arch Linux 9.3.0-1)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] SPS unavailable in decode_picture_timing
[h264 @ 0x557143911700] non-existing PPS 0 referenced
[h264 @ 0x557143911700] decode_slice_header error
[h264 @ 0x557143911700] no frame!
[mpegts @ 0x55714390c540] PES packet size mismatch
Input #0, mpegts, from 'raw_video.MTS':
Duration: 00:18:30.97, start: 113.284733, bitrate: 16850 kb/s
Program 1
Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 50 tbr, 90k tbn, 50 tbc
Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
At least one output file must be specified
视频编解码器实际上是h264
。 MPEG2-TS 是一种 container/packaging 格式,不需要只包含 MPEG-2 视频流。
使用 cuvid
等硬件解码器解码视频时,解码帧在硬件设备内存中采用特定于硬件的数据布局。在将它们传输到系统内存之前,需要将它们转换为可接受的布局。
添加过滤器 hwdownload 以将帧复制到系统内存,然后立即添加格式过滤器以指定 hwdownload 的下载格式。 nv12
是 yuv420p
的一个变体,在 ffmpeg 中可以进行 hW->SW 转换。
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i raw_video.MTS -vf hwdownload,format=nv12 -vsync 0 -q:v 2 -f image2 output_folder/image_%05d.jpg