Fix Video Player that support generate black image when finish playing video (reach the end of video)

This commit is contained in:
2026-04-23 08:08:34 +10:00
parent f068eb716f
commit c625898f61
4 changed files with 24 additions and 17 deletions

View File

@@ -1491,11 +1491,11 @@ int VideoPlayerClientTest() {
while (true) {
index++;
std::cout << "Index=" << index << std::endl;
if ((index == 200) || (index == 800) || (index == 1200)) { StopVideoPlayer(&videoClient); }
/*if ((index == 200) || (index == 800) || (index == 1200)) { StopVideoPlayer(&videoClient); }
if ((index == 400) || (index == 1000) || (index == 1500)) { StartVideoPlayer(&videoClient); }
if ((index == 1800) || (index == 2200) || (index == 2500)) { StopVideoPlayer(&videoClient); }
if ((index == 2000) || (index == 2300) || (index == 2700)) { StartVideoPlayer(&videoClient); }
if (index > 20000) break;
if (index > 20000) break;*/
auto start = std::chrono::system_clock::now();
cv::Mat* image = nullptr; // ✅ Use a pointer to hold the allocated image
GetVideoPlayerCVImage(&videoClient, width, height, pts,&image);
@@ -1574,11 +1574,11 @@ int FilePlayerClientCVTest() {
while (true) {
index++;
std::cout << "Index=" << index << std::endl;
if ((index == 200) || (index == 800) || (index == 1200)) { StopFilePlayer(&filePlayerClient); }
/*if ((index == 200) || (index == 800) || (index == 1200)) { StopFilePlayer(&filePlayerClient); }
if ((index == 400) || (index == 1000) || (index == 1500)) { StartFilePlayer(&filePlayerClient); }
if ((index == 1800) || (index == 2200) || (index == 2500)) { StopFilePlayer(&filePlayerClient); }
if ((index == 2000) || (index == 2300) || (index == 2700)) { StartFilePlayer(&filePlayerClient); }
if (index > 20000) break;
if (index > 20000) break;*/
auto start = std::chrono::system_clock::now();
cv::Mat* image = nullptr;
GetFilePlayerCVImage(&filePlayerClient, width, height, pts, &image);
@@ -1645,17 +1645,16 @@ int main()
// so this works without the unit test having to link FFmpeg itself.
//ANSCV_PrintFFmpegLicense_S();
//FilePlayerClientDoubleDestroy();
//FilePlayerClientCVTest();
FilePlayerClientCVTest();
// VideoPlayerClientDoubleDestroy();
//VideoPlayerClientTest();
//VideoPlayerClientDoubleDestroy();
// VideoPlayerClientTest();
//OpenCVFunctionTest();
//GenerateVideo();
//VideoTestClient();
// TestGetImage();
//PureOpenCV();
// RSTPTestClient();
RSTPTestCVClient();
//RSTPTestCVClient();
//TestCreateImageFromJpegStringFile();
//TestCreateImageFromFile();
//for (int i = 0; i < 100; i++) {