title: Uninitialized frameSize when opening VideoWriter in OpenCV
body: <p>I'm developing an app to stream a camera over internet by using OpenCV and GStreamer.</p>
  <p>I've succesfully done it using Python, and now I'm trying to develop the same app in C++.</p>
  <p>I have a problem with the VideoWriter class. It throws an error because there is an assertion to check the frameSize (cap_gstreamer.cpp line 1937), and it says that the parameter is &lt;= 0, so the function fails.</p>
  <p>The thing is that the parameter i use when calling the function is ok (640,480), but once inside the function is like it's uninitialized.</p>
  <p>I've modified the source code of OpenCV to add a few prints inside the creator and open functions, and all the parameters are ok except the frameSize, which value is random (ex. -396126824, 65535).</p>
  <p>I've searched over the internet and i haven't found any similar error.</p>
  <p>I'm using OpenCV inside a docker container. OpenCV has been built inside the docker by using the following:</p>
  <pre><code>mkdir -p ~/opencv &amp;&amp; \
      cd ~/opencv &amp;&amp; \
      wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip &amp;&amp; \
      unzip opencv.zip &amp;&amp; \
      rm opencv.zip &amp;&amp; \
      mkdir -p build &amp;&amp; \ 
      cd build &amp;&amp; \
      cmake ../opencv-4.x \
      -D CMAKE_BUILD_TYPE=RELEASE \
      -D CMAKE_INSTALL_PREFIX=/usr/local \
      -D INSTALL_C_EXAMPLES=OFF \
      -D INSTALL_PYTHON_EXAMPLES=ON \
      -D BUILD_EXAMPLES=OFF \
      -D PYTHON3_EXECUTABLE=$(which python3) \
      -D PYTHON_INCLUDE_DIR=$(python3 -c &quot;from distutils.sysconfig import get_python_inc; print(get_python_inc())&quot;) \
      -D PYTHON_INCLUDE_DIR2=$(python3 -c &quot;from os.path import dirname; from distutils.sysconfig import get_config_h_filename; print(dirname(get_config_h_filename()))&quot;) \
      -D PYTHON_LIBRARY=$(python3 -c &quot;from distutils.sysconfig import get_config_var;from os.path import dirname,join ; print(join(dirname(get_config_var('LIBPC')),get_config_var('LDLIBRARY')))&quot;) \
      -D PYTHON3_NUMPY_INCLUDE_DIRS=$(python3 -c &quot;import numpy; print(numpy.get_include())&quot;) \
      -D PYTHON3_PACKAGES_PATH=$(python3 -c &quot;from distutils.sysconfig import get_python_lib; print(get_python_lib())&quot;) .. &amp;&amp; \
      make -j4 &amp;&amp; \
      make install &amp;&amp; \ 
      ldconfig
  </code></pre>
  <p>The program i use:</p>
  <pre><code>    string gst_out(&quot;appsrc ! videoconvert ! video/x-raw ! &quot;
                     &quot;jpegenc ! &quot;
                     &quot;udpsink host=&quot; + host_ip + &quot; port=&quot; + to_string(port_num));
      cout &lt;&lt; &quot;Stream caps: &quot; &lt;&lt; gst_out &lt;&lt; endl;
      
      /* Open stream */
      Size S = Size((int)640, (int)480);
      printf(&quot;Size: w %d, h %d\n&quot;, S.width, S.height);
  
      VideoWriter out(gst_out,                         /* gstreamer pipeline */
                      CAP_GSTREAMER,                   /* gstreamer api */
                      -1,                              /* auto detect codec */
                      FRAMERATE,                       /* framerate */
                      S,                               /* frame size */
                      true);                           /* color=true */
      if (!out.isOpened()) 
      {
          cap.release();
          cout &lt;&lt; &quot;Failed to open stream&quot; &lt;&lt; endl;
          exit(-1);
      }
  </code></pre>
  <p>The program is compiled by using:</p>
  <pre><code>g++ streaming_jpeg.cpp -o streaming_jpeg -I /usr/include/opencv4 -L /usr/local/lib -lopencv_core -lopencv_videoio
  </code></pre>