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.