- 
  Notifications
 You must be signed in to change notification settings 
- Fork 7
Open
@timothyhalim 
 
Description
Get started
- I have read Contributing guidelines.
- I have confirmed that my problem could not be solved by the troubleshooting section in the documentation.
- I agree to follow the Code of Conduct.
- I have confirmed that my issue is not duplicated with an existing issue.
Description
Hi @cainmagi
When I try to extract last 2 frames of a video it return None
Here is the code used :
from PySide2.QtWidgets import QWidget, QLabel, QVBoxLayout, QApplication, QSlider
from PySide2.QtGui import QImage, QPixmap
from PySide2.QtCore import Qt
import mpegCoder
mpegCoder.setGlobal(dumpLevel=0)
class Player(QWidget):
 def __init__(self, parent=None):
 super(Player, self).__init__(parent)
 self._layout = QVBoxLayout(self)
 self.image = QLabel()
 self.slider = QSlider(Qt.Horizontal)
 self.slider.valueChanged.connect(self.extract_frame)
 self._layout.addWidget(self.image)
 self._layout.addWidget(self.slider)
 self.frames = []
 self.open_file()
 
 def close(self):
 self.decoder.clear()
 return super(Player, self).close()
 
 def open_file(self):
 self.decoder = mpegCoder.MpegDecoder()
 self.decoder.setParameter(nthread=4)
 opened = self.decoder.FFmpegSetup(r"30.mp4")
 
 if opened:
 duration = self.decoder.getParameter("duration")
 fps = self.decoder.getParameter("avgFrameRate")
 frameCount = duration*fps
 print("Video frame count is", frameCount)
 self.slider.setRange(0, frameCount-1) # -1 since start from 0
 
 self.extract_frame(0)
 
 def extract_frame(self, frame):
 print(frame)
 p = self.decoder.ExtractFrame(frame, 1)
 
 data = p[0].data
 height = p[0].shape[0]
 width = p[0].shape[1]
 channel = p[0].shape[2]
 pixmap = QPixmap.fromImage(QImage(data, width, height, channel*width, QImage.Format_RGB888))
 self.image.setPixmap(pixmap)
 
 
if __name__ == "__main__":
 import sys
 app = QApplication(sys.argv)
 p = Player()
 p.show()
 app.exec_()
You can change the frame by changing the slider
Here is the video used, 10sec/300frame video @30fps 
the time code should be from 00:00 to 09:29
beeping every 1 sec/ 30 frame
30.mp4
Not really sure if this is a bug or if I'm doing something wrong
To Reproduce
- Run the code
- Change the slider
- Error occur when extracting last 2 frame
Traceback
No response
Behaviors
- The expected behaviors: able to extract every frame of the video
- The actual behaviors: unable to extract last 2 frame of the video
Screenshots
No response
OS
Windows 10
Python version
3.9
numpy version
1.23.1
mpegCoder version
3.2.4
Additional context
No response