Closed horseyhorsey closed 6 years ago
This sounds like an issue that we've seen (and addressed on the June 5th commit) and I hope that you are using an older version of layers.py and don't have this fix..?
This specific fix addresses an occurs when some MP4 have been optimized by the software that creates them and multiple instances of the same frame are not actually saved within the stream, but counted as part of the total number of frames --the issue is within ffmpeg itself, but the "fix" (work-around) is at line 341 in layers.py and line 352 in the else case in layers.py. Basically this says: "if ffmpeg told us there were more frames in the move, but calling next returns None, then there was a size mismatch so we trust the number of frames we can actually get from ffmpeg instead of the count it returned."
If you have these lines in your layers.py, then it's clearly something else that we need to track down.
It's an .avi, but I did convert a different video file earlier in testing to mp4 to see if that was the issue with no difference.
It seems I have the latest because I used your setup installer just yesterday and that would've pulled latest from here and no difference in the example lines you posted.
It's one of my older games that was made on older version of HD, but to update to py 2.7 I just needed the newer procgame folder. Game is fine apart from that, was smooth to update.
The streaming flag was working on this older version yesterday and this was how it was left for nearly 2 years :)
Might be an idea if I look at the older branch of this game as it was only done yesterday and maybe pull the working code from there.
This is good for me, just used the old code.
def next_frame(self):
"""Returns the frame to be shown, or None if there is no frame."""
#lets check if we are at end of video and if not, grab next frame
#and convert to a surface and shove into frame
# Important: Notify the frame listeners before frame_pointer has been advanced.
# Only notify the listeners if this is the first time this frame has been shown
# (such as if frame_time is > 1).
if self.frame_time_counter == self.frame_time:
self.notify_frame_listeners()
self.frame_time_counter -= 1
rval = None
#now we grab the next frame
if (self.frame_pointer >= self.movie.frame_count) and self.frame_time_counter == 0:
if self.repeat:
self.frame_pointer = 0
self.movie.vc.set(cv.CV_CAP_PROP_POS_FRAMES,0)
elif self.hold:
self.frame_time_counter = self.frame_time
return self.frame
else:
self.frame_time_counter = self.frame_time
return None
if self.frame_time_counter == 0:
rval, video_frame = self.movie.vc.read()
self.frame_pointer += 1
self.frame_time_counter = self.frame_time
if rval is not None:
video_frame = cv2.cvtColor(video_frame,cv2.cv.CV_BGR2RGB)
the_frame = video_frame
# surface = pygame.image.frombuffer(the_frame.tostring(), (self.movie.width, self.movie.height), 'RGB')
surf = sdl2_DisplayManager.inst().make_texture_from_imagebits(bits=the_frame.tostring(), width=self.movie.width, height=self.movie.height, mode='RGB', composite_op = None)
self.frame.pySurface = surf
return self.frame
Can actually see what happened now :) . Was using a mish/mash of the framework. The main cause seems to be the library was updated and all that needed to be added was the cv2.
cv2.cv.CV_CAP_PROP_POS_FRAMES,0
Bit of a weird one here, I will need to check my other games to be sure of this because I'm sure I used this flag alot with it working... if you have a "Movie" set to streaming then it will never go back to the first frame even by force invoking reset.
https://github.com/mjocean/PyProcGameHD-SkeletonGame/blob/a14b9386c43666dede0d47a1a6c2ab9a013ee68c/procgame/assetmanager.py#L201
https://github.com/mjocean/PyProcGameHD-SkeletonGame/blob/a14b9386c43666dede0d47a1a6c2ab9a013ee68c/procgame/dmd/layers.py#L289