tangmignzhou 发表于 2023-7-18 11:35:49

mpp编码失败

本帖最后由 tangmignzhou 于 2023-7-18 11:45 编辑

dev:/tmz$ ffgo version
OS:         Ubuntu 20.04.6 LTS
MODEL:         Firefly AIO-3588Q MIPI101(Linux)
FIREFLY: v2.40-7-gaab3442
DATE:         20230629
KERNEL:         Linux version 5.10.160 (lvsx@tchip16) (kernel commit id: dc384cc20ddf) (sdk version: rk3588_linux_release_20230704_v1.1.1a) (aarch64-none-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 10.3.1 20210621, GNU ld (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 2.36.1.20210621) #111 SMP Tue Jul 4 11:41:59 CST 2023

0:00:00.073694217 181803   0x55b1bc8b60 WARN                  mppenc gstmppenc.c:641:gst_mpp_enc_set_format:<myenc_1> framerate (0/1) is insane!

rga_api version 1.8.1_
RgaBlit(1465) RGA_BLIT fail: Invalid argument
RgaBlit(1466) RGA_BLIT fail: Invalid argument
fd-vir-phy-hnd-format
rect
f-blend-size-rotation-col-log-mmu
fd-vir-phy-hnd-format
rect
f-blend-size-rotation-col-log-mmu
This output the user patamaters when rga call blit fail
:00:14.891498867 181803   0x55b1bc8b60 WARN                     mpp gstmpp.c:235:gst_mpp_rga_do_convert: failed to blit
0:00:14.891568285 181803   0x55b1bc8b60 ERROR               mppenc gstmppenc.c:829:gst_mpp_enc_convert:<myenc_1> failed to convert frame
0:00:14.891586952 181803   0x55b1bc8b60 ERROR               mppenc gstmppenc.c:1021:gst_mpp_enc_handle_frame:<myenc_1> not negotiated
0:00:14.891610285 181803   0x55b1bc8b60 WARN                  mppenc gstmppenc.c:1025:gst_mpp_enc_handle_frame:<myenc_1> can't handle this frame
0:00:14.891973123 181803   0x55b1bc8b60 WARN               basesrc gstbasesrc.c:3072:gst_base_src_loop:<mysource_1> error: Internal data stream error.
0:00:14.891999665 181803   0x55b1bc8b60 WARN               basesrc gstbasesrc.c:3072:gst_base_src_loop:<mysource_1> error: streaming stopped, reason not-negotiated (-4)


源码:
CRINFO << "starting gstreamer";
    if (mGstInfo.pipeline = gst_pipeline_new("mypipeline_1"); mGstInfo.pipeline == nullptr) {
      CRERROR << "mGstInfo.pipeline nullptr";
      return false;
    }

    if (mGstInfo.appsrc = gst_element_factory_make("appsrc", "mysource_1"); mGstInfo.appsrc == nullptr) {
      CRERROR << "mGstInfo.appsrc nullptr";
      return false;
    }

    if (mGstInfo.appsink = gst_element_factory_make("appsink", "mysink_1"); mGstInfo.appsink == nullptr) {
      CRERROR << "mGstInfo.appsink nullptr";
      return false;
    }

    if (mGstInfo.frame_encoder = gst_element_factory_make("mpph264enc", "myenc_1");
      mGstInfo.frame_encoder == nullptr) {
      CRERROR << "mGstInfo.frame_encoder nullptr";
      return false;
    }

    mGstInfo.gst_elements.push_back(mGstInfo.appsrc);
    mGstInfo.gst_elements.push_back(mGstInfo.frame_encoder);
    mGstInfo.gst_elements.push_back(mGstInfo.appsink);
    GstCaps *caps_appsrc = nullptr, *caps_h264 = nullptr, *caps_conv = nullptr;

    caps_appsrc = gst_caps_new_simple("video/x-raw", "format", G_TYPE_STRING, mGstInfo.type.c_str(), "width",
                                    G_TYPE_INT, mGstInfo.width, "height", G_TYPE_INT, mGstInfo.height,
                                    "framerate", GST_TYPE_FRACTION, mGstInfo.framerate, 1, "chroma-site",
                                    G_TYPE_STRING, "mpeg2", NULL);

    if (caps_appsrc == nullptr) {
      CRERROR << "caps_appsrc nullptr";
      return false;
    }

    // caps_h264 =
    //   gst_caps_new_simple("video/x-h264", "stream-format", G_TYPE_STRING, "byte-stream", "alignment",
    //                         G_TYPE_STRING, "au", "profile", G_TYPE_STRING, "baseline", "height", G_TYPE_INT,
    //            mGstInfo.height,"width", G_TYPE_INT, mGstInfo.width, NULL);
    caps_h264 =
                gst_caps_new_simple("video/x-h264", "stream-format", G_TYPE_STRING, "byte-stream", "alignment",
                            G_TYPE_STRING, "au", NULL);
    if (caps_h264 == nullptr) {
      CRERROR << "caps_h264 nullptr";
      gst_caps_unref(caps_appsrc);
      return false;
    }

    int blocksize = mGstInfo.width * mGstInfo.height * mGstInfo.channel;// TODO::
    g_object_set(G_OBJECT(mGstInfo.appsrc), "caps", caps_appsrc, "blocksize", blocksize, NULL);

    CRINFO << "mGstInfo.appsrc set";

    // g_object_set(G_OBJECT(mGstInfo.appsink), "caps", caps_h264, NULL);
    // CRINFO << "mGstInfo.appsink set";
    g_object_set(G_OBJECT(mGstInfo.appsink), "caps", caps_h264, NULL);
    CRINFO << "mGstInfo.appsink set";
    g_object_set(G_OBJECT(mGstInfo.frame_encoder), "bps", mGstInfo.bitrate, "bps-max", mGstInfo.bitrate,
               "bps-min", mGstInfo.bitrate, "gop", mGstInfo.iframeinterval, "header-mode", 1, "height",
               mGstInfo.height, "profile", 66, "rc-mode", 1, "width", mGstInfo.width, NULL);

    CRINFO << "mGstInfo.encoder set";

    mGstInfo.loop = g_main_loop_new(NULL, FALSE);
    mGstInfo.bus = gst_pipeline_get_bus(GST_PIPELINE(mGstInfo.pipeline));
    mGstInfo.bus_watch_id = gst_bus_add_watch(mGstInfo.bus, busCall, mGstInfo.loop);
    gst_object_unref(mGstInfo.bus);

    for (int i = 0; i < mGstInfo.gst_elements.size(); ++i) {
      gst_bin_add(GST_BIN(mGstInfo.pipeline), mGstInfo.gst_elements);
      if (i > 0) {
            if (!gst_element_link(mGstInfo.gst_elements, mGstInfo.gst_elements)) {
                CRERROR << "link element [" << mGstInfo.gst_elements->object.name << "] and ["
                        << mGstInfo.gst_elements->object.name << "] failed.";
                gst_caps_unref(caps_appsrc);
                gst_caps_unref(caps_h264);
                return false;
            }
      }
    }

    gst_caps_unref(caps_appsrc);
    gst_caps_unref(caps_h264);
    if (caps_conv != nullptr) { gst_caps_unref(caps_conv); }

    CRINFO << "iframeinterval: " << mGstInfo.iframeinterval << ", bitrate: " << mGstInfo.bitrate
         << ", for image " << mGstInfo.width << "*" << mGstInfo.height;

    // Start pipeline so it could process incoming data
    GstStateChangeReturn ret = gst_element_set_state(mGstInfo.pipeline, GST_STATE_PLAYING);
    CRINFO << "gst_element_set_state:" << ret;

    mGstreamerThreadStarted = true;// TODO::
    CRINFO << "gstreamer thread started";
    return true;




zhibiao 发表于 2023-8-25 17:09:31

我也遇到同样的问题,请问你问题解决了吗?
页: [1]
查看完整版本: mpp编码失败