I am receiving h264 frames of a stream (720x360@30fps) from a camera connected to PC via USB. I am converting these frames to BGR frames supported in OpenCV. After the conversion, these frames are sent to local network via UDP with the use of GStreamer in C++. A code snippet is shown below:
class VideoServer {
public:
VideoServer() {
std::string pipeline = "appsrc ! video/x-raw,format=BGR ! queue ! videoconvert ! x264enc bitrate=5000 ! "
"mpegtsmux alignment=7 ! rndbuffersize max=1316 min=1316 ! udpsink port=5005";
writer = std::make_unique<cv::VideoWriter>(pipeline, cv::CAP_GSTREAMER, 0, fps_, cv::Size(width_, height_));
}
void VideoDataCallack(const uint8_t *data, size_t size, int64_t timestamp) override {
std::cout << "At timestamp: " << timestamp << " video data of size " << size << " received." << std::endl;
// convert h264_frame to opencv_frame
writer->write(opencv_frame);
}
private:
std::unique_ptr<cv::VideoWriter> writer;
};
My goal is to steam these frames with minimal latency. Therefore, can someone point me to an efficient pipeline suitable for above code snippet?