Skip to content

Commit

Permalink
videoio: moved GStreamer-specific test to test_gstreamer.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabunin committed Nov 7, 2023
1 parent 7f53fc4 commit ee2a6ab
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
40 changes: 40 additions & 0 deletions modules/videoio/test/test_gstreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,44 @@ TEST(videoio_gstreamer, timeout_property)
}
}

//==============================================================================
// Seeking test with manual GStreamer pipeline
typedef testing::TestWithParam<string> gstreamer_bunny;

TEST_P(gstreamer_bunny, manual_seek)
{
const string video_file = BunnyParameters::getFilename("." + GetParam());
const string pipeline = "filesrc location=" + video_file + " ! decodebin ! videoconvert ! video/x-raw, format=BGR ! appsink drop=1";
const double target_pos = 3000.0;
const float ms_per_frame = 1000 / BunnyParameters::getFps();
VideoCapture cap;
cap.open(pipeline, CAP_GSTREAMER);
ASSERT_TRUE(cap.isOpened());
Mat img;
for (int i = 0; i < 10; i++)
{
cap >> img;
}
EXPECT_FALSE(img.empty());
cap.set(CAP_PROP_POS_MSEC, target_pos);
cap >> img;
EXPECT_FALSE(img.empty());
double actual_pos = cap.get(CAP_PROP_POS_MSEC);
EXPECT_NEAR(actual_pos, target_pos, ms_per_frame);
}

static const string bunny_params[] = {
// string("wmv"),
string("mov"),
string("mp4"),
// string("mpg"),
string("avi"),
string("h264"),
string("h265"),
string("mjpg.avi")
};

INSTANTIATE_TEST_CASE_P(videoio, gstreamer_bunny, testing::ValuesIn(bunny_params));


}} // namespace
20 changes: 0 additions & 20 deletions modules/videoio/test/test_video_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,6 @@ class videoio_bunny : public Videoio_Test_Base, public testing::TestWithParam<Ba
// timestamp depending on codec and back-end. So the first frame has timestamp 0 or frame_period.
EXPECT_NEAR(timestamp, i*frame_period, frame_period) << "i=" << i;
}
if (ext == "wmv" || ext == "mpg" || apiPref != CAP_GSTREAMER)
return;

// Seeking test with manual GStreamer pipeline
VideoCapture cap2;
EXPECT_NO_THROW(cap2.open("filesrc location="+video_file+" ! decodebin ! videoconvert ! video/x-raw, format=BGR ! appsink drop=1", apiPref));
if (!cap.isOpened())
throw SkipTestException(cv::String("Backend ") + cv::videoio_registry::getBackendName(apiPref) +
cv::String(" can't open the video: ") + video_file);
for (int i = 0; i < 10; i++)
{
ASSERT_NO_THROW(cap2 >> img);
}
double timestamp = 0;
cap2.set(CAP_PROP_POS_MSEC, 3000.0);
ASSERT_NO_THROW(cap2 >> img);
EXPECT_NO_THROW(timestamp = cap2.get(CAP_PROP_POS_MSEC));
if (cvtest::debugLevel > 0)
std::cout << "msec jump rewind back test case: timestamp = " << timestamp << std::endl;
EXPECT_NEAR(timestamp, 3000.0, 100.0) << "Failed to rewind back";
}
};

Expand Down

0 comments on commit ee2a6ab

Please sign in to comment.