From 21fb984954a0701cfb87cf6f927406db423a22e5 Mon Sep 17 00:00:00 2001 From: svsdval Date: Wed, 16 Oct 2024 14:06:34 +0700 Subject: [PATCH] =?UTF-8?q?-=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D1=81=D1=8F=D0=BA=D0=B0?= =?UTF-8?q?=20=D1=81=20opencv=20=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=81=D0=B8=D0=B9,=20=D1=87=D1=82=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=D0=B2=D0=BE=D0=B4=D0=B8=D1=82=20=D0=BA=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BC=D0=B5=D0=B6?= =?UTF-8?q?=D0=B4=D1=83=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B0?= =?UTF-8?q?=D0=B5=D0=BC=D1=8B=D0=BC=20=D0=BA=D0=B0=D0=B4=D1=80=D0=BE=D0=BC?= =?UTF-8?q?=20=D0=B8=20=D1=81=D1=87=D0=B8=D1=82=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2m.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/v2m.py b/v2m.py index 6fe7f50..8fbcf5e 100755 --- a/v2m.py +++ b/v2m.py @@ -175,18 +175,22 @@ def getFrame(framenum:int = -1) -> None: if ( fps == 0 ): return + goto_frame_by_msec=False if ( framenum != -1 ): #vidcap.set(CAP_PROP_POS_FRAMES, int(framenum) ) # problems with mpeg formats ... - oldframenum = int(round(vidcap.get(1))) - - frametime = framenum * 1000.0 / fps - print("go to frame time :" + str(frametime)) - success = vidcap.set(CAP_PROP_POS_MSEC, frametime) - if not success: - print("Cannot set frame position from video file at " + str(framenum)) - success = vidcap.set(CAP_PROP_POS_FRAMES, int(oldframenum) ) + if goto_frame_by_msec: + oldframenum = int(round(vidcap.get(1))) + frametime = framenum * 1000.0 / fps + print("go to frame time :" + str(frametime)) + success = vidcap.set(CAP_PROP_POS_MSEC, frametime) + if not success: + print("Cannot set frame position from video file at " + str(framenum)) + success = vidcap.set(CAP_PROP_POS_FRAMES, int(oldframenum) ) + else: + success = vidcap.set(CAP_PROP_POS_FRAMES, framenum ) + curframe = vidcap.get(CAP_PROP_POS_FRAMES) if (curframe != framenum ): print("OpenCV bug, Requesting frame " + str(framenum) + " but get position on " +str(curframe)) @@ -868,7 +872,7 @@ def drawframe( lastimage = None): global mousex, mousey global keyp_colormap_colors_pos global keyp_colormap_pos - global frame + global frame, image global printed_for_frame global notes_tmp global notes_pressed_color @@ -1104,14 +1108,14 @@ def processmidi(): print("starting from frame:" + str(prefs.startframe)) getFrame( prefs.startframe ) notecnt=0 - lastimage = image + lastimage = image.copy() while success: if (frame % 10 == 0): glBindTexture(GL_TEXTURE_2D, Gl.bgImgGL) if (frame % 200 == 0): loadImage(frame) - lastimage = image + lastimage = image.copy() #glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) #glTexImage2D(GL_TEXTURE_2D, 0, 3, video_width, video_height, 0, GL_BGR, GL_UNSIGNED_BYTE, image ) #glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)