# OpenCV vido in SFML window

**URL:** <https://forum.opencv.org/t/opencv-vido-in-sfml-window/5365>\
**Category:** Uncategorized\
**Created:** [September 27, 2021, 10:02am UTC](https://forum.opencv.org/t/opencv-vido-in-sfml-window/5365 "2021-09-27T10:02:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gosh1k](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/gosh1k/32/3278_2.png) [@gosh1k](https://forum.opencv.org/u/gosh1k)\
**Post date:** [September 27, 2021, 10:02am UTC](https://forum.opencv.org/t/opencv-vido-in-sfml-window/5365/1 "2021-09-27T10:02:29Z")

</div>

Help please, I need to display the video that I play using OpenCV in SFML window

```auto
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Config.hpp>
#include <SFML/GpuPreference.hpp>
#include <SFML/Main.hpp>
#include <SFML/OpenGL.hpp>
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace sf;
using namespace std;
using namespace cv;

int main(){
    RenderWindow window(sf::VideoMode(1920, 1080), "War - New Era in 16bit!");
    Image heroimage;
    heroimage.loadFromFile("C:/Users/vitya/source/repos/Project2/Project2/biografiya-glad-valakas.jpg");
    Sprite herosprite;
    Texture herotexture;
    herotexture.loadFromImage(heroimage);
    herosprite.setTexture(herotexture);
    herosprite.setPosition(450,60);
    Music music;
    if (!music.openFromFile("jojo.wav")) {
        cout << "error"; }
    music.play();
    while (window.isOpen()){
        Event event;
        while (window.pollEvent(event)) 
        {
            if(event.type==Event::Closed)
            window.close();
        }
        window.clear();
        window.draw(herosprite);
        window.display();}
    VideoCapture cap("D:\\1_1.mp4");
    if (cap.isOpened() == false){
        cout << "Cannot open the video file" << endl;
        cin.get();
        return -1;}
    double fps = cap.get(CAP_PROP_FPS);
    cout << "Frames per seconds : " << fps << endl;
    string window_name = "My First Video";
    namedWindow(window_name);
   //setWindowProperty("window name", WND_PROP_FULLSCREEN, WINDOW_FULLSCREEN);
    while (true)
    {
        Mat frame;
        bool bSuccess = cap.read(frame);
        if (bSuccess == false)
        {
            cout << "Found the end of the video" << endl;
        }
        imshow(window_name, frame);
        if (waitKey(10) == 27)
        {
            cout << "Esc key is pressed by user. Stoppig the video" << endl;
        }
    }
    return 0;
}

```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [September 27, 2021, 12:42pm UTC](https://forum.opencv.org/t/opencv-vido-in-sfml-window/5365/2 "2021-09-27T12:42:00Z")

</div>

that code looks like two sources copy-pasted together.

please put some effort into your question.
