简体   繁体   中英

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? Can I access that streams from C++ side? In fact, this data in future will be sending to nginx server using librtmp .

I will use 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. Thanks to Qt forum for right path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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