encoder: Use ffmpeg::tools::get_error_description

This commit is contained in:
Michael Fabian 'Xaymar' Dirks
2019-11-11 21:15:56 +01:00
parent d233b52e1f
commit 05d8e74088
+19 -12
View File
@@ -558,7 +558,8 @@ void obsffmpeg::encoder_factory::get_properties(obs_properties_t* props, bool hw
} }
if (!hw_encode) { if (!hw_encode) {
{ {
auto p = obs_properties_add_int(grp, ST_FFMPEG_GPU, TRANSLATE(ST_FFMPEG_GPU), 0, std::numeric_limits<uint8_t>::max(), 1); auto p = obs_properties_add_int(grp, ST_FFMPEG_GPU, TRANSLATE(ST_FFMPEG_GPU), 0,
std::numeric_limits<uint8_t>::max(), 1);
obs_property_set_long_description(p, TRANSLATE(DESC(ST_FFMPEG_GPU))); obs_property_set_long_description(p, TRANSLATE(DESC(ST_FFMPEG_GPU)));
} }
if (avcodec_ptr->pix_fmts) { if (avcodec_ptr->pix_fmts) {
@@ -885,7 +886,6 @@ void obsffmpeg::encoder::get_properties(obs_properties_t* props, bool hw_encode)
obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_THREADS), false); obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_THREADS), false);
obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_STANDARDCOMPLIANCE), false); obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_STANDARDCOMPLIANCE), false);
obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_GPU), false); obs_property_set_enabled(obs_properties_get(props, ST_FFMPEG_GPU), false);
} }
bool obsffmpeg::encoder::update(obs_data_t* settings) bool obsffmpeg::encoder::update(obs_data_t* settings)
@@ -1011,13 +1011,13 @@ bool obsffmpeg::encoder::update(obs_data_t* settings)
} else { } else {
value = std::string(&opts[p_value], &opts[p]); value = std::string(&opts[p_value], &opts[p]);
} }
int ret = 0; int res = av_opt_set(_context, key.c_str(), value.c_str(),
if ((ret = av_opt_set(_context, key.c_str(), value.c_str(), AV_OPT_SEARCH_CHILDREN);
AV_OPT_SEARCH_CHILDREN)) if (res < 0) {
< 0) { PLOG_WARNING(
char sterror[AV_ERROR_MAX_STRING_SIZE]; "Failed setting option '%s' to '%s' due to error: %s",
av_make_error_string(sterror, AV_ERROR_MAX_STRING_SIZE, ret); key.c_str(), value.c_str(),
PLOG_WARNING("Option '%s' could not be set to '%s'. (%s)", key.c_str(), value.c_str(), sterror); ffmpeg::tools::get_error_description(res));
} }
have_param = false; have_param = false;
have_key = false; have_key = false;
@@ -1176,10 +1176,14 @@ bool obsffmpeg::encoder::video_encode_texture(uint32_t handle, int64_t pts, uint
int obsffmpeg::encoder::receive_packet(bool* received_packet, struct encoder_packet* packet) int obsffmpeg::encoder::receive_packet(bool* received_packet, struct encoder_packet* packet)
{ {
auto gctx = obsffmpeg::obs_graphics(); int res = 0;
av_packet_unref(&_current_packet); av_packet_unref(&_current_packet);
int res = avcodec_receive_packet(_context, &_current_packet); {
auto gctx = obsffmpeg::obs_graphics();
res = avcodec_receive_packet(_context, &_current_packet);
}
if (res != 0) { if (res != 0) {
return res; return res;
} }
@@ -1240,9 +1244,12 @@ int obsffmpeg::encoder::receive_packet(bool* received_packet, struct encoder_pac
} }
int obsffmpeg::encoder::send_frame(std::shared_ptr<AVFrame> const frame) int obsffmpeg::encoder::send_frame(std::shared_ptr<AVFrame> const frame)
{
int res = 0;
{ {
auto gctx = obsffmpeg::obs_graphics(); auto gctx = obsffmpeg::obs_graphics();
int res = avcodec_send_frame(_context, frame.get()); res = avcodec_send_frame(_context, frame.get());
}
if (res == 0) { if (res == 0) {
push_used_frame(frame); push_used_frame(frame);
} }