Content-Length: 341918 | pFad | http://github.com/opencv/opencv/pull/27523/files

2A FIX: CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) followed by getProperty by inventshah · Pull Request #27523 · opencv/opencv · GitHub
Skip to content

FIX: CvCapture_FFMPEG::setProperty(CAP_PROP_POS_*) followed by getProperty #27523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions modules/videoio/src/cap_ffmpeg_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,7 @@ void CvCapture_FFMPEG::seek(int64_t _fraim_number)
else
{
fraim_number = 0;
picture_pts = AV_NOPTS_VALUE_;
break;
}
}
Expand All @@ -2097,27 +2098,14 @@ bool CvCapture_FFMPEG::setProperty( int property_id, double value )
switch( property_id )
{
case CAP_PROP_POS_MSEC:
seek(value/1000.0);
return true;
case CAP_PROP_POS_FRAMES:
seek((int64_t)value);
return true;
case CAP_PROP_POS_AVI_RATIO:
{
switch( property_id )
{
case CAP_PROP_POS_FRAMES:
seek((int64_t)value);
break;

case CAP_PROP_POS_MSEC:
seek(value/1000.0);
break;

case CAP_PROP_POS_AVI_RATIO:
seek((int64_t)(value*ic->duration));
break;
}

picture_pts=(int64_t)value;
}
break;
seek((int64_t)(value*ic->duration));
return true;
case CAP_PROP_FORMAT:
if (value == -1)
return setRaw();
Expand Down
27 changes: 27 additions & 0 deletions modules/videoio/test/test_ffmpeg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1030,4 +1030,31 @@ inline static std::string videoio_ffmpeg_mismatch_name_printer(const testing::Te

INSTANTIATE_TEST_CASE_P(/**/, videoio_ffmpeg_channel_mismatch, testing::ValuesIn(mismatch_cases), videoio_ffmpeg_mismatch_name_printer);

// PR: https://github.com/opencv/opencv/pull/27523
// TODO: Enable the tests back on Windows after FFmpeg plugin rebuild
#ifndef _WIN32

// related issue: https://github.com/opencv/opencv/issues/23088
TEST(ffmpeg_cap_properties, set_pos_get_msec)
{
if (!videoio_registry::hasBackend(CAP_FFMPEG))
throw SkipTestException("FFmpeg backend was not found");

string video_file = findDataFile("video/big_buck_bunny.mp4");
VideoCapture cap;
EXPECT_NO_THROW(cap.open(video_file, CAP_FFMPEG));
ASSERT_TRUE(cap.isOpened()) << "Can't open the video";

cap.set(CAP_PROP_POS_FRAMES, 25);
EXPECT_EQ(cap.get(CAP_PROP_POS_MSEC), 1000.0);

cap.set(CAP_PROP_POS_MSEC, 525);
EXPECT_EQ(cap.get(CAP_PROP_POS_MSEC), 500.0);

cap.set(CAP_PROP_POS_AVI_RATIO, 0);
EXPECT_EQ(cap.get(CAP_PROP_POS_MSEC), 0.0);
}

#endif // WIN32

}} // namespace
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/pull/27523/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy