SkillAgentSearch skills...

VideoTexture

Renders an MPEG1 video to an SFML Texture using the pl_mpeg library

Install / Use

/learn @fallahn/VideoTexture
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

VideoTexture class for SFML

Example for using pl_mpeg to decode mpg1 video and audio, and render it to a texture for use with SFML drawables.

Usage

Add the files in src to your SFML project and link to OpenGL. Then do something like:

#include "src/VideoTexture.hpp"

#include <SFML/graphics.hpp>


int main()
{
    sf::RenderWindow window;
    window.create({ 1024, 768 }, "Window");

    //test video can be downloaded from the link in the pl_mpeg readme
    //https://github.com/phoboslab/pl_mpeg/blob/master/README.md

    VideoTexture videoTexture;
    if (videoTexture.loadFromFile("test.mpeg"))
    {
        videoTexture.play();
    }

    sf::Clock frameClock;

    sf::Sprite sprite01(videoTexture.getTexture());


    while (window.isOpen())
    {
        sf::Event evt;
        while (window.pollEvent(evt))
        {
            if (evt.type == sf::Event::Closed)
            {
                window.close();
            }

        }

        const float dt = frameClock.restart().asSeconds();
        videoTexture.update(dt);



        window.clear();
        window.draw(sprite01);
        window.display();
    }

    return 0;
}

VideoTexture class includes api for play/pause/stop playback as well as retreiving video duration and seeking to specific points. See VideoTexture.hpp for details.

Related Skills

View on GitHub
GitHub Stars7
CategoryContent
Updated1y ago
Forks0

Languages

C

Security Score

55/100

Audited on Jun 5, 2024

No findings