try to fix VideoCapture different time stamp(issue 8834)#14901
Merged
opencv-pushbot merged 1 commit intoopencv:3.4from Aug 6, 2019
Merged
try to fix VideoCapture different time stamp(issue 8834)#14901opencv-pushbot merged 1 commit intoopencv:3.4from
opencv-pushbot merged 1 commit intoopencv:3.4from
Conversation
alalek
reviewed
Jun 26, 2019
| { | ||
| case CAP_PROP_POS_MSEC: | ||
| return 1000.0*(double)frame_number/get_fps(); | ||
| return (dts_to_sec(picture_pts) * 1000 + 0.5); |
Member
There was a problem hiding this comment.
- Initial undefined value (
AV_NOPTS_VALUE) is not properly handled here. - Why we need
0.5?
Author
There was a problem hiding this comment.
You are right.
1.I forget the AV_NOPTS_VALUE, so I add the logical for handle it.
2.add 0.5 is for my round requirements, not need in opencv.
After refactor, I write some test code to compare result with ffprobe, it's almost same.
- Test Code
VideoCapture capture;
if (capture.open(argv[1])) {
double width = capture.get(CV_CAP_PROP_FRAME_WIDTH);
double height = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
double timePos = capture.get(CV_CAP_PROP_POS_MSEC);
printf("width=%f, height=%f, index=0, timePos=%f\n", width, height, timePos);
int index = 0;
Mat img;
do
{
capture >> img;
if (!img.empty())
{
index++;
double timePos = capture.get(CV_CAP_PROP_POS_MSEC);
printf("index=%d, timePos=%f\n", index, timePos);
}
} while (!img.empty());
}
- Result for opencv
width=720.000000, height=1280.000000, index=0, timePos=0.000000
index=1, timePos=0.000000
index=2, timePos=37.877778
index=3, timePos=65.933333
index=4, timePos=88.311111
index=5, timePos=101.544444
index=6, timePos=132.033333
index=7, timePos=149.877778
index=8, timePos=181.844444
index=9, timePos=215.888889
index=10, timePos=265.566667
- Result for ffprobe
ffprobe -show_frames -print_format json Xxxx.mp4 | grep pkt_dts_time
"pkt_dts_time": "0.000000",
"pkt_dts_time": "0.037878",
"pkt_dts_time": "0.065933",
"pkt_dts_time": "0.088311",
"pkt_dts_time": "0.101544",
"pkt_dts_time": "0.132033",
"pkt_dts_time": "0.149878",
"pkt_dts_time": "0.181844",
"pkt_dts_time": "0.215889",
"pkt_dts_time": "0.265567",
There was a problem hiding this comment.
In my case , it is not solved .still Timepos is 0.00. Don't Know why? Any more changes required?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #8834
This pullrequest changes
please refer 8834's issue comment