0

I can succesfully save video which I captured from c++ opencv there is no problem.

Bu similar code not capturing the video. Just opening out.avi . and only 6 kb.

I put the code in showframe func. there is no resizing fyi.

Anybody has experience with the opencv videowriter on the Qt?

void Widget::show_frame(Mat &image)
{
    Mat resized_image = image.clone();
    video.write(image);

    int width_of_label = ui->label_camera->width();
    int height_of_label = ui->label_camera->height();

    Size size(width_of_label, height_of_label);

//    cv::resize(image, resized_image, size);
    cvtColor(image,image,CV_BGR2RGB);
    cvtColor(resized_image, resized_image, CV_BGR2RGB);

ps : Platform MacOSX

scopchanov
  • 7,966
  • 10
  • 40
  • 68
Rahibe Meryem
  • 269
  • 3
  • 14

2 Answers2

1

I encountered the same problem with you, and I have tried many solutions, I think you can make the fifth parameter of videowriter() be false. That is, VideoWriter out = VideoWriter(video_name, CV_FOURCC('D', 'I', 'V', 'X'),frame_fps,Size(frame_width,frame_height),false). This works for me!

peace
  • 11
  • 1
0

make sure that your application has access to the opencv_ffmpeg*.dll. For example place it in the working directory or the PATH variable.

Try different codecs, too. Afaik, MJPG did work on all tested machines/systems so far.

Micka
  • 19,585
  • 4
  • 56
  • 74
  • I am at the mac os X . When I try a simple code with C++11 it is working and writing the mpeg or mjpg. But when I try to embed it to QT with QTCreator it is opening the file for wirte but its freezing at 6 KB . Why QT didnt add the images as video to the output I couldnt find. – Rahibe Meryem Jan 30 '18 at 15:58
  • the writer is an cv::VideoWriter, right? Should be no problem to use it within Qt. Can you test for .isOpen? Can you add the class structure and the function where you create/open the writer? – Micka Jan 31 '18 at 06:56
  • if you create a VideoWriter in the main function and write some frames before you go to the Qt event loop, does that work? – Micka Jan 31 '18 at 06:58
  • I will try in the main loop. I found [link](https://stackoverflow.com/questions/47858206/c-opencv-3-4-ffmpeg-3-4-1-videowriter-and-mp4-output-file-format) . people suffering same problem I think. – Rahibe Meryem Jan 31 '18 at 08:16