Question / Help How do I use second gpu when recording in H264_nvec?

Justcampus

New Member
Hello!
I tried to find correct video encoder settings for obs custom ffmpeg but I couldn't find any.

These are the settings what I tried to use
d4wEQYN.png


Code:
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/themes/Default.qss
Attempted path: /usr/share/obs/obs-studio/themes/Default.qss
Attempted path: share/obs/obs-studio/license/gplv2.txt
Attempted path: /usr/share/obs/obs-studio/license/gplv2.txt
info: Processor: 4 logical cores
info: Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
info: Physical Memory: 16010MB Total
info: Kernel Version: Linux 4.11.2-1-ARCH
info: Distribution: "Arch Linux" Unknown
info: Portable mode: false
info: OBS 18.0.2-1 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
    samples per sec: 48000
    speakers:        2
info: ---------------------------------
info: Initializing OpenGL...
info: OpenGL version: 3.2.0 NVIDIA 381.22
info: ---------------------------------
info: video settings reset:
    base resolution:   3840x2160
    output resolution: 3840x2160
    downscale filter:  Bilinear
    fps:               8/1
    format:            NV12
info: ---------------------------------
libDeckLinkAPI.so: cannot open shared object file: No such file or directory
info: No blackmagic support
info: NVENC supported
info: ---------------------------------
info:   Loaded Modules:
info:     text-freetype2.so
info:     rtmp-services.so
info:     obs-x264.so
info:     obs-transitions.so
info:     obs-outputs.so
info:     obs-libfdk.so
info:     obs-filters.so
info:     obs-ffmpeg.so
info:     linux-v4l2.so
info:     linux-pulseaudio.so
info:     linux-jack.so
info:     linux-decklink.so
info:     linux-capture.so
info:     linux-alsa.so
info:     image-source.so
info:     frontend-tools.so
info: ==== Startup complete ===============================================
error: Service '' not found
info: All scene data cleared
info: ------------------------------------------------
info: pulse-input: Server name: 'pulseaudio 10.0'
info: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
info: pulse-input: Started recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
info: pulse-input: Server name: 'pulseaudio 10.0'
error: pulse-input: An error occurred while getting the source info!
info: xshm-input: Geometry 3840x2160 @ 1920,0
info: Switched to scene 'Scene'
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info:     - source: 'Screen Capture (XSHM)' (xshm_input)
info: ------------------------------------------------
info: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds
info: adding 21 milliseconds of audio buffering, total audio buffering is now 42 milliseconds
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: ==== Recording Start ===============================================
Attempted path: share/obs/obs-studio/locale.ini
Attempted path: /usr/share/obs/obs-studio/locale.ini
Attempted path: share/obs/obs-studio/themes/
Attempted path: /usr/share/obs/obs-studio/themes/
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: Settings changed (outputs)
info: ------------------------------------------------
^C
[campus@pomper Desktop]$ obs
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/themes/Default.qss
Attempted path: /usr/share/obs/obs-studio/themes/Default.qss
Attempted path: share/obs/obs-studio/license/gplv2.txt
Attempted path: /usr/share/obs/obs-studio/license/gplv2.txt
info: Processor: 4 logical cores
info: Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
info: Physical Memory: 16010MB Total
info: Kernel Version: Linux 4.11.2-1-ARCH
info: Distribution: "Arch Linux" Unknown
info: Portable mode: false
info: OBS 18.0.2-1 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
    samples per sec: 48000
    speakers:        2
info: ---------------------------------
info: Initializing OpenGL...
info: OpenGL version: 3.2.0 NVIDIA 381.22
info: ---------------------------------
info: video settings reset:
    base resolution:   3840x2160
    output resolution: 3840x2160
    downscale filter:  Bilinear
    fps:               8/1
    format:            NV12
