Created
December 5, 2014 00:01
-
-
Save crackwitz/69238c3acc2f86764c1b to your computer and use it in GitHub Desktop.
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
| #include <iostream> | |
| #include <opencv2/opencv.hpp> | |
| int main(int argc, char **argv) | |
| { | |
| if (argc < 3) | |
| { | |
| std::cout << "./a.out <video file name> <number of frames>" << std::endl; | |
| return 0; | |
| } | |
| std::string outvideoname(argv[1]); | |
| unsigned framecount = atoi(argv[2]); | |
| cv::Mat frame(1080, 1920, CV_8UC3, cv::Scalar(186, 186, 186)); | |
| cv::VideoWriter outvid( | |
| outvideoname, | |
| CV_FOURCC('M', 'J', 'P', 'G'), | |
| 25, | |
| frame.size()); | |
| std::cout << "writer open? " << (outvid.isOpened() ? "yes" : "NO") << std::endl; | |
| if (!outvid.isOpened()) | |
| return -1; | |
| for (unsigned c = 0; c < framecount; c += 1) | |
| { | |
| if (c % 25 == 0) | |
| std::cout << "\rwriting frame " << c << std::flush; | |
| outvid.write(frame); | |
| } | |
| std::cout << std::endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment