GstVideoCodecState *state = gst_video_codec_state_new(); gst_video_decoder_set_output_state(GST_VIDEO_DECODER(h264parse_), state);出现了error: incompatible type for argument 2 of ‘gst_video_decoder_set_output_state’GstVideoCodecState * {aka struct _GstVideoCodecState *}
时间: 2023-10-23 18:10:55 浏览: 136
这个错误提示意味着函数`gst_video_decoder_set_output_state`的第二个参数类型与函数定义不匹配。通常,这个错误是由于传递给函数的参数类型与函数声明中参数类型不一致导致的。你需要检查函数声明并确保第二个参数的类型与函数声明中的类型匹配。
在这个特定的问题中,你需要确保在调用`gst_video_decoder_set_output_state`函数时,第一个参数是`GstVideoDecoder`类型的对象,第二个参数的类型是`GstVideoCodecState *`类型的指针。如果类型匹配但是仍然存在问题,你需要检查是否正确包含相关头文件和库文件。
另外,请确保你已经包含了`gst/video/video.h`头文件,因为`gst_video_decoder_set_output_state()`函数的声明位于该头文件中。
相关问题
gstreamer1.16.3中没有gst_video_codec_state_new
如果你使用的是 GStreamer 1.16.3 版本,那么确实没有 `gst_video_codec_state_new` 函数。这个函数最早出现在 GStreamer 1.18 版本中,用于创建视频编解码器状态对象。
在 GStreamer 1.16.3 版本中,可以使用 `gst_video_info_init()` 函数来初始化一个 `GstVideoInfo` 对象,该对象包含有关视频流格式和编码器参数的信息。你可以将 `GstVideoInfo` 对象传递给 `gst_video_decoder_set_output_state()` 函数来设置视频解码器的输出状态。
例如,以下代码演示了如何使用 `gst_video_info_init()` 函数和 `gst_video_decoder_set_output_state()` 函数创建视频解码器状态:
```c
GstVideoInfo info;
GstVideoCodecState *state;
// 初始化 video info 对象
gst_video_info_init(&info);
info.width = 640;
info.height = 480;
info.fps_n = 30;
info.fps_d = 1;
// 创建视频解码器状态
state = gst_video_decoder_set_output_state(GST_VIDEO_DECODER(h264parse_), &info);
if (state == NULL) {
g_print("Failed to create video codec state\n");
return;
}
// 使用 state 对象进行解码
// ...
```
在这个例子中,我们首先使用 `gst_video_info_init()` 函数初始化一个 `GstVideoInfo` 对象,该对象表示一个 640x480 分辨率、30fps 的视频流。然后,我们使用 `gst_video_decoder_set_output_state()` 函数创建一个新的视频解码器状态对象,并将其设置为解码器的输出状态。注意,在这个例子中,我们将 `&info` 对象传递给 `gst_video_decoder_set_output_state()` 函数,而不是 `gst_video_codec_state_new()` 函数。
你可以根据你的具体需求调整 `GstVideoInfo` 对象的属性,以便与你的视频流格式和编码器参数匹配。
gst_video_decoder_set_output_state(GST_VIDEO_DECODER(h264parse_), state);中的state怎么在gstreamer1.16.3中生成再
在 GStreamer 1.16.3 中,`state` 参数的生成方式取决于你的应用程序需要的输出状态。它通常是一个 `GstVideoCodecState` 类型的结构体,包含视频解码器的输出参数,例如帧宽、帧高、像素格式、比特率、帧率等等。
要生成 `GstVideoCodecState`,你需要先创建一个 `GstCaps` 结构体,描述视频流的格式信息,包括帧宽、帧高、像素格式等。然后,使用 `gst_video_decoder_set_output_state()` 函数将 `GstCaps` 转换为 `GstVideoCodecState`。具体操作如下:
```c
// 创建视频流的格式信息
GstCaps *caps = gst_caps_new_simple("video/x-h264",
"width", G_TYPE_INT, frame_width,
"height", G_TYPE_INT, frame_height,
"framerate", GST_TYPE_FRACTION, frame_rate, 1,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
NULL);
// 将 caps 转换为 GstVideoCodecState
GstVideoCodecState *state = gst_video_decoder_set_output_state(GST_VIDEO_DECODER(h264parse_), caps);
```
这样,你就可以得到一个描述视频解码器输出状态的 `GstVideoCodecState` 结构体了。
阅读全文
相关推荐
