info: ---------------------------------
libDeckLinkAPI.so: cannot open shared object file: No such file or directory
info: No blackmagic support
info: NVENC supported
info: ---------------------------------
info:   Loaded Modules:
info:     text-freetype2.so
info:     rtmp-services.so
info:     obs-x264.so
info:     obs-transitions.so
info:     obs-outputs.so
info:     obs-libfdk.so
info:     obs-filters.so
info:     obs-ffmpeg.so
info:     linux-v4l2.so
info:     linux-pulseaudio.so
info:     linux-jack.so
info:     linux-decklink.so
info:     linux-capture.so
info:     linux-alsa.so
info:     image-source.so
info:     frontend-tools.so
info: ==== Startup complete ===============================================
error: Service '' not found
info: All scene data cleared
info: ------------------------------------------------
info: pulse-input: Server name: 'pulseaudio 10.0'
info: pulse-input: Audio format: s16le, 44100 Hz, 2 channels
info: pulse-input: Started recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
info: pulse-input: Server name: 'pulseaudio 10.0'
error: pulse-input: An error occurred while getting the source info!
info: xshm-input: Geometry 3840x2160 @ 1920,0
info: Switched to scene 'Scene'
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info:     - source: 'Screen Capture (XSHM)' (xshm_input)
info: ------------------------------------------------
info: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds
info: adding 21 milliseconds of audio buffering, total audio buffering is now 42 milliseconds
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: ==== Recording Start ===============================================
Attempted path: share/obs/obs-studio/locale.ini
Attempted path: /usr/share/obs/obs-studio/locale.ini
Attempted path: share/obs/obs-studio/themes/
Attempted path: /usr/share/obs/obs-studio/themes/
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: Output 'adv_ffmpeg_output': stopping
info: Output 'adv_ffmpeg_output': Total encoded frames: 734
info: Output 'adv_ffmpeg_output': Total drawn frames: 734
info: ==== Recording Stop ================================================
Attempted path: share/obs/obs-studio/locale.ini
Attempted path: /usr/share/obs/obs-studio/locale.ini
Attempted path: share/obs/obs-studio/themes/
Attempted path: /usr/share/obs/obs-studio/themes/
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''
warning: rtmp-common.c: [initialize_output] Could not find service ''

It works fine and quality looks good, but I would like to use secondary graphics card (gpu 1) to record videos. I am using gigabyte H motherboard so those two gtx 660 aren't in SLI. I use such low fps because I record timelapses.
 

kiroma

New Member
This is weird...
I have no problem changing this option in my build of OBS v19.0.1.
Could you please try updating your software?

Also, can you change the type from "Custom output (FFmpeg)" to Standard?
 

Justcampus

New Member
This is weird...
I have no problem changing this option in my build of OBS v19.0.1.
Could you please try updating your software?

Also, can you change the type from "Custom output (FFmpeg)" to Standard?

When I tried to record in NVENC H.264 in Standard mode it gives this:
K8VB57l.png


Code:
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/themes/Default.qss
Attempted path: /usr/share/obs/obs-studio/themes/Default.qss
Attempted path: share/obs/obs-studio/license/gplv2.txt
Attempted path: /usr/share/obs/obs-studio/license/gplv2.txt
info: Processor: 4 logical cores
info: Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
info: Physical Memory: 16010MB Total
info: Kernel Version: Linux 4.11.2-1-ARCH
info: Distribution: "Arch Linux" Unknown
info: Portable mode: false
info: OBS 19.0.2-1 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
   samples per sec: 48000
   speakers:  2
info: ---------------------------------
info: Initializing OpenGL...
info: OpenGL version: 3.2.0 NVIDIA 381.22
info: ---------------------------------
info: video settings reset:
   base resolution:  3840x2160
   output resolution: 3840x2160
   downscale filter:  Bilinear
   fps:  60/8
   format:  NV12
