Opencv CAP_PROP_FRAME_COUNT return negative larg number
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
VideoCapture capture(captureFileName);
I am using Opencv 3.3.1.
I am using the following cod.
if (!capture.isOpened()) {
throw "Error when reading file";
}
cout << "capture.get(CAP_PROP_FRAME_COUNT)"
<< capture.get(CAP_PROP_FRAME_COUNT) << endl;
cout << "capture.get(CV_CAP_PROP_FPS)" << capture.get(CV_CAP_PROP_FPS)
<< endl;
When the video size is around 30MB, capture.get(CAP_PROP_FRAME_COUNT) return value around 16632. However, when the video size is around 150MB, capture.get(CAP_PROP_FRAME_COUNT) return value around -2.30584e+14.
The rest of the code cannot run as well (after that line). Did anyone run large video with opencv before?
update:
I realized the problem is in the source video. I download the stream with vlc and it did not stop recording properly and a 1 minute video is more than 100mb(frames after 30mb are corrupted). VideoCapture works well on other video.
c++ opencv
add a comment |
VideoCapture capture(captureFileName);
I am using Opencv 3.3.1.
I am using the following cod.
if (!capture.isOpened()) {
throw "Error when reading file";
}
cout << "capture.get(CAP_PROP_FRAME_COUNT)"
<< capture.get(CAP_PROP_FRAME_COUNT) << endl;
cout << "capture.get(CV_CAP_PROP_FPS)" << capture.get(CV_CAP_PROP_FPS)
<< endl;
When the video size is around 30MB, capture.get(CAP_PROP_FRAME_COUNT) return value around 16632. However, when the video size is around 150MB, capture.get(CAP_PROP_FRAME_COUNT) return value around -2.30584e+14.
The rest of the code cannot run as well (after that line). Did anyone run large video with opencv before?
update:
I realized the problem is in the source video. I download the stream with vlc and it did not stop recording properly and a 1 minute video is more than 100mb(frames after 30mb are corrupted). VideoCapture works well on other video.
c++ opencv
add a comment |
VideoCapture capture(captureFileName);
I am using Opencv 3.3.1.
I am using the following cod.
if (!capture.isOpened()) {
throw "Error when reading file";
}
cout << "capture.get(CAP_PROP_FRAME_COUNT)"
<< capture.get(CAP_PROP_FRAME_COUNT) << endl;
cout << "capture.get(CV_CAP_PROP_FPS)" << capture.get(CV_CAP_PROP_FPS)
<< endl;
When the video size is around 30MB, capture.get(CAP_PROP_FRAME_COUNT) return value around 16632. However, when the video size is around 150MB, capture.get(CAP_PROP_FRAME_COUNT) return value around -2.30584e+14.
The rest of the code cannot run as well (after that line). Did anyone run large video with opencv before?
update:
I realized the problem is in the source video. I download the stream with vlc and it did not stop recording properly and a 1 minute video is more than 100mb(frames after 30mb are corrupted). VideoCapture works well on other video.
c++ opencv
VideoCapture capture(captureFileName);
I am using Opencv 3.3.1.
I am using the following cod.
if (!capture.isOpened()) {
throw "Error when reading file";
}
cout << "capture.get(CAP_PROP_FRAME_COUNT)"
<< capture.get(CAP_PROP_FRAME_COUNT) << endl;
cout << "capture.get(CV_CAP_PROP_FPS)" << capture.get(CV_CAP_PROP_FPS)
<< endl;
When the video size is around 30MB, capture.get(CAP_PROP_FRAME_COUNT) return value around 16632. However, when the video size is around 150MB, capture.get(CAP_PROP_FRAME_COUNT) return value around -2.30584e+14.
The rest of the code cannot run as well (after that line). Did anyone run large video with opencv before?
update:
I realized the problem is in the source video. I download the stream with vlc and it did not stop recording properly and a 1 minute video is more than 100mb(frames after 30mb are corrupted). VideoCapture works well on other video.
c++ opencv
c++ opencv
edited Jan 4 at 2:57
Vivian
asked Jun 21 '18 at 6:58
VivianVivian
3510
3510
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It doesn't depend on the video size. The property will be correctly returned for videos with much larger size than 150 MB.
If your two videos are identical in container and video codec, most likely your second video is corrupted somehow. This can happen e.g. by not cleanly aborting while writing the video file. You could try to fix this by re-encoding (e.g. with ffmpeg) if you absolutely need the frame count.
Otherwise just ignore the frame count and keep grabbing frames until you reach the end of the video, which may still work correctly, even if you don't have a frame count.
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50962251%2fopencv-cap-prop-frame-count-return-negative-larg-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It doesn't depend on the video size. The property will be correctly returned for videos with much larger size than 150 MB.
If your two videos are identical in container and video codec, most likely your second video is corrupted somehow. This can happen e.g. by not cleanly aborting while writing the video file. You could try to fix this by re-encoding (e.g. with ffmpeg) if you absolutely need the frame count.
Otherwise just ignore the frame count and keep grabbing frames until you reach the end of the video, which may still work correctly, even if you don't have a frame count.
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
add a comment |
It doesn't depend on the video size. The property will be correctly returned for videos with much larger size than 150 MB.
If your two videos are identical in container and video codec, most likely your second video is corrupted somehow. This can happen e.g. by not cleanly aborting while writing the video file. You could try to fix this by re-encoding (e.g. with ffmpeg) if you absolutely need the frame count.
Otherwise just ignore the frame count and keep grabbing frames until you reach the end of the video, which may still work correctly, even if you don't have a frame count.
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
add a comment |
It doesn't depend on the video size. The property will be correctly returned for videos with much larger size than 150 MB.
If your two videos are identical in container and video codec, most likely your second video is corrupted somehow. This can happen e.g. by not cleanly aborting while writing the video file. You could try to fix this by re-encoding (e.g. with ffmpeg) if you absolutely need the frame count.
Otherwise just ignore the frame count and keep grabbing frames until you reach the end of the video, which may still work correctly, even if you don't have a frame count.
It doesn't depend on the video size. The property will be correctly returned for videos with much larger size than 150 MB.
If your two videos are identical in container and video codec, most likely your second video is corrupted somehow. This can happen e.g. by not cleanly aborting while writing the video file. You could try to fix this by re-encoding (e.g. with ffmpeg) if you absolutely need the frame count.
Otherwise just ignore the frame count and keep grabbing frames until you reach the end of the video, which may still work correctly, even if you don't have a frame count.
answered Jun 21 '18 at 8:27
w-mw-m
6,5742434
6,5742434
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
add a comment |
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
I realized my problem is when I use vlc to save udp stream video, the file became incredibly large. It is a 9 minutes video but when I put the video in video editor, it showed 23566 days: 9hours... vlc probably is the problem.
– Vivian
Jun 22 '18 at 1:14
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50962251%2fopencv-cap-prop-frame-count-return-negative-larg-number%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown