简体   繁体   English

C ++ / Qt 5 GStreamer继续循环

[英]C++/Qt 5 GStreamer continues loop

I'm currently trying to experiment with GSteamer playing a video on loop. 我目前正在尝试使用GSteamer在循环播放视频。 I have it currently implemented like this: 我目前实现如下:

void VPlayer::playFile(QString video_filename, bool loop)
{
    m_isLooping = loop;
    QString cmdstr = "gst-launch-1.0 -v filesrc location=" + video_filename + " ! qtdemux ! queue max-size-buffers=0 max-size-time=0 ! vpudec frame-drop=0 ! queue ! imxv4l2sink device=/dev/video16";
    GError **l_error = NULL;;
    m_gst_pipeline = gst_parse_launch (cmdstr.toUtf8().data(), l_error);

    m_gst_bus = gst_pipeline_get_bus (GST_PIPELINE(m_gst_pipeline));
    gst_bus_set_sync_handler (m_gst_bus, GStreamerBusCallback, this, nullptr);
    gst_object_ref (m_gst_bus);
    gst_object_ref(m_gst_pipeline);

    gst_element_set_state (m_gst_pipeline, GST_STATE_NULL);
    gst_element_seek_simple (m_gst_pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
    gst_element_set_state (m_gst_pipeline, GST_STATE_PLAYING);
}

GstBusSyncReply VPlayer::GStreamerBusCallback(GstBus *bus, GstMessage *msg, gpointer data)
{
    VPlayer* player = (VPlayer*) data;
    GstElement *pipeline = player->getPipeline();
    switch (GST_MESSAGE_TYPE(msg))
    {
    case GST_MESSAGE_EOS:
        /* restart playback if at end */
        qDebug() << "PLAYBACK FINISHED";
        if(player->isLooping())
        {
            qDebug() << "LOOPING";
            gst_element_seek_simple (pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 0);
            gst_element_set_state (pipeline, GST_STATE_PLAYING);
        }

        break;
    default:
        break;
    }

    return GST_BUS_PASS;
}

When I run this example I get the EOS as expected and also the debug output is ok, but instead of seeking the image freezes and nothing happens. 当我运行这个例子时,我得到了预期的EOS,并且调试输出也没问题,但是没有寻找图像冻结而没有任何反应。 Also the looping does not seem to continue. 循环似乎也没有继续。

What did I miss here? 我在这里想念的是什么?

At least this needs to be fixed: 至少这需要修复:

GError *l_error = NULL;
m_gst_pipeline = gst_parse_launch (cmdstr.toUtf8().data(), &l_error);

and I'm assuming you call gst_init(...); 我假设你打电话给gst_init(...); somewhere. 某处。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM