app crashes when using ofVideoPlayer pointers

Hi!

I’ve notice that openframeworks crashes due to segmentation faults when creating and deleting ofVideoPlayers several times.
For testing, I’ve made the following variation of the videoplayer example:

in testApp.h I declare:

  
  
  
  // Pointer to ofVideoPlayer  
  ofVideoPlayer *fingerPointer;  
  
  // Time variables for making periodic actions  
  int seconds;  
  int minutes;  
  int currentTime;  
  int lastActionTime;  
  
  

in testApp.cpp…

  
  
  
void testApp::setup(){  
  
// Initializing time vars  
  seconds = ofGetSeconds();  
  minutes = ofGetMinutes();  
  currentTime = 60 * minutes + seconds;  
  lastActionTime = currentTime;  
  
// create the first videoplayer object  
  fingerPointer = new ofVideoPlayer();  
  fingerPointer->loadMovie("movies/fingers.mov");  
  fingerPointer->play();  
  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
// check current time  
  seconds = ofGetSeconds();  
  minutes = ofGetMinutes();  
  currentTime = 60 * minutes + seconds;  
  
// if 2 seconds since last time then delete and create a video  
  if(currentTime - lastActionTime >= 2)  
  {  
      // update lastActionTime  
      lastActionTime = currentTime;  
  
      // Delete the videoplayer  
      fingerPointer->stop();  
      fingerPointer->closeMovie();  
      delete(fingerPointer);  
  
      // And create a new one  
      fingerPointer = new ofVideoPlayer();  
      fingerPointer->loadMovie("movies/fingers.mov");  
      fingerPointer->play();  
  }  
}  
  
  

On Win32, I’ve appreciate that the application crashes the fourth, fiveth or sixth time it does the delete() and new operation in the update routine. On Linux, the failure is more random but it appears sooner or later . I’ve tested it on a IMac with macOX and surprisingly there are no crashes… maybe becouse Quicktime is the apple’s media player… :frowning:

any suggestion? I’m quite desperate :wink:

thanks in advance!

kike E.

Hey kike

i’ve been testing this under linux with the fingers movie and didn’t manage to make the app crash. some days ago some reported that some formats made his app crash under linux, particularly h264 and mjpeg exported from premiere if i remember well. we solved it by exporting from linux with avidemux.

trying your example with some h264 videos exported in linux makes the app crash after some time and running the app under valgrind, it seems there’s some problem with uninitialized memory in the ffmpeg module for h264.

have you noticed if this happens with some particular video? take a look at the formats of your videos and perhaps try to export them again with a different format.

Also i’ve noticed there were 2 uninitialized variables in ofVideoPlayer, don’t think that’s the problem, but just in case i’ve attached the modified version

arturo

ofVideoPlayer.cpp.zip

great thanks arturo!

that it’s true, on Linux I was loading .mp4 movies, transcoded with VLC. I’ve tried with several videos, can I send you a sample movie?

I noticed that on Linux this failure is quite random, so I don’t think it’s a matter of memory leaks but, as you say, uninitialized memory issues involved with the calls to gstreamer methods within the loadMovie() method (I’ve tested the app without deletes() and news, only closing and loading movies, and the random segmentation fault persists).

I’m going on with these tests and I’ll tell you if something new happens!!

cheers

pd: On Windows I’ve tested again with the fingers.mov file and the app crashes. The problem disapears when commenting the delete() and new lines…

  
  
  
  if(currentTime - lastActionTime >= 2)  
  {  
      // update lastActionTime  
      lastActionTime = currentTime;  
  
      // Delete the videoplayer  
      fingerPointer->stop();  
      fingerPointer->closeMovie();  
      //delete(fingerPointer);  
  
      // And create a new one  
      //fingerPointer = new ofVideoPlayer();  
      fingerPointer->loadMovie("movies/fingers.mov");  
      fingerPointer->play();  
  }  
  
  

mmm, lets see…

that it’s true, on Linux I was loading .mp4 movies, transcoded with VLC. I’ve tried with several videos, can I send you a sample movie?

yes, send me, as much formats we try the best.

I noticed that on Linux this failure is quite random, so I don’t think it’s a matter of memory leaks but, as you say, uninitialized memory issues involved with the calls to gstreamer methods within the loadMovie() method (I’ve tested the app without deletes() and news, only closing and loading movies, and the random segmentation fault persists).

well the memory problems i’ve detected are not in the ofVideoPlayer but in the same ffmpeg libavcodec library.

Hi - did you manage to solve this problem?

I’m getting the same thing - works on Mac, crashes on Windows 7.

Dave

I had the same problem today on Windows 7 while recreating new ofVideoPlayer for playing new mov-files with h264.

I looked in the ofVideoPlayer code and found a call to

  
initializeQuicktime();  

but no call to

  
closeQuicktime();  

anywhere.

After adding the call to ofVideoPlayers destructor and rebuilding ofFrameworkds lib it did no more crash on my system.

Not sure if it is the correct solution, but it seemed plausible to me.