title: OpenCV trying to read or write to video file causes VIDEOIO exception "Can't find starting number" (icvExtractPattern)
body: <p>So for a school project, I am trying to use <code>cv::VideoCapture</code> to open a <code>.avi</code> file to perform some image processing on it. Also, I am trying to record the video from my (Laptop) camera and save it to a file <code>out.avi</code>. Both times I encountered more or less the same exception.
  I am using <code>OpenCV 4.1.2</code> and CLion on Linux Mint.</p>
  
  <p>Trying to use <code>cv::VideoCapture vid(0);</code> works perfectly fine, it shows the output from the Laptop's camera. However, when specifying a path to a video file to open, I get the following error:</p>
  
  <pre><code>VIDIOC_REQBUFS: Inappropriate ioctl for device
  [ERROR:0] global /home/aris/dev/opencv/modules/videoio/src/cap.cpp (116) open VIDEOIO(CV_IMAGES): raised OpenCV exception:
  
  OpenCV(4.1.2-dev) /home/aris/dev/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): ../example_depth.avi in function 'icvExtractPattern'
  </code></pre>
  
  <p>When trying to create a <code>cv::VideoWriter</code> object (to save the camera video ouput to a file) using:</p>
  
  <pre><code>cv::VideoWriter vidWrit("out.avi", cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), 10, cv::Size(width, height), true);
  </code></pre>
  
  <p>I am encountering this error:</p>
  
  <pre><code>[ERROR:0] global /home/aris/dev/opencv/modules/videoio/src/cap.cpp (392) open VIDEOIO(CV_IMAGES): raised OpenCV exception:
  
  OpenCV(4.1.2-dev) /home/aris/dev/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): out.avi in function 'icvExtractPattern'
  </code></pre>
  
  <p>Which looks kind of similar to the other one.</p>
  
  <p>Here is a minimal example (note that the program still shows the camera output in <code>task == "write"</code>):</p>
  
  <pre><code>#include &lt;opencv2/opencv.hpp&gt;
  
  int main ()
  {
      std::string task = "write";
      if(task == "read") {    // Read from .avi file
          system("pwd");  // Print current path
          cv::VideoCapture vid("../example_depth.avi");   // Throws first exception "Inappropriate ioctl for device"
  
          int key = 0;
          cv::Mat frame;
          while (key != 27) {
              vid &gt;&gt; frame;
              if (frame.empty())
                  break;
  
              cv::imshow("Video", frame);
              key = cv::waitKey(25);
          }
      } else if (task == "write") {   // Write Laptop video to file
          cv::VideoCapture vid(0);    // Video from camera
  
          int width = vid.get(cv::VideoCaptureProperties::CAP_PROP_FRAME_WIDTH);
          int height = vid.get(cv::VideoCaptureProperties::CAP_PROP_FRAME_HEIGHT);
          cv::VideoWriter vidWriter("out.avi", cv::VideoWriter::fourcc('M', 'J', 'P', 'G'), 10, cv::Size(width, height), true);   // Throws second exception
  
          int key = 0;
          cv::Mat frame;
          while (key != 27) {
              vid &gt;&gt; frame;
              if (frame.empty())
                  break;
              vidWriter.write(frame);
  
              cv::imshow("Video", frame);
              key = cv::waitKey(25);
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>I've been looking for a solution for two days now. Maybe I am missing some library or OpenCV didn't get installed correctly, I don't know about that (yes, I've tried 'recompiling' OpenCV). I used <a href="https://blog.zhajor.com/2016/10/install-opencv-and-make-a-test-project-with-clion/" rel="nofollow noreferrer">this</a> tutorial to make all the OpenCV files.</p>