Your C and C++ code are not equal. This code will work:
int main( int argc, char** argv )
{
Mat source;
VideoCapture stream("video.avi");
if (!stream.isOpened())
{
std::cout << "Stream cannot be opened" << std::endl;
return -1;
}
while(1)
{
stream >> source;
if(source.empty())
{
std::cout << "Error reading video frame" << endl;
}
imshow("Source", source);
waitKey(20);
}
stream.release();
getchar();
}