Closed oomek closed 4 weeks ago
Describe the bug I'm getting packets not empty message when video loops
packets not empty
Environment:
Looping 1s video yields the following debug log.
Log log.txt
Test code
#include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include "mdk/Player.h" using namespace MDK_NS; using namespace std; #include <iostream> #include <cmath> #include <vector> #include <memory> class VideoPlayer { public: Player player; sf::RenderTexture texture; sf::Clock clock; sf::Time video_frame_time; sf::Time next_video_timestamp; sf::IntRect rect; VideoPlayer(const char* mediaFile, sf::IntRect rect) : rect(rect) { player.setMedia(mediaFile); player.prepare(); player.setPreloadImmediately(true); for(;;) { if (player.mediaStatus() > MediaStatus::Buffering) break; if (player.mediaStatus() == MediaStatus::Invalid) return; } auto video_info = player.mediaInfo().video[0]; player.setVideoSurfaceSize(video_info.codec.width * video_info.codec.par, video_info.codec.height); float frame_rate = video_info.codec.frame_rate; if (!texture.create(video_info.codec.width * video_info.codec.par, video_info.codec.height)) return; texture.setSmooth(true); player.setLoop(std::numeric_limits<int>::max()); video_frame_time = sf::seconds(1.0 / frame_rate); next_video_timestamp = sf::seconds(0); } void play() { player.set(State::Playing); clock.restart(); next_video_timestamp = sf::seconds(0); }; void update(sf::RenderWindow& window) { if ( next_video_timestamp < clock.getElapsedTime() - sf::seconds(video_frame_time.asSeconds() * 1.0 )) // is - video_frame_time necessay? { texture.setActive(true); sf::Time last_timestamp = sf::seconds(player.renderVideo()); next_video_timestamp += video_frame_time; texture.display(); texture.setActive(false); } sf::Sprite sprite(texture.getTexture()); sprite.setScale(static_cast<float>(rect.width) / texture.getSize().x, static_cast<float>(rect.height) / texture.getSize().y); sprite.setPosition(static_cast<float>(rect.left), static_cast<float>(rect.top)); window.draw(sprite); } }; int main(int argc, char** argv) { setLogHandler(nullptr); if (argc < 4) { cout << "Usage: " << argv[0] << " <gridWidth> <gridHeight> <videoFile1> [<videoFile2> ...]" << endl; return 1; } sf::VideoMode desktop_mode = sf::VideoMode::getDesktopMode(); desktop_mode.width = 800; desktop_mode.height = 600; int gridWidth = atoi(argv[1]); int gridHeight = atoi(argv[2]); int videoWidth = desktop_mode.width / gridWidth; int videoHeight = desktop_mode.height / gridHeight; sf::RenderWindow window(sf::VideoMode(videoWidth * gridWidth, videoHeight * gridHeight), "Attract-Mode Plus"); window.setVerticalSyncEnabled(true); std::vector<std::unique_ptr<VideoPlayer>> players; for (int i = 0; i < gridHeight; ++i) { for (int j = 0; j < gridWidth; ++j) { int index = (i * gridWidth + j) % (argc - 3); players.push_back(std::make_unique<VideoPlayer>(argv[index + 3], sf::IntRect(j * videoWidth, i * videoHeight, videoWidth, videoHeight))); } } while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if (event.type == sf::Event::KeyPressed) { if (event.key.code == sf::Keyboard::Space) { for (auto& p : players) p->play(); } if (event.key.code == sf::Keyboard::Escape) { for (auto& player : players) player->player.setVideoSurfaceSize(-1, -1); return 0; } } } window.setActive(true); window.clear(); for (auto& p : players) p->update(window); window.display(); } return 0; }
the message was accidentally added recently, no a bug, I will remove it.
Describe the bug I'm getting
packets not empty
message when video loopsEnvironment:
Looping 1s video yields the following debug log.
Log log.txt
Test code