0

I am facing a problem with OpenH264 library https://github.com/cisco/openh264

I would like to decode a stream sent by my raspberry pi camera over network on my C++/Qt Program which will display the image.

I'm using gstreamer on Raspberry Side to send the stream with this command line :

raspivid -n -t 0 -w 1280 -h 720 -fps 25 -b 2500000 -o - | gst-launch-1.0 fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! gdppay ! tcpserversink host=my_ip port=5000

On desktop side when I execute :

gst-launch-1.0 -v tcpclientsrc host=raspberry_ip port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

I'm able to see the stream of the camera correctly.

Okay, so now. I would like to make my own decoder using QT/C++ & OpenH264 decoder.

Here is my code :

void Manager::initDecoder(int width, int height) {
    long ret = WelsCreateDecoder(&(this->decoder));
    if (ret == 0) {
        this->decodingParam = { 0 };
        this->decodingParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
        this->decoder->Initialize(&decodingParam);
        this->bufferInfo = { 0 };

        this->yuvData = new uint8_t*[3];
        this->yuvData[0] = new uint8_t[width * height];
        this->yuvData[1] = new uint8_t[width * height / 4];
        this->yuvData[2] = new uint8_t[width * height / 4];

        this->tcpSocket->connectToHost("ip_raspberry", 5000);
    }
}

bool Manager::decodeStream(const unsigned char *rawEncodedData, const int rawEncodedDataLength, uint8_t **yuvData) {
    DECODING_STATE err = decoder->DecodeFrame2(rawEncodedData, rawEncodedDataLength, yuvData, &bufferInfo);
    if (err != 0) {
        qDebug() << "H264 decoding failed. Error code: " << err << ".";
        return false;
    }
    qDebug() << "----------- Succeedeeed --------------";
    return true;
}

When I get a new data I call decodeStream but this function is returning an error :

 dsBitstreamError      = 0x04,   ///< error bitstreams(maybe broken internal frame) the decoder cared
  dsNoParamSets         = 0x10,   ///< no parameter set NALs involved

I don't know what I'm doing wrong... Should I change some parameters on the raspberry sending ?

Thanks for helping.

X6Entrepreneur
  • 971
  • 2
  • 10
  • 30
  • 1
    Uhm.. is that all? In your original gstreamer pipeline you depacketize gdpay, a gstreamer payload format and then depacketize RTP before you hand it to the decoder. If you don't do this the decoder will not udnerstand the data you give it.. – Florian Zwoch Feb 20 '18 at 11:08
  • Could you please tell me the command that I need to send then ? I did not understand what do you mean exactly. Does gstreamer with this command line encode the image in H264 ? Maybe, the stream is not understood by the decoder... Yes. – X6Entrepreneur Feb 20 '18 at 11:51
  • Any help please ? – X6Entrepreneur Mar 02 '18 at 13:45

0 Answers0