需要一个示例来检索Gstreamer C代码中输出流的流统计信息吗?

需要一个示例来检索Gstreamer C代码中输出流的流统计信息吗?,c,gstreamer,C,Gstreamer,我是C代码新手,我正在为一个项目编写一个基本的代码转换程序。我想知道是否有人有一个基本的例子,可以让我捕获输出统计数据,例如(视频和音频的实际比特率、帧速率、分辨率大小、视频h264级别等) 请参阅以下代码: #include <gst/gst.h> #include <glib.h> #include <stdio.h> static gboolean cb_print_position (GstElement *pipeline) { gint64

我是C代码新手,我正在为一个项目编写一个基本的代码转换程序。我想知道是否有人有一个基本的例子,可以让我捕获输出统计数据,例如(视频和音频的实际比特率、帧速率、分辨率大小、视频h264级别等)

请参阅以下代码:

#include <gst/gst.h>
#include <glib.h>
#include <stdio.h>


static gboolean
cb_print_position (GstElement *pipeline)
{
  gint64 pos;


  if (gst_element_query_position (pipeline, GST_FORMAT_TIME, &pos)) 
    {
    g_print ("Time: %" GST_TIME_FORMAT  "\r", GST_TIME_ARGS (pos));
  }


  /* call me again */
  return TRUE;
}




static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;

  switch (GST_MESSAGE_TYPE (msg)) {

    case GST_MESSAGE_EOS:
      g_print ("End of stream\n");
      g_main_loop_quit (loop);
      break;

    case GST_MESSAGE_ERROR: {
      gchar  *debug;
      GError *error;

      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);

      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }

  return TRUE;
}



int main (int argc, char *argv[])
{
  GMainLoop *loop;

  GstElement *pipeline, *videotestsrcm, *x264encm, *rtmpsinkm, *flvmuxm;
  GstBus *bus;
  guint bus_watch_id;

  /* Initialisation */
  gst_init (&argc, &argv);


const gchar*nano_str;guint major, minor, micro, nano;

gst_init (&argc, &argv);

gst_version (&major, &minor, &micro, &nano);

if (nano == 1)
nano_str = "(CVS)";
else if (nano == 2)
nano_str = "(Prerelease)";
else
nano_str = "";
printf ("This program is linked against GStreamer %d.%d.%d%s\n",major, minor, micro, nano_str);

  loop = g_main_loop_new (NULL, FALSE);


  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("videotest-pipeline");
  videotestsrcm   = gst_element_factory_make ("videotestsrc", "testsource");
  x264encm = gst_element_factory_make ("x264enc", "videoencoder");
  rtmpsinkm = gst_element_factory_make ("rtmpsink", "video2sink");
  flvmuxm = gst_element_factory_make ("flvmux", "muxer");

  if (!pipeline || !videotestsrcm || !x264encm || !rtmpsinkm || !flvmuxm) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }


g_object_set (G_OBJECT (rtmpsinkm), "location" , argv[1] ,  NULL);



  /* Set up the pipeline */

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);


  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
                    videotestsrcm, x264encm, rtmpsinkm, flvmuxm, NULL);

  /* we link the elements together */
  /* videotestsrcm -> autovideosinkm */
  gst_element_link_many (videotestsrcm, x264encm, flvmuxm, rtmpsinkm, NULL);


  /* Set the pipeline to "playing" state*/
  g_print ("Now set pipeline in state playing...\n");
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

/* run pipeline */
  g_timeout_add (200, (GSourceFunc) cb_print_position, pipeline);



  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);


  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));
  g_source_remove (bus_watch_id);
  g_main_loop_unref (loop);

  return 0;
}
#包括
#包括
#包括
静态gboolean
cb_打印_位置(GstElement*管道)
{
gint64位;
if(gst元素查询位置(管道、gst格式、时间和pos))
{
g_打印(“时间:%”GST_时间格式“\r”,GST_时间参数(pos));
}
/*再打电话给我*/
返回TRUE;
}
静态gboolean总线调用(GstBus*总线、GstMessage*消息、gpointer数据)
{
GMainLoop*循环=(GMainLoop*)数据;
开关(GST\信息\类型(msg)){
案例GST\信息\ EOS:
g_打印(“流结束\n”);
g_主循环退出(循环);
打破
案例GST\u消息\u错误:{
gchar*调试;
GError*错误;
gst\消息\解析\错误(消息、错误和调试);
g_自由(调试);
g_printerr(“错误:%s\n”,错误->消息);
g_无错误(错误);
g_主循环退出(循环);
打破
}
违约:
打破
}
返回TRUE;
}
int main(int argc,char*argv[])
{
GMainLoop*循环;
GstElement*管道、*视频测试SRCM、*x264encm、*rtmpsinkm、*flvmuxm;
GstBus*总线;
吉尼特巴士公司;
/*初始化*/
gst_init(&argc,&argv);
const gchar*nano_str;吉尼特大调、小调、微型、纳米级;
gst_init(&argc,&argv);
gst_版本(大、小、微、纳米);
如果(nano==1)
nano_str=“(CVS)”;
否则如果(nano==2)
nano_str=“(预释放)”;
其他的
nano_str=“”;
printf(“此程序与GStreamer%d.%d.%d%s\n”链接,主调、小调、微调、纳米级);
loop=g_main_loop_new(NULL,FALSE);
/*创建gstreamer元素*/
管道=gst_管道_新(“视频测试管道”);
videotestsrcm=gst\u元素\u工厂制造商(“videotestsrc”、“testsource”);
x264encm=gst元素工厂制造(“x264enc”、“视频编码器”);
rtmpsinkm=gst元素工厂制造(“rtmpsink”、“video2sink”);
flvmuxm=gst元素工厂制造(“flvmux”、“muxer”);
如果(!pipeline | | |!videotestsrcm | | |!x264encm | |!rtmpsinkm | |!flvmuxm){
g_printerr(“无法创建一个元素。正在退出。\n”);
返回-1;
}
g_对象集(g_对象(rtmpsinkm),“位置”,argv[1],NULL);
/*铺设管道*/
/*我们添加了一个消息处理程序*/
总线=gst_管道_获取_总线(gst_管道(管道));
bus_watch_id=gst_bus_add_watch(总线、总线调用、环路);
商品及服务税(巴士);
/*我们将所有元素添加到管道中*/
gst_bin_add_many(gst_bin(管道),
videotestsrcm、x264encm、rtmpsinkm、flvmuxm、NULL);
/*我们将这些元素连接在一起*/
/*videotestsrcm->autovideosinkm*/
gst元素链接多(videotestsrcm、x264encm、flvmuxm、rtmpsinkm、NULL);
/*将管道设置为“正在播放”状态*/
g_print(“现在将管道设置为播放状态…\n”);
gst元素设置状态(管道、gst状态);
/*运行管道*/
g_超时_添加(200,(GSourceFunc)cb_打印位置,管道);
/*迭代*/
g_打印(“运行…\n”);
g_主循环运行(循环);
/*离开主回路,好好清理*/
g_print(“返回,停止播放”);
gst\元素\集合\状态(管道,gst\状态\空);
g_print(“删除管道”);
gst_对象_unref(gst_对象(管道));
g_源_移除(总线_监视_id);
g_主回路_unref(回路);
返回0;
}

请先添加一些代码。我想在上下文中更容易显示我添加了一些基本代码请先添加一些代码。我想在contextHi-Antti中更容易显示我添加了一些基本代码