如何动态改变gstreamer管道视频的亮度

时间:2018-01-19 02:36:39

标签: c gstreamer

我正在尝试下面的代码来改变视频管道的亮度。我可以看到视频,但亮度永远不会改变,虽然我试图每隔60秒更改一次。知道我错过了什么吗?

static gboolean broadcasting_timeout_cb (gpointer user_data)
{
GstElement *vaapipostproc = NULL;
vaapipostproc = gst_bin_get_by_name(GST_BIN(broadcasting_pipeline),  
"postproc");

if (vaapipostproc == NULL) {
    fprintf(stderr, "unable to get vaapipostproc from broadcasting 
pipeline\n");
    return TRUE;
}

g_object_set (G_OBJECT (vaapipostproc), "brightness", -1.0, NULL);
fprintf(stderr, "brightness changed by -1.0\n");
return TRUE;
}


main() {
//pipeline code goes here and  then below code comes //

broadcasting_pipeline = gst_parse_launch (compl_streaming_pipe, &error);
if (!broadcasting_pipeline) {
    fprintf (stderr, "Parse error: %s\n", error->message);
    exit (1);
}
loop_broadcasting = g_main_loop_new (NULL, FALSE);
g_timeout_add_seconds (60, broadcasting_timeout_cb, loop_broadcasting); 

gst_element_set_state (broadcasting_pipeline, GST_STATE_PLAYING);
g_main_loop_run(loop_broadcasting);
// rest of the code for main function comes here
}

1 个答案:

答案 0 :(得分:0)

似乎vaapipostproc属性如亮度等在运行时不能动态改变!!

然而,我发现视频平衡元素的工作原理是Millind Deore所建议的。但是视频平衡导致CPU使用率过高并成为流媒体管道的瓶颈。

所以,我尝试使用与视频平衡相同的glcolorbalance,但它使用gpu进行亮度转换。

以下是我的实验:

如果我使用以下管道,那么我可以成功地向youtube广播:

gst-launch-1.0 filesrc location=Recorded_live_streaming_on__2018_01_20___13_56_33.219076__-0800.flv ! decodebin name=demux ! queue ! videorate ! video/x-raw,framerate=30/1 ! glupload ! glcolorconvert ! gldownload ! video/x-raw ! vaapih264enc dct8x8=true cabac=true rate-control=cbr bitrate=8192 keyframe-period=60 max-bframes=0 ! flvmux name=mux ! rtmpsink sync=true async=true location="rtmp://x.rtmp.youtube.com/XXXXX live=1" demux. ! queue ! progressreport ! audioconvert ! audiorate ! audioresample ! faac bitrate=128000 ! audio/mpeg,mpegversion=4,stream-format=raw ! mux.

错误:未在环境中设置XDG_RUNTIME_DIR。 libva info:VA-API版本0.39.0 libva info:va_getDriverName()返回0 libva info:试图打开/usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info:找到init函数__vaDriverInit_0_39 libva info:va_openDriver()返回0 将管道设置为PAUSED ... 错误:未在环境中设置XDG_RUNTIME_DIR。 libva info:VA-API版本0.39.0 libva info:va_getDriverName()返回0 libva info:试图打开/usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info:找到init函数__vaDriverInit_0_39 libva info:va_openDriver()返回0 管道是PREROLLING ...... 得到元素'vaapiencodeh264-0'的上下文:gst.vaapi.Display = context,gst.vaapi.Display =(GstVaapiDisplay)“(GstVaapiDisplayGLX)\ vaapidisplayglx1”; 从元素'gldownloadelement0'获得上下文:gst.gl.GLDisplay = context,gst.gl.GLDisplay =(GstGLDisplay)“(GstGLDisplayX11)\ gldisplayx11-0”; 重新分配延迟...... 管道是PREROLLED ... 将管道设置为PLAYING ... 新时钟:GstSystemClock progressreport0(00:00:05):4/1984秒(0.2%) progressreport0(00:00:10):9/1984秒(0.5%) progressreport0(00:00:15):14/1984秒(0.7%) progressreport0(00:00:20):19/1984秒(1.0%)

但是,如果我在此管道中使用glcolorbalance,则会出现以下错误,我无法再将其流式传输到youtube:

gst-launch-1.0 filesrc location=Recorded_live_streaming_on__2018_01_20___13_56_33.219076__-0800.flv ! decodebin name=demux ! queue ! videorate ! video/x-raw,framerate=30/1 ! glupload ! glcolorbalance ! glcolorconvert ! gldownload ! video/x-raw ! vaapih264enc dct8x8=true cabac=true rate-control=cbr bitrate=8192 keyframe-period=60 max-bframes=0 ! flvmux name=mux ! rtmpsink sync=true async=true location="rtmp://x.rtmp.youtube.com/XXXXX live=1" demux. ! queue ! progressreport ! audioconvert ! audiorate ! audioresample ! faac bitrate=128000 ! audio/mpeg,mpegversion=4,stream-format=raw ! mux.

错误:未在环境中设置XDG_RUNTIME_DIR。 libva info:VA-API版本0.39.0 libva info:va_getDriverName()返回0 libva info:试图打开/usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info:找到init函数__vaDriverInit_0_39 libva info:va_openDriver()返回0 将管道设置为PAUSED ... 错误:未在环境中设置XDG_RUNTIME_DIR。 libva info:VA-API版本0.39.0 libva info:va_getDriverName()返回0 libva info:试图打开/usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info:找到init函数__vaDriverInit_0_39 libva info:va_openDriver()返回0 管道是PREROLLING ...... 得到元素'vaapiencodeh264-0'的上下文:gst.vaapi.Display = context,gst.vaapi.Display =(GstVaapiDisplay)“(GstVaapiDisplayGLX)\ vaapidisplayglx1”; 从元素'gldownloadelement0'获得上下文:gst.gl.GLDisplay = context,gst.gl.GLDisplay =(GstGLDisplay)“(GstGLDisplayX11)\ gldisplayx11-0”; 重新分配延迟...... 警告:来自element / GstPipeline:pipeline0 / GstDecodeBin:demux:延迟链接失败。 其他调试信息: ./grammar.y(510):gst_parse_no_more_pads():/ GstPipeline:pipeline0 / GstDecodeBin:demux: 失败延迟将名为demux的GstDecodeBin的某个pad连接到名为queue0的GstQueue的一个pad ^ Chandling中断。 中断:停止管道...... 错误:管道不想预卷。 将管道设置为NULL ... 释放管道......

似乎glcolorbalanc导致decodebin不与vaapih264enc链接,因为它是上述管道之间的唯一区别。

我是gstreamer的新手,任何人都可以告诉我第二个管道有什么问题,为什么链接失败了?

相关问题