私はあなたの要件に従ってプログラムを書いています。同じディレクトリにフォルダキャプチャを作成します。 Png画像は「キャプチャ」フォルダに保存されます。
25fps以上必要な場合は、OBSソフトウェアを使用することをお勧めします。プラットフォームで
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'ScreenCapture.ui'
#
# Created: Sat May 06 15:32:13 2017
# by: pyside-uic 0.2.15 running on PySide 1.2.4
#
# WARNING! All changes made in this file will be lost!
from PySide import QtCore, QtGui
class Ui_ScreenCapture(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setupUi(self)
self.CreateCaptureFolder()
def setupUi(self, ScreenCapture):
ScreenCapture.setObjectName("ScreenCapture")
ScreenCapture.resize(180, 90)
self.verticalLayout = QtGui.QVBoxLayout(ScreenCapture)
self.verticalLayout.setObjectName("verticalLayout")
self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.start = QtGui.QPushButton(ScreenCapture)
self.start.setObjectName("start")
self.gridLayout.addWidget(self.start, 1, 0, 1, 1)
#self.stop = QtGui.QPushButton(ScreenCapture)
#self.stop.setObjectName("stop")
#self.gridLayout.addWidget(self.stop, 1, 1, 1, 1)
self.sbfps = QtGui.QSpinBox(ScreenCapture)
self.sbfps.setPrefix("")
self.sbfps.setMinimum(1)
self.sbfps.setMaximum(60)
self.sbfps.setObjectName("sbfps")
self.gridLayout.addWidget(self.sbfps, 0, 1, 1, 1)
self.label = QtGui.QLabel(ScreenCapture)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
self.verticalLayout.addLayout(self.gridLayout)
self.retranslateUi(ScreenCapture)
QtCore.QMetaObject.connectSlotsByName(ScreenCapture)
def retranslateUi(self, ScreenCapture):
ScreenCapture.setWindowTitle(QtGui.QApplication.translate("ScreenCapture", "Screen Capture", None, QtGui.QApplication.UnicodeUTF8))
self.start.setText(QtGui.QApplication.translate("ScreenCapture", "Start", None, QtGui.QApplication.UnicodeUTF8))
#self.stop.setText(QtGui.QApplication.translate("ScreenCapture", "Stop", None, QtGui.QApplication.UnicodeUTF8))
self.sbfps.setSuffix(QtGui.QApplication.translate("ScreenCapture", " fps", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("ScreenCapture", "Screen Shot FPS", None, QtGui.QApplication.UnicodeUTF8))
###########################################################################
self.fname = 1
self.start.clicked.connect(self.loop)
###########################################################################
def CreateCaptureFolder(self):
if QtCore.QDir("Capture").exists():
print "Folder Exists"
pass
else:
print "Capture folder not exists"
QtCore.QDir().mkdir("Capture")
print "Created folder capture"
def Capture(self):
self.start.setEnabled(False)
self.originalPixmap = None
self.originalPixmap = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId())
format = 'png'
initialPath = QtCore.QDir.currentPath() + "/Capture/"
fileName = initialPath + str(self.fname) + '.' + format
if fileName:
self.originalPixmap.save(fileName, format)
self.fname+=1
def loop(self):
self.timer = QtCore.QTimer()
self.timer.setSingleShot(False)
self.timer.timeout.connect(self.Capture)
self.timer.start(1000/self.sbfps.value())
def stop(self):
self.timer.stop()
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
if not app:
app = QtGui.QApplication(sys.argv)
ui = Ui_ScreenCapture()
ui.show()
sys.exit(app.exec_())
? Windows? –
@JonasByströmno ubuntu –
あなたはビデオをキャプチャすることを意味しますか?なぜビデオをキャプチャしないのですか? http://stackoverflow.com/questions/35097837/capture-video-data-from-screen-in-python – RvdK