简体   繁体   English

从QML Camera获取原始H.264和AAC数据

[英]Getting raw H.264 and AAC data from QML Camera

According to this code: 根据此代码:

import QtQuick 2.5
import QtMultimedia 5.5

Item {
    id: root
    Camera {
        objectName: "camera"
                id: camera
                captureMode: Camera.CaptureVideo
                videoRecorder.videoCodec: "h264"
                videoRecorder.audioCodec: "aac"
        }
}

is it possible to get raw H.264 and AAC data (for example, in unsigned char * type) without writing it on the disk drive? 是否可以在不将其写入磁盘驱动器的情况下获取原始H.264和AAC数据(例如, unsigned char *类型)? Can I access that streams from C++ side? 我可以从C ++端访问该流吗? In fact, this data in future will be sending to nginx server using librtmp . 实际上,将来这些数据将使用librtmp发送到nginx服务器。

I will use GStreamer. 我将使用GStreamer。

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <gst/gst.h>

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    GstElement *pipeline;
    GstBus *bus;
    GstMessage *msg;

    putenv("GST_DEBUG=6");
    putenv("GST_PLUGIN_PATH_1_0=E:\\sdk\\gstreamer\\1.0\\x86_64\\lib\\gstreamer-1.0\\");
    putenv("GST_PLUGIN_PATH=E:\\sdk\\gstreamer\\1.0\\x86_64\\lib\\gstreamer-1.0\\");

    /* Initialize GStreamer */
    gst_init (&argc, &argv);

    /* Build the pipeline */
    //pipeline = gst_parse_launch ("playbin uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", 
    //NULL);
    pipeline = gst_parse_launch ("ksvideosrc device-index=0 ! autovideosink", NULL); // Windows OS specific

    /* Start playing */
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* Wait until error or EOS */
    bus = gst_element_get_bus (pipeline);
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, (GstMessageType)(GST_MESSAGE_ERROR | GST_MESSAGE_EOS));

    /* Free resources */
    if (msg != NULL)
      gst_message_unref (msg);
    gst_object_unref (bus);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);

    return app.exec();
}

You can write your own plugin for QML, using this lib. 您可以使用此库编写自己的QML插件。 Thanks to Qt forum for right path. 感谢Qt论坛提供正确的路径。

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

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