Quantcast
Channel: Active questions tagged windows - Super User
Viewing all articles
Browse latest Browse all 9273

D3D11 hardware screen recording with ffmpeg using Intel H264 QSV hardware encoding

$
0
0

I'm trying to screen record using ffmpeg and having it all done via hardware on my Intel integrated graphics.

Specs

For reference, here are my specs:

  • Windows 11 Pro Version 10.0.22631 Build 22631
  • Model: Dell Inc. OptiPlex 3090
  • Processor: 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz, 2995 Mhz, 2 Core(s), 4 Logical Processor(s)
  • Terminal: Windows Terminal using Windows Powershell

In this wiki, it looked like I could use the "Windows 8+ Desktop Duplication API" to be "directly encoded by a compatible hardware encoder" — so I thought that I could use h264_qsv to encode, allowing me to record without much performance overhead costs.

Attempt 1

I've tried copying one of the command examples, but it didn't work:

ffmpeg -init_hw_device d3d11va -filter_complex ddagrab=0 

Output:

ffmpeg version 2024-05-02-git-71669f2ad5-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint  libavutil      59. 16.101 / 59. 16.101  libavcodec     61.  5.103 / 61.  5.103  libavformat    61.  3.103 / 61.  3.103  libavdevice    61.  2.100 / 61.  2.100  libavfilter    10.  2.101 / 10.  2.101  libswscale      8.  2.100 /  8.  2.100  libswresample   5.  2.100 /  5.  2.100  libpostproc    58.  2.100 / 58.  2.100Stream mapping:  ddagrab:default -> Stream #0:0 (h264_qsv)Press [q] to stop, [?] for helpImpossible to convert between the formats supported by the filter 'Parsed_ddagrab_0' and the filter 'auto_scale_0'[fc#0 @ 000001e4ed4393c0] Error configuring filter graph: Function not implemented[fc#0 @ 000001e4ed4393c0] Task finished with error code: -40 (Function not implemented)[fc#0 @ 000001e4ed4393c0] Terminating thread with return code -40 (Function not implemented)[vost#0:0/h264_qsv @ 000001e4ed454000] Could not open encoder before EOF[vost#0:0/h264_qsv @ 000001e4ed454000] Task finished with error code: -22 (Invalid argument)[vost#0:0/h264_qsv @ 000001e4ed454000] Terminating thread with return code -22 (Invalid argument)[out#0/matroska @ 000001e4ed453280] Nothing was written into output file, because at least one of its streams received no packets.frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/AConversion failed!

Attempt 2

I then tried copying one of the command examples in the linked ddagrab wiki page, but also no luck.

ffmpeg -f lavfi -i ddagrab -c:v h264_qsv output.mkv

Output:

ffmpeg version 2024-05-02-git-71669f2ad5-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint  libavutil      59. 16.101 / 59. 16.101  libavcodec     61.  5.103 / 61.  5.103  libavformat    61.  3.103 / 61.  3.103  libavdevice    61.  2.100 / 61.  2.100  libavfilter    10.  2.101 / 10.  2.101  libswscale      8.  2.100 /  8.  2.100  libswresample   5.  2.100 /  5.  2.100  libpostproc    58.  2.100 / 58.  2.100Input #0, lavfi, from 'ddagrab':  Duration: N/A, start: 0.000000, bitrate: N/A  Stream #0:0: Video: wrapped_avframe, d3d11, 1920x1080 [SAR 1:1 DAR 16:9], 30 fps, 30 tbr, 1000k tbnFile 'output.mkv' already exists. Overwrite? [y/N] yStream mapping:  Stream #0:0 -> #0:0 (wrapped_avframe (native) -> h264 (h264_qsv))Press [q] to stop, [?] for helpImpossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scale_0'[vf#0:0 @ 00000115e105bd40] Error reinitializing filters![vf#0:0 @ 00000115e105bd40] Task finished with error code: -40 (Function not implemented)[vf#0:0 @ 00000115e105bd40] Terminating thread with return code -40 (Function not implemented)[vost#0:0/h264_qsv @ 00000115e105aa00] Could not open encoder before EOF[vost#0:0/h264_qsv @ 00000115e105aa00] Task finished with error code: -22 (Invalid argument)[vost#0:0/h264_qsv @ 00000115e105aa00] Terminating thread with return code -22 (Invalid argument)[out#0/matroska @ 00000115e1054b80] Nothing was written into output file, because at least one of its streams received no packets.frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/AConversion failed!

My main problem is that I don't know how to use really any of these encoders and the examples I've found above don't work with me. What command should I use to screen record all with hardware acceleration on my Intel system? I don't care about any presets or other options at the moment.

Is there also a way to record audio? When I tried to use -f dshow -i audio="Stereo Mix (Realtek(R) Audio)" by itself, which I made sure was turned on in Windows' settings and named correctly, it didn't work (is it because I'm using Bluetooth headphones that isn't connected to Realtek's system?). Should this question be made separately than this one?


Viewing all articles
Browse latest Browse all 9273

Trending Articles