Conversation
source/encoder.cpp: Added GPU field selection to Software encoders locale: Added label and description for GPU field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes, but otherwise fine.
data/locale/en-US.ini
Outdated
@@ -20,6 +20,9 @@ FFmpeg.StandardCompliance.Strict="Strict" | |||
FFmpeg.StandardCompliance.Normal="Normal" | |||
FFmpeg.StandardCompliance.Unofficial="Unofficial" | |||
FFmpeg.StandardCompliance.Experimental="Experimental" | |||
FFmpeg.gpu="GPU" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GPU should be uppercase as "gpu" is not a word.
data/locale/en-US.ini
Outdated
@@ -20,6 +20,9 @@ FFmpeg.StandardCompliance.Strict="Strict" | |||
FFmpeg.StandardCompliance.Normal="Normal" | |||
FFmpeg.StandardCompliance.Unofficial="Unofficial" | |||
FFmpeg.StandardCompliance.Experimental="Experimental" | |||
FFmpeg.gpu="GPU" | |||
FFmpeg.gpu.Description="For multiple GPU, selects which gpu to use as the main encoder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as other comment.
source/encoder.cpp
Outdated
@@ -64,6 +64,7 @@ extern "C" { | |||
#define ST_FFMPEG_THREADS "FFmpeg.Threads" | |||
#define ST_FFMPEG_COLORFORMAT "FFmpeg.ColorFormat" | |||
#define ST_FFMPEG_STANDARDCOMPLIANCE "FFmpeg.StandardCompliance" | |||
#define ST_FFMPEG_GPU "FFmpeg.gpu" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as other comment.
source/encoder.cpp
Outdated
@@ -555,6 +557,10 @@ void obsffmpeg::encoder_factory::get_properties(obs_properties_t* props, bool hw | |||
obs_property_set_long_description(p, TRANSLATE(DESC(ST_FFMPEG_CUSTOMSETTINGS))); | |||
} | |||
if (!hw_encode) { | |||
{ | |||
auto p = obs_properties_add_int(grp, ST_FFMPEG_GPU, TRANSLATE(ST_FFMPEG_GPU), 0, std::numeric_limits<int16_t>::max(), 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be limited to uint8_t::max instead. I doubt someone will get 32676 GPUs in a single system - even with the best PCI-E splitters, you'd at most only get 192 to 256 GPUs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory the maximum number of GPUs you can get are 13 straight GPUs but only 9 of those can be nVidia. I like 256 value :)
but this value was lifted from the obs-ffmpeg standard plugin, though sure I will change it and update this.
source/encoder.cpp
Outdated
@@ -930,6 +939,9 @@ bool obsffmpeg::encoder::update(obs_data_t* settings) | |||
_context->keyint_min = _context->gop_size; | |||
} | |||
|
|||
if (!_hwinst) | |||
av_opt_set_int(_context->priv_data, "gpu", (int)obs_data_get_int(settings, ST_FFMPEG_GPU), 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set options on _context with AV_OPT_SEARCH_CHILDREN. It works better if the encoder and FFmpeg have the same property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also based upon the obs-ffmpeg standard plugin, but sure, I'll set the Search clildren option.
Should this point to _context
instead of _context->priv_data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it should point to _context. AV_OPT_SEARCH_CHILDREN makes it descend into _context->priv_data by itself, so when options move from encoder to ffmpeg or ffmpeg to encoder things still work as expected.
locale: Matched variable case and corrected narration a little bit
Description
locale: Added the text for the label and description for the GPU field.
source/encoder.cpp: Added the label, entry point, settings and rules to enable GPU selection on the field.
source/encoder.cpp: Added error look up to show a more understandable message to the user
Motivation and Context
Finding out what parameters to use in the custom field has always been a complicated task https://github.com/Xaymar/obs-ffmpeg-encoder/issues/12 even in the Custom ffmpeg plugin that comes standard with OBS. Since this plug in is meant to solve the complications out of configuring the NVENC encoders in OBS, as such it felt at home to add the possiblity to select the GPU from a simple to use interface.
How Has This Been Tested?
I have used those changes in a local OBS setup
Types of changes
New feature
Checklist: