Hello community,
I try to get total frame count of video file using OpenCV API.
cv::VideoCapture capture(video_path);
if (!capture.isOpened()){
throw "Error when reading video";
}
double frame_count = capture.get(cv::CAP_PROP_FRAME_COUNT);
double org_height = capture.get(cv::CAP_PROP_FRAME_HEIGHT);
double org_width = capture.get(cv::CAP_PROP_FRAME_WIDTH);
capture.release();
std::cout << "frame count = " << frame_count << std::endl;
std::cout << "height = " << org_height << std::endl;
std::cout << "width = " << org_width << std::endl;
I just try on iMX8MP-EVK and iMX8QXP-MEK with Linux BSP 5.15.71_2.2.0.
But function will be returned error status (-1).
root@imx8qxpc0mek:~/work/opencv/test_capture# g++ -O -g test_capture.cpp -l/usr/include/opencv4 -o test_capture -std=c++11 -lopencv_videoio
root@imx8qxpc0mek:~/work/opencv/test_capture# ./test_capture -video=bunny_480p.mp4
frame count = -1
height = 480
width = 854
root@imx8qxpc0mek:~/work/opencv/test_capture# ./test_capture -video=bunny_1080p.mp4
frame count = -1
height = 1080
width = 1920
On HOST PC Linux, it will return correct value of total frame count.
tte@evmhost20:~/imx-bsp-5.15.71/work/opencv/test_capture$ ./test_capture -video=bunny_480p.mp4
frame count = 720
height = 480
width = 854
tte@evmhost20:~/imx-bsp-5.15.71/work/opencv/test_capture$ ./test_capture -video=bunny_1080p.mp4
frame count = 1800
height = 1080
width = 1920
Is this file parser problem? or not a bug but a specification?
Evaluation environment as following
board : MIMX8MPLUS-EVK LPDDR4, MIMX8QXP-C0-MEK
Linux BSP : L5.15.71_2.2.0
Video file : URL https://github.com/bower-media-samples
bunny_480p = https://github.com/bower-media-samples/big-buck-bunny-480p-30s
bunny_1080p = https://github.com/bower-media-samples/big-buck-bunny-1080p-60fps-30s
Host PC : Ubuntu 20.04.2LTE x86-64
Attached are source code of test program and message log of MIMX6QXP-C0-MEK.
Best regards,
Ishii.