obs-ffmpeg-nvenc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /******************************************************************************
  2. Copyright (C) 2016 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include <util/darray.h>
  15. #include <util/dstr.h>
  16. #include <util/base.h>
  17. #include <media-io/video-io.h>
  18. #include <obs-module.h>
  19. #include <obs-avc.h>
  20. #include <libavutil/opt.h>
  21. #include <libavutil/pixdesc.h>
  22. #include <libavformat/avformat.h>
  23. #include "obs-ffmpeg-formats.h"
  24. #define do_log(level, format, ...) \
  25. blog(level, "[NVENC encoder: '%s'] " format, \
  26. obs_encoder_get_name(enc->encoder), ##__VA_ARGS__)
  27. #define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
  28. #define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
  29. #define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
  30. struct nvenc_encoder {
  31. obs_encoder_t *encoder;
  32. AVCodec *nvenc;
  33. AVCodecContext *context;
  34. AVFrame *vframe;
  35. DARRAY(uint8_t) buffer;
  36. uint8_t *header;
  37. size_t header_size;
  38. uint8_t *sei;
  39. size_t sei_size;
  40. int height;
  41. bool first_packet;
  42. bool initialized;
  43. };
  44. static const char *nvenc_getname(void *unused)
  45. {
  46. UNUSED_PARAMETER(unused);
  47. return "NVIDIA NVENC H.264";
  48. }
  49. static inline bool valid_format(enum video_format format)
  50. {
  51. return format == VIDEO_FORMAT_I420 || format == VIDEO_FORMAT_NV12 ||
  52. format == VIDEO_FORMAT_I444;
  53. }
  54. static void nvenc_video_info(void *data, struct video_scale_info *info)
  55. {
  56. struct nvenc_encoder *enc = data;
  57. enum video_format pref_format;
  58. pref_format = obs_encoder_get_preferred_video_format(enc->encoder);
  59. if (!valid_format(pref_format)) {
  60. pref_format = valid_format(info->format) ? info->format
  61. : VIDEO_FORMAT_NV12;
  62. }
  63. info->format = pref_format;
  64. }
  65. static bool nvenc_init_codec(struct nvenc_encoder *enc)
  66. {
  67. int ret;
  68. // avcodec_open2 will overwrite priv_data, we call this to get a
  69. // local copy of the "gpu" setting for improved error messages.
  70. int64_t gpu;
  71. if (av_opt_get_int(enc->context->priv_data, "gpu", 0, &gpu) < 0) {
  72. gpu = -1;
  73. }
  74. ret = avcodec_open2(enc->context, enc->nvenc, NULL);
  75. if (ret < 0) {
  76. // if we were a fallback from jim-nvenc, there may already be a
  77. // more useful error returned from that, so don't overwrite.
  78. // this can be removed if / when ffmpeg fallback is removed.
  79. if (!obs_encoder_get_last_error(enc->encoder)) {
  80. struct dstr error_message = {0};
  81. dstr_copy(&error_message,
  82. obs_module_text("NVENC.Error"));
  83. dstr_replace(&error_message, "%1", av_err2str(ret));
  84. dstr_cat(&error_message, "\r\n\r\n");
  85. if (gpu > 0) {
  86. // if a non-zero GPU failed, almost always
  87. // user error. tell then to fix it.
  88. char gpu_str[16];
  89. snprintf(gpu_str, sizeof(gpu_str) - 1, "%d",
  90. (int)gpu);
  91. gpu_str[sizeof(gpu_str) - 1] = 0;
  92. dstr_cat(&error_message,
  93. obs_module_text("NVENC.BadGPUIndex"));
  94. dstr_replace(&error_message, "%1", gpu_str);
  95. } else if (ret == AVERROR_EXTERNAL) {
  96. // special case for common NVENC error
  97. dstr_cat(&error_message,
  98. obs_module_text("NVENC.GenericError"));
  99. } else {
  100. dstr_cat(&error_message,
  101. obs_module_text("NVENC.CheckDrivers"));
  102. }
  103. obs_encoder_set_last_error(enc->encoder,
  104. error_message.array);
  105. dstr_free(&error_message);
  106. }
  107. warn("Failed to open NVENC codec: %s", av_err2str(ret));
  108. return false;
  109. }
  110. enc->vframe = av_frame_alloc();
  111. if (!enc->vframe) {
  112. warn("Failed to allocate video frame");
  113. return false;
  114. }
  115. enc->vframe->format = enc->context->pix_fmt;
  116. enc->vframe->width = enc->context->width;
  117. enc->vframe->height = enc->context->height;
  118. enc->vframe->colorspace = enc->context->colorspace;
  119. enc->vframe->color_range = enc->context->color_range;
  120. ret = av_frame_get_buffer(enc->vframe, base_get_alignment());
  121. if (ret < 0) {
  122. warn("Failed to allocate vframe: %s", av_err2str(ret));
  123. return false;
  124. }
  125. enc->initialized = true;
  126. return true;
  127. }
  128. enum RC_MODE { RC_MODE_CBR, RC_MODE_VBR, RC_MODE_CQP, RC_MODE_LOSSLESS };
  129. static bool nvenc_update(void *data, obs_data_t *settings)
  130. {
  131. struct nvenc_encoder *enc = data;
  132. const char *rc = obs_data_get_string(settings, "rate_control");
  133. int bitrate = (int)obs_data_get_int(settings, "bitrate");
  134. int cqp = (int)obs_data_get_int(settings, "cqp");
  135. int keyint_sec = (int)obs_data_get_int(settings, "keyint_sec");
  136. const char *preset = obs_data_get_string(settings, "preset");
  137. const char *profile = obs_data_get_string(settings, "profile");
  138. int gpu = (int)obs_data_get_int(settings, "gpu");
  139. bool cbr_override = obs_data_get_bool(settings, "cbr");
  140. int bf = (int)obs_data_get_int(settings, "bf");
  141. video_t *video = obs_encoder_video(enc->encoder);
  142. const struct video_output_info *voi = video_output_get_info(video);
  143. struct video_scale_info info;
  144. /* XXX: "cbr" setting has been deprecated */
  145. if (cbr_override) {
  146. warn("\"cbr\" setting has been deprecated for all encoders! "
  147. "Please set \"rate_control\" to \"CBR\" instead. "
  148. "Forcing CBR mode. "
  149. "(Note to all: this is why you shouldn't use strings for "
  150. "common settings)");
  151. rc = "CBR";
  152. }
  153. info.format = voi->format;
  154. info.colorspace = voi->colorspace;
  155. info.range = voi->range;
  156. bool twopass = false;
  157. if (astrcmpi(preset, "mq") == 0) {
  158. twopass = true;
  159. preset = "hq";
  160. }
  161. nvenc_video_info(enc, &info);
  162. av_opt_set_int(enc->context->priv_data, "cbr", false, 0);
  163. av_opt_set(enc->context->priv_data, "profile", profile, 0);
  164. av_opt_set(enc->context->priv_data, "preset", preset, 0);
  165. if (astrcmpi(rc, "cqp") == 0) {
  166. bitrate = 0;
  167. enc->context->global_quality = cqp;
  168. } else if (astrcmpi(rc, "lossless") == 0) {
  169. bitrate = 0;
  170. cqp = 0;
  171. bool hp = (astrcmpi(preset, "hp") == 0 ||
  172. astrcmpi(preset, "llhp") == 0);
  173. av_opt_set(enc->context->priv_data, "preset",
  174. hp ? "losslesshp" : "lossless", 0);
  175. } else if (astrcmpi(rc, "vbr") != 0) { /* CBR by default */
  176. av_opt_set_int(enc->context->priv_data, "cbr", true, 0);
  177. enc->context->rc_max_rate = bitrate * 1000;
  178. enc->context->rc_min_rate = bitrate * 1000;
  179. cqp = 0;
  180. }
  181. av_opt_set(enc->context->priv_data, "level", "auto", 0);
  182. av_opt_set_int(enc->context->priv_data, "2pass", twopass, 0);
  183. av_opt_set_int(enc->context->priv_data, "gpu", gpu, 0);
  184. enc->context->bit_rate = bitrate * 1000;
  185. enc->context->rc_buffer_size = bitrate * 1000;
  186. enc->context->width = obs_encoder_get_width(enc->encoder);
  187. enc->context->height = obs_encoder_get_height(enc->encoder);
  188. enc->context->time_base = (AVRational){voi->fps_den, voi->fps_num};
  189. enc->context->pix_fmt = obs_to_ffmpeg_video_format(info.format);
  190. enc->context->colorspace = info.colorspace == VIDEO_CS_709
  191. ? AVCOL_SPC_BT709
  192. : AVCOL_SPC_BT470BG;
  193. enc->context->color_range = info.range == VIDEO_RANGE_FULL
  194. ? AVCOL_RANGE_JPEG
  195. : AVCOL_RANGE_MPEG;
  196. enc->context->max_b_frames = bf;
  197. if (keyint_sec)
  198. enc->context->gop_size =
  199. keyint_sec * voi->fps_num / voi->fps_den;
  200. else
  201. enc->context->gop_size = 250;
  202. enc->height = enc->context->height;
  203. info("settings:\n"
  204. "\trate_control: %s\n"
  205. "\tbitrate: %d\n"
  206. "\tcqp: %d\n"
  207. "\tkeyint: %d\n"
  208. "\tpreset: %s\n"
  209. "\tprofile: %s\n"
  210. "\twidth: %d\n"
  211. "\theight: %d\n"
  212. "\t2-pass: %s\n"
  213. "\tb-frames: %d\n"
  214. "\tGPU: %d\n",
  215. rc, bitrate, cqp, enc->context->gop_size, preset, profile,
  216. enc->context->width, enc->context->height,
  217. twopass ? "true" : "false", enc->context->max_b_frames, gpu);
  218. return nvenc_init_codec(enc);
  219. }
  220. static bool nvenc_reconfigure(void *data, obs_data_t *settings)
  221. {
  222. #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58, 19, 101)
  223. struct nvenc_encoder *enc = data;
  224. int bitrate = (int)obs_data_get_int(settings, "bitrate");
  225. const char *rc = obs_data_get_string(settings, "rate_control");
  226. bool cbr = astrcmpi(rc, "CBR") == 0;
  227. bool vbr = astrcmpi(rc, "VBR") == 0;
  228. if (cbr || vbr) {
  229. enc->context->bit_rate = bitrate * 1000;
  230. enc->context->rc_max_rate = bitrate * 1000;
  231. }
  232. #endif
  233. return true;
  234. }
  235. static void nvenc_destroy(void *data)
  236. {
  237. struct nvenc_encoder *enc = data;
  238. if (enc->initialized) {
  239. AVPacket pkt = {0};
  240. int r_pkt = 1;
  241. while (r_pkt) {
  242. #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
  243. if (avcodec_receive_packet(enc->context, &pkt) < 0)
  244. break;
  245. #else
  246. if (avcodec_encode_video2(enc->context, &pkt, NULL,
  247. &r_pkt) < 0)
  248. break;
  249. #endif
  250. if (r_pkt)
  251. av_packet_unref(&pkt);
  252. }
  253. }
  254. avcodec_close(enc->context);
  255. av_frame_unref(enc->vframe);
  256. av_frame_free(&enc->vframe);
  257. da_free(enc->buffer);
  258. bfree(enc->header);
  259. bfree(enc->sei);
  260. bfree(enc);
  261. }
  262. static void *nvenc_create(obs_data_t *settings, obs_encoder_t *encoder)
  263. {
  264. struct nvenc_encoder *enc;
  265. #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58, 9, 100)
  266. avcodec_register_all();
  267. #endif
  268. enc = bzalloc(sizeof(*enc));
  269. enc->encoder = encoder;
  270. enc->nvenc = avcodec_find_encoder_by_name("h264_nvenc");
  271. if (!enc->nvenc)
  272. enc->nvenc = avcodec_find_encoder_by_name("nvenc_h264");
  273. enc->first_packet = true;
  274. blog(LOG_INFO, "---------------------------------");
  275. if (!enc->nvenc) {
  276. obs_encoder_set_last_error(encoder,
  277. "Couldn't find NVENC encoder");
  278. warn("Couldn't find encoder");
  279. goto fail;
  280. }
  281. enc->context = avcodec_alloc_context3(enc->nvenc);
  282. if (!enc->context) {
  283. warn("Failed to create codec context");
  284. goto fail;
  285. }
  286. if (!nvenc_update(enc, settings))
  287. goto fail;
  288. return enc;
  289. fail:
  290. nvenc_destroy(enc);
  291. return NULL;
  292. }
  293. static inline void copy_data(AVFrame *pic, const struct encoder_frame *frame,
  294. int height, enum AVPixelFormat format)
  295. {
  296. int h_chroma_shift, v_chroma_shift;
  297. av_pix_fmt_get_chroma_sub_sample(format, &h_chroma_shift,
  298. &v_chroma_shift);
  299. for (int plane = 0; plane < MAX_AV_PLANES; plane++) {
  300. if (!frame->data[plane])
  301. continue;
  302. int frame_rowsize = (int)frame->linesize[plane];
  303. int pic_rowsize = pic->linesize[plane];
  304. int bytes = frame_rowsize < pic_rowsize ? frame_rowsize
  305. : pic_rowsize;
  306. int plane_height = height >> (plane ? v_chroma_shift : 0);
  307. for (int y = 0; y < plane_height; y++) {
  308. int pos_frame = y * frame_rowsize;
  309. int pos_pic = y * pic_rowsize;
  310. memcpy(pic->data[plane] + pos_pic,
  311. frame->data[plane] + pos_frame, bytes);
  312. }
  313. }
  314. }
  315. static bool nvenc_encode(void *data, struct encoder_frame *frame,
  316. struct encoder_packet *packet, bool *received_packet)
  317. {
  318. struct nvenc_encoder *enc = data;
  319. AVPacket av_pkt = {0};
  320. int got_packet;
  321. int ret;
  322. av_init_packet(&av_pkt);
  323. copy_data(enc->vframe, frame, enc->height, enc->context->pix_fmt);
  324. enc->vframe->pts = frame->pts;
  325. #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
  326. ret = avcodec_send_frame(enc->context, enc->vframe);
  327. if (ret == 0)
  328. ret = avcodec_receive_packet(enc->context, &av_pkt);
  329. got_packet = (ret == 0);
  330. if (ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
  331. ret = 0;
  332. #else
  333. ret = avcodec_encode_video2(enc->context, &av_pkt, enc->vframe,
  334. &got_packet);
  335. #endif
  336. if (ret < 0) {
  337. warn("nvenc_encode: Error encoding: %s", av_err2str(ret));
  338. return false;
  339. }
  340. if (got_packet && av_pkt.size) {
  341. if (enc->first_packet) {
  342. uint8_t *new_packet;
  343. size_t size;
  344. enc->first_packet = false;
  345. obs_extract_avc_headers(av_pkt.data, av_pkt.size,
  346. &new_packet, &size,
  347. &enc->header, &enc->header_size,
  348. &enc->sei, &enc->sei_size);
  349. da_copy_array(enc->buffer, new_packet, size);
  350. bfree(new_packet);
  351. } else {
  352. da_copy_array(enc->buffer, av_pkt.data, av_pkt.size);
  353. }
  354. packet->pts = av_pkt.pts;
  355. packet->dts = av_pkt.dts;
  356. packet->data = enc->buffer.array;
  357. packet->size = enc->buffer.num;
  358. packet->type = OBS_ENCODER_VIDEO;
  359. packet->keyframe = obs_avc_keyframe(packet->data, packet->size);
  360. *received_packet = true;
  361. } else {
  362. *received_packet = false;
  363. }
  364. av_packet_unref(&av_pkt);
  365. return true;
  366. }
  367. void nvenc_defaults(obs_data_t *settings)
  368. {
  369. obs_data_set_default_int(settings, "bitrate", 2500);
  370. obs_data_set_default_int(settings, "max_bitrate", 5000);
  371. obs_data_set_default_int(settings, "keyint_sec", 0);
  372. obs_data_set_default_int(settings, "cqp", 20);
  373. obs_data_set_default_string(settings, "rate_control", "CBR");
  374. obs_data_set_default_string(settings, "preset", "hq");
  375. obs_data_set_default_string(settings, "profile", "high");
  376. obs_data_set_default_bool(settings, "psycho_aq", true);
  377. obs_data_set_default_int(settings, "gpu", 0);
  378. obs_data_set_default_int(settings, "bf", 2);
  379. }
  380. static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p,
  381. obs_data_t *settings)
  382. {
  383. const char *rc = obs_data_get_string(settings, "rate_control");
  384. bool cqp = astrcmpi(rc, "CQP") == 0;
  385. bool vbr = astrcmpi(rc, "VBR") == 0;
  386. bool lossless = astrcmpi(rc, "lossless") == 0;
  387. size_t count;
  388. p = obs_properties_get(ppts, "bitrate");
  389. obs_property_set_visible(p, !cqp && !lossless);
  390. p = obs_properties_get(ppts, "max_bitrate");
  391. obs_property_set_visible(p, vbr);
  392. p = obs_properties_get(ppts, "cqp");
  393. obs_property_set_visible(p, cqp);
  394. p = obs_properties_get(ppts, "preset");
  395. count = obs_property_list_item_count(p);
  396. for (size_t i = 0; i < count; i++) {
  397. bool compatible = (i == 0 || i == 3);
  398. obs_property_list_item_disable(p, i, lossless && !compatible);
  399. }
  400. return true;
  401. }
  402. obs_properties_t *nvenc_properties_internal(bool ffmpeg)
  403. {
  404. obs_properties_t *props = obs_properties_create();
  405. obs_property_t *p;
  406. p = obs_properties_add_list(props, "rate_control",
  407. obs_module_text("RateControl"),
  408. OBS_COMBO_TYPE_LIST,
  409. OBS_COMBO_FORMAT_STRING);
  410. obs_property_list_add_string(p, "CBR", "CBR");
  411. obs_property_list_add_string(p, "CQP", "CQP");
  412. obs_property_list_add_string(p, "VBR", "VBR");
  413. obs_property_list_add_string(p, obs_module_text("Lossless"),
  414. "lossless");
  415. obs_property_set_modified_callback(p, rate_control_modified);
  416. p = obs_properties_add_int(props, "bitrate", obs_module_text("Bitrate"),
  417. 50, 300000, 50);
  418. obs_property_int_set_suffix(p, " Kbps");
  419. p = obs_properties_add_int(props, "max_bitrate",
  420. obs_module_text("MaxBitrate"), 50, 300000,
  421. 50);
  422. obs_property_int_set_suffix(p, " Kbps");
  423. obs_properties_add_int(props, "cqp", obs_module_text("NVENC.CQLevel"),
  424. 1, 30, 1);
  425. obs_properties_add_int(props, "keyint_sec",
  426. obs_module_text("KeyframeIntervalSec"), 0, 10,
  427. 1);
  428. p = obs_properties_add_list(props, "preset", obs_module_text("Preset"),
  429. OBS_COMBO_TYPE_LIST,
  430. OBS_COMBO_FORMAT_STRING);
  431. #define add_preset(val) \
  432. obs_property_list_add_string(p, obs_module_text("NVENC.Preset." val), \
  433. val)
  434. add_preset("mq");
  435. add_preset("hq");
  436. add_preset("default");
  437. add_preset("hp");
  438. add_preset("ll");
  439. add_preset("llhq");
  440. add_preset("llhp");
  441. #undef add_preset
  442. p = obs_properties_add_list(props, "profile",
  443. obs_module_text("Profile"),
  444. OBS_COMBO_TYPE_LIST,
  445. OBS_COMBO_FORMAT_STRING);
  446. #define add_profile(val) obs_property_list_add_string(p, val, val)
  447. add_profile("high");
  448. add_profile("main");
  449. add_profile("baseline");
  450. #undef add_profile
  451. if (!ffmpeg) {
  452. p = obs_properties_add_bool(props, "lookahead",
  453. obs_module_text("NVENC.LookAhead"));
  454. obs_property_set_long_description(
  455. p, obs_module_text("NVENC.LookAhead.ToolTip"));
  456. p = obs_properties_add_bool(
  457. props, "psycho_aq",
  458. obs_module_text("NVENC.PsychoVisualTuning"));
  459. obs_property_set_long_description(
  460. p, obs_module_text("NVENC.PsychoVisualTuning.ToolTip"));
  461. }
  462. obs_properties_add_int(props, "gpu", obs_module_text("GPU"), 0, 8, 1);
  463. obs_properties_add_int(props, "bf", obs_module_text("BFrames"), 0, 4,
  464. 1);
  465. return props;
  466. }
  467. obs_properties_t *nvenc_properties(void *unused)
  468. {
  469. UNUSED_PARAMETER(unused);
  470. return nvenc_properties_internal(false);
  471. }
  472. obs_properties_t *nvenc_properties_ffmpeg(void *unused)
  473. {
  474. UNUSED_PARAMETER(unused);
  475. return nvenc_properties_internal(true);
  476. }
  477. static bool nvenc_extra_data(void *data, uint8_t **extra_data, size_t *size)
  478. {
  479. struct nvenc_encoder *enc = data;
  480. *extra_data = enc->header;
  481. *size = enc->header_size;
  482. return true;
  483. }
  484. static bool nvenc_sei_data(void *data, uint8_t **extra_data, size_t *size)
  485. {
  486. struct nvenc_encoder *enc = data;
  487. *extra_data = enc->sei;
  488. *size = enc->sei_size;
  489. return true;
  490. }
  491. struct obs_encoder_info nvenc_encoder_info = {
  492. .id = "ffmpeg_nvenc",
  493. .type = OBS_ENCODER_VIDEO,
  494. .codec = "h264",
  495. .get_name = nvenc_getname,
  496. .create = nvenc_create,
  497. .destroy = nvenc_destroy,
  498. .encode = nvenc_encode,
  499. .update = nvenc_reconfigure,
  500. .get_defaults = nvenc_defaults,
  501. .get_properties = nvenc_properties_ffmpeg,
  502. .get_extra_data = nvenc_extra_data,
  503. .get_sei_data = nvenc_sei_data,
  504. .get_video_info = nvenc_video_info,
  505. #ifdef _WIN32
  506. .caps = OBS_ENCODER_CAP_DYN_BITRATE | OBS_ENCODER_CAP_INTERNAL,
  507. #else
  508. .caps = OBS_ENCODER_CAP_DYN_BITRATE,
  509. #endif
  510. };