How do I display two or more videos with different lenghts (1,2 mins) using opencv?
1 | initial version |
How do I display two or more videos with different lenghts (1,2 mins) using opencv?
2 | No.2 Revision |
How do I display two or more videos with different lenghts (1,2 mins) using opencv?
int main(){
/* Open the Video File for Reading */
VideoCapture cap("CarSurveillance/Video1.avi"); // 00:00:33
VideoCapture cap2("CarSurveillance/Video2.mp4"); // 00:01:12
if (!cap.isOpened()){
cout << "Was not possible to Open the Video" << endl;
cout << "Reasons:" << endl;
cout << "1st: Wrong PATH" << endl;
cout << "2nd: Wrong Extension" << endl;
cout << "3rt: Unknown Reasons" << endl;
system("PAUSE");
exit(EXIT_FAILURE);
}
if (!cap2.isOpened()){
cout << "Was not possible to Open the Video" << endl;
cout << "Reasons:" << endl;
cout << "1st: Wrong PATH" << endl;
cout << "2nd: Wrong Extension" << endl;
cout << "3rt: Unknown Reasons" << endl;
system("PAUSE");
exit(EXIT_FAILURE);
}
namedWindow("Video1", CV_WINDOW_AUTOSIZE);
namedWindow("Video2", CV_WINDOW_AUTOSIZE);
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 1 Frame per seconds : " << fps << endl;
fps = cap2.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 2 Frame per seconds : " << fps << endl;
while (true){
Mat frame,frame2;
if(!cap.read(frame)){
destroyWindow("Video1");
}else{
imshow("Video1", frame);
}
if (!cap2.read(frame2)){
destroyWindow("Video2");
}else{
imshow("Video2", frame2);
}
waitKey(30);
}
system("PAUSE");
return 0;
}
After the first video be closed the second stay in slow motion
3 | No.3 Revision |
How do I display two or more videos with different lenghts (1,2 mins) using opencv?
int main(){
/* Open the Video File for Reading */
VideoCapture cap("CarSurveillance/Video1.avi"); // 00:00:33
VideoCapture cap2("CarSurveillance/Video2.mp4"); // 00:01:12
if (!cap.isOpened()){
cout << "Was not possible to Open the Video" << endl;
cout << "Reasons:" << endl;
cout << "1st: Wrong PATH" << endl;
cout << "2nd: Wrong Extension" << endl;
cout << "3rt: Unknown Reasons" << endl;
system("PAUSE");
exit(EXIT_FAILURE);
}
if (!cap2.isOpened()){
cout << "Was not possible to Open the Video" << endl;
cout << "Reasons:" << endl;
cout << "1st: Wrong PATH" << endl;
cout << "2nd: Wrong Extension" << endl;
cout << "3rt: Unknown Reasons" << endl;
system("PAUSE");
exit(EXIT_FAILURE);
}
namedWindow("Video1", CV_WINDOW_AUTOSIZE);
bool video1WindowDestroyed = false;
bool video2WindowDestroyed = false;
namedWindow("Video2", CV_WINDOW_AUTOSIZE);
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 1 Frame per seconds : " << fps << endl;
fps = cap2.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Video 2 Frame per seconds : " << fps << endl;
Mat frame, frame2;
cap.read(frame); // read a new frame from video
cap2.read(frame); // read a new frame from video
while (true){
Mat frame,frame2;
if(!cap.read(frame)){
destroyWindow("Video1");
}else{
if ((video1WindowDestroyed == false) && (cap.read(frame) == true)){
imshow("Video1", frame);
}
if (!cap2.read(frame2)){
destroyWindow("Video2");
}else{
if (cap.read(frame) == false){
destroyWindow("Video1");
video1WindowDestroyed = true;
}
}
if ((video2WindowDestroyed == false) && (cap2.read(frame2) == true)){
imshow("Video2", frame2);
if (cap2.read(frame2) == false){
destroyWindow("Video2");
video2WindowDestroyed = true;
}
}
if (video2WindowDestroyed == true && video2WindowDestroyed == true){
break;
}
waitKey(30);
}
waitKey(0);
system("PAUSE");
return 0;
}
After the when first video be closed ends he is slow to close the window and pause the second stay in slow motionvideo, two seconds after restart