Eliyahu-Shmuel Eliyahu-Shmuel - 9 months ago 57
C++ Question

Why the function 'x'.write(frame) isn't work for me?

When I use in the function: 'x'.write(frame) for write to video file in opencv the program pass the code and I compile it without Errors but when I open the file i see that it's 0 kb and the player can't play it. can someone help me?

Here my code:

// Setup output video
cv::VideoWriter output_cap("output.avi",
cv::Size(1376, 768));

// Loop to read frames from the image and write it to the output capture
cv::Mat frame = imread("1.jpg", 0);
for(int hgf=1;hgf<=300;hgf++)

if (!frame.data)




I changed my code to this and I changed my image to smaller image and it's work!

my code:

cv::Mat frame = imread("01.jpg",1);
VideoWriter output_cap("output.avi", CV_FOURCC('M', 'J', 'P', 'G'), 1,

for (int hgf = 1; hgf <= 10; hgf++) {
std::cout << "-";

the problem was that my image was 4608x3456 and the opencv cann't use in this file to create a video. I changed to 752x515 an this work!! good day!!!!!!