imshow in OpenCv shows black screen
<p>I have created a project once and it was working properly, after reinstalling operation system, I set up the enviroment and all the components and suddenly i am not getting any output at all. My program for testing is simple:</p>

<pre><code>#include &lt;cstdio&gt;
#include "opencv2/opencv.hpp"
#include &lt;iostream&gt;
#include &lt;sstream&gt;

using namespace cv;
using namespace std;

int main(int, char**)
{
VideoCapture cap("videofile.avi"); 
if (!cap.isOpened())  // check if we succeeded
    return -1;

namedWindow("Frame", 1);
for (;;)
{
    Mat frame;
    if (!cap.read(frame)) {
        cerr &lt;&lt; "Unable to read next frame." &lt;&lt; endl;
        cerr &lt;&lt; "Exiting..." &lt;&lt; endl;
        exit(EXIT_FAILURE);
    }

    imshow("Frame", frame);
    if (waitKey(30) &gt;= 0) break;
}

return 0;
}
</code></pre>

<p>I have installed all necessary codecs and updated video card drivers. Still getting the same black screen.</p>

<p>The output looks like this:
<a href="https://i.stack.imgur.com/jIHbN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jIHbN.jpg" alt="Black screen"></a></p>

<p>EDIT:</p>

<p>The problem appears to be only when playing .avi videos with AVC codec</p>