This commit is contained in:
PodmogilnyjIvan
2021-12-13 04:10:22 -08:00
parent d8a0dea9b5
commit 682ca7160b
2 changed files with 16 additions and 11 deletions

View File

@@ -94,19 +94,19 @@ GstFlowReturn new_sample(GstAppSink* appsink, gpointer data) {
static int framecount = 0; static int framecount = 0;
framecount++; framecount++;
std::cout << "nnew frame " << framecount << std::endl; //std::cout << "nnew frame " << framecount << std::endl;
GstSample* sample = gst_app_sink_pull_sample(appsink); GstSample* sample = gst_app_sink_pull_sample(appsink);
GstCaps* caps = gst_sample_get_caps(sample); GstCaps* caps = gst_sample_get_caps(sample);
GstBuffer* buffer = gst_sample_get_buffer(sample); GstBuffer* buffer = gst_sample_get_buffer(sample);
const auto& n_memory = gst_buffer_n_memory(buffer); const auto& n_memory = gst_buffer_n_memory(buffer);
std::cout << "n_memory = " << n_memory << std::endl; //std::cout << "n_memory = " << n_memory << std::endl;
std::cout << "buffer->pts = " << buffer->pts << std::endl; //std::cout << "buffer->pts = " << buffer->pts << std::endl;
std::cout << "buffer->dts = " << buffer->dts << std::endl; //std::cout << "buffer->dts = " << buffer->dts << std::endl;
std::cout << "buffer->duration = " << buffer->duration << std::endl; //std::cout << "buffer->duration = " << buffer->duration << std::endl;
std::cout << "buffer->offset = " << buffer->offset << std::endl; //std::cout << "buffer->offset = " << buffer->offset << std::endl;
std::cout << "buffer->offset_end = " << buffer->offset_end << std::endl; //std::cout << "buffer->offset_end = " << buffer->offset_end << std::endl;
const GstStructure* info = gst_sample_get_info(sample); const GstStructure* info = gst_sample_get_info(sample);
@@ -318,8 +318,8 @@ GstFlowReturn new_sample(GstAppSink* appsink, gpointer data) {
// convert gstreamer data to OpenCV Mat, you could actually // convert gstreamer data to OpenCV Mat, you could actually
// resolve height / width from caps... // resolve height / width from caps...
int width = 2560; int width = 480;
int height = 1440; int height = 270;
GstStructure* s = gst_caps_get_structure(caps, 0); GstStructure* s = gst_caps_get_structure(caps, 0);
gboolean res = true; gboolean res = true;
@@ -353,7 +353,7 @@ GstFlowReturn new_sample(GstAppSink* appsink, gpointer data) {
} }
static gboolean my_bus_callback(GstBus* bus, GstMessage* message, gpointer data) { static gboolean my_bus_callback(GstBus* bus, GstMessage* message, gpointer data) {
g_print("Got %s message\n", GST_MESSAGE_TYPE_NAME(message)); //g_print("Got %s message\n", GST_MESSAGE_TYPE_NAME(message));
switch (GST_MESSAGE_TYPE(message)) { switch (GST_MESSAGE_TYPE(message)) {
case GST_MESSAGE_ERROR: { case GST_MESSAGE_ERROR: {
GError* err; GError* err;
@@ -781,6 +781,7 @@ int main(int argc, char* argv[]) {
} }
else { else {
std::cout << "Don't have any frames yet ..." << std::endl; std::cout << "Don't have any frames yet ..." << std::endl;
//std::cout << "";
} }
} }

View File

@@ -45,8 +45,12 @@ int main(int argc, char* argv[]) {
int64_t total_frames_counter = 0; int64_t total_frames_counter = 0;
// Let's open the video with OpenCV and read it // Let's open the video with OpenCV and read it
std::string path_to_file = "C:\\Users\\ivan\\Source\\Repos\\cv_networking_pipeline\\gstreamer_receive_video\\videos\\camera1-2020-10-14---19-38-42---093390448_scaled.mp4"; // std::string path_to_file = "C:\\Users\\ivan\\Source\\Repos\\cv_networking_pipeline\\gstreamer_receive_video\\videos\\camera1-2020-10-14---19-38-42---093390448_scaled.mp4";
std::string path_to_file;
std::cout << "Please, enter the path to the video_file" << std::endl;
std::cin >> path_to_file;
cv::VideoCapture video_file(path_to_file); cv::VideoCapture video_file(path_to_file);
std::cout << "Video File opened" << std::endl; std::cout << "Video File opened" << std::endl;
cv::Mat frame; cv::Mat frame;