Skip to content

Commit

Permalink
properly map between obs and gst video formats
Browse files Browse the repository at this point in the history
  • Loading branch information
fzwoch committed Sep 19, 2024
1 parent 5b437ec commit 6b614a3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion obs-vaapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ typedef struct {
size_t codec_size;
} obs_vaapi_t;

static GstVideoFormat map_video_format(enum video_format format)
{
switch (format) {
case VIDEO_FORMAT_I420:
return GST_VIDEO_FORMAT_I420;
case VIDEO_FORMAT_NV12:
return GST_VIDEO_FORMAT_NV12;
case VIDEO_FORMAT_I444:
return GST_VIDEO_FORMAT_Y444;
case VIDEO_FORMAT_BGRA:
return GST_VIDEO_FORMAT_BGRx;
case VIDEO_FORMAT_P010:
return GST_VIDEO_FORMAT_P010_10LE;
case VIDEO_FORMAT_I010:
return GST_VIDEO_FORMAT_I420_10LE;
default:
return GST_VIDEO_FORMAT_UNKNOWN;
}
}

static gboolean bus_callback(GstBus *bus, GstMessage *message,
gpointer user_data)
{
Expand Down Expand Up @@ -387,7 +407,7 @@ static void *create(obs_data_t *settings, obs_encoder_t *encoder)
obs_encoder_get_height(encoder), video_info.fps_num,
video_info.fps_den,
gst_video_format_to_string(
(GstVideoFormat)video_info.output_format));
map_video_format(video_info.output_format)));

gst_element_set_state(vaapi->pipe, GST_STATE_PLAYING);

Expand Down

0 comments on commit 6b614a3

Please sign in to comment.