info: ---------------------------------
libDeckLinkAPI.so: cannot open shared object file: No such file or directory
info: No blackmagic support
info: NVENC supported
info: ---------------------------------
info:  Loaded Modules:
info:  text-freetype2.so
info:  rtmp-services.so
info:  obs-x264.so
info:  obs-transitions.so
info:  obs-outputs.so
info:  obs-libfdk.so
info:  obs-filters.so
info:  obs-ffmpeg.so
info:  linux-v4l2.so
info:  linux-pulseaudio.so
info:  linux-jack.so
info:  linux-decklink.so
info:  linux-capture.so
info:  linux-alsa.so
info:  image-source.so
info:  frontend-tools.so
info: ==== Startup complete ===============================================
error: Service '' not found
info: All scene data cleared
info: ------------------------------------------------
info: pulse-input: Server name: 'pulseaudio 10.0'
info: pulse-input: Audio format: s16le, 48000 Hz, 2 channels
info: pulse-input: Started recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
info: pulse-input: Server name: 'pulseaudio 10.0'
error: pulse-input: An error occurred while getting the source info!
info: xshm-input: Geometry 3840x2160 @ 1920,0
info: Switched to scene 'Scene'
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info:  - source: 'Screen Capture (XSHM)' (xshm_input)
info: ------------------------------------------------
info: adding 42 milliseconds of audio buffering, total audio buffering is now 42 milliseconds
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: ---------------------------------
info: [NVENC encoder: 'recording_h264'] settings:
   rate_control: lossless
   bitrate:  0
   cqp:  0
   keyint:  250
   preset:  hq
   profile:  high
   level:  auto
   width:  3840
   height:  2160
   2-pass:  true
   b-frames:  2
   GPU:  1

[h264_nvenc @ 0x1b6d1c0] No NVENC capable devices found
warning: [NVENC encoder: 'recording_h264'] Failed to open NVENC codec: Generic error in an external library

I am able to record with ffmpeg using:
Code:
ffmpeg -vsync passthrough -frame_drop_threshold 4 -framerate 24 -video_size 3840x2160 -f x11grab -i :0.0+1920,0 -f:1 pulse -ac 2 -i default -c:v h264_nvenc -gpu 1 -pix_fmt rgb0 -profile:v high -preset:v fast -qp:v 0 -b:v 50000k -preset fast -c:a pcm_s16le -b:a 128k ${time}.mkv
It records without dropping too many frames at once, and it uses second gpu (1) as set.


Even when I used similiar settings in OBS, it still uses gpu 0.

I can record in Standard mode with libx264, but then it will use cpu and I would rather use gpu.

Everything should be updatet according to pacman.
 

Justcampus

New Member
Well I got standard mode working now. It didn't accept "lossless" mode. Custom ffmpeg would have had more settings such as audio encoding settings.

I compared ffmpeg and obs recordings and both quality is very good with 100mb/s bitrate 24fps 4K.

OBS used about 20% more cpu than ffmpeg.

ffmpeg record setting and log:
Code:
$ ffmpeg -vsync passthrough -framerate 24 -video_size 3840x2160 -f x11grab -i :0.0+1920,0 -thread_queue_size 2048 -f:1 pulse -ac 2 -i default -c:v h264_nvenc -gpu 1 -pix_fmt rgb0 -profile:v high -preset:v fast  -cbr true -b:v 100000k -preset fast -qp 4 -c:a pcm_s16le -b:a 128k ffmhpeg.mkv
ffmpeg version 3.3.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.1 (GCC) 20170306
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxvid --enable-netcdf --enable-shared --enable-version3
  libavutil  55. 58.100 / 55. 58.100
  libavcodec  57. 89.100 / 57. 89.100
  libavformat  57. 71.100 / 57. 71.100
  libavdevice  57.  6.100 / 57.  6.100
  libavfilter  6. 82.100 /  6. 82.100
  libavresample  3.  5.  0 /  3.  5.  0
  libswscale  4.  6.100 /  4.  6.100
  libswresample  2.  7.100 /  2.  7.100
  libpostproc  54.  5.100 / 54.  5.100
[x11grab @ 0x555e17f658e0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0+1920,0':
  Duration: N/A, start: 1496161901.376530, bitrate: N/A
  Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 3840x2160, 24 fps, 1000k tbr, 1000k tbn, 1000k tbc
Guessed Channel Layout for Input Stream #1.0 : stereo
Input #1, pulse, from 'default':
  Duration: N/A, start: 1496161901.400655, bitrate: 1536 kb/s
  Stream #1:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
  Stream #1:0 -> #0:1 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, matroska, to 'ffmhpeg.mkv':
  Metadata:
  encoder  : Lavf57.71.100
  Stream #0:0: Video: h264 (h264_nvenc) (High) (H264 / 0x34363248), rgb0(progressive), 3840x2160, q=-1--1, 100000 kb/s, 24 fps, 1k tbn, 24 tbc
  Metadata:
  encoder  : Lavc57.89.100 h264_nvenc
  Side data:
  cpb: bitrate max/min/avg: 0/0/100000000 buffer size: 200000000 vbv_delay: -1
  Stream #0:1: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
  Metadata:
  encoder  : Lavc57.89.100 pcm_s16le

OBS record settings and log:
Code:
$ obs
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/themes/Default.qss
Attempted path: /usr/share/obs/obs-studio/themes/Default.qss
Attempted path: share/obs/obs-studio/license/gplv2.txt
Attempted path: /usr/share/obs/obs-studio/license/gplv2.txt
info: Processor: 4 logical cores
info: Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
info: Physical Memory: 16010MB Total
info: Kernel Version: Linux 4.11.3-1-ARCH
info: Distribution: "Arch Linux" Unknown
info: Portable mode: false
info: OBS 19.0.2-1 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
   samples per sec: 48000
   speakers:  2
info: ---------------------------------
info: Initializing OpenGL...
info: OpenGL version: 3.2.0 NVIDIA 381.22
info: ---------------------------------
info: video settings reset:
   base resolution:  3840x2160
   output resolution: 3840x2160
   downscale filter:  Bilinear
   fps:  24/1
   format:  NV12
info: ---------------------------------
libDeckLinkAPI.so: cannot open shared object file: No such file or directory
info: No blackmagic support
info: NVENC supported
info: ---------------------------------
info:  Loaded Modules:
info:  text-freetype2.so
info:  rtmp-services.so
info:  obs-x264.so
info:  obs-transitions.so
info:  obs-outputs.so
info:  obs-libfdk.so
info:  obs-filters.so
info:  obs-ffmpeg.so
info:  linux-v4l2.so
info:  linux-pulseaudio.so
info:  linux-jack.so
info:  linux-decklink.so
info:  linux-capture.so
info:  linux-alsa.so
info:  image-source.so
info:  frontend-tools.so
info: ==== Startup complete ===============================================
error: Service '' not found
info: All scene data cleared
info: ------------------------------------------------
info: pulse-input: Server name: 'pulseaudio 10.0'
info: pulse-input: Audio format: s16le, 48000 Hz, 2 channels
info: pulse-input: Started recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
info: pulse-input: Server name: 'pulseaudio 10.0'
error: pulse-input: An error occurred while getting the source info!
info: xshm-input: Geometry 3840x2160 @ 1920,0
info: Switched to scene 'Scene'
info: ------------------------------------------------
info: Loaded scenes:
info: - scene 'Scene':
info:  - source: 'Screen Capture (XSHM)' (xshm_input)
info: ------------------------------------------------
info: adding 21 milliseconds of audio buffering, total audio buffering is now 21 milliseconds
info: adding 21 milliseconds of audio buffering, total audio buffering is now 42 milliseconds
warning: rtmp-common.c: [initialize_output] Could not find service ''
info: ---------------------------------
info: [NVENC encoder: 'recording_h264'] settings:
   rate_control: CBR
   bitrate:  100000
   cqp:  0
   keyint:  250
   preset:  hp
   profile:  high
   level:  auto
   width:  3840
   height:  2160
   2-pass:  true
   b-frames:  2
   GPU:  1

Well anyways, it works now. Since ffmpeg seems to use slightly less cpu and there's a few options more, I might go with ffmpeg for now. Thanks for the answer!
 
Top