Skip to content

Instantly share code, notes, and snippets.

@LinuxPhreak
Last active October 7, 2018 05:35
Show Gist options
  • Select an option

  • Save LinuxPhreak/4dc900ee02ec82e88740ecece7541ab6 to your computer and use it in GitHub Desktop.

Select an option

Save LinuxPhreak/4dc900ee02ec82e88740ecece7541ab6 to your computer and use it in GitHub Desktop.
Stopping the Video Recording Issue
#!/usr/bin/env python3
import sys
import os
import subprocess
from PyQt5 import QtCore, QtGui, QtWidgets
from pynput.keyboard import Key, Controller
from ffmpeg import Ui_frmMain
class ffmpeg(Ui_frmMain):
def __init__(self, dialog):
Ui_frmMain.__init__(self)
self.setupUi(dialog)
self.pbRecord.clicked.connect(self.filename)
keyboard = Controller() #Problem here
pressQ = keyboard.press('q') #Problem here
self.pbQuit.clicked.connect(pressQ) #Problem here
def filename(self):
vidname = os.environ['HOME'] + "/Videos/" + self.txtFile.text() + ".mkv" #sets the directory to save image in
cmd = subprocess.run(["/usr/bin/ffmpeg", "-video_size", "1920x1080", "-framerate", "20", "-f", "x11grab", "-i", ":0.0", "-f", "pulse", "-ac", "2", "-i", "default", vidname])
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
dialog = QtWidgets.QMainWindow()
prog = ffmpeg(dialog)
dialog.show()
sys.exit(app.exec_())
@LinuxPhreak
Copy link
Copy Markdown
Author

Gives me the following error.

qTraceback (most recent call last):
File "screen-recorder.py", line 28, in
prog = ffmpeg(dialog)
File "screen-recorder.py", line 17, in init
self.pbQuit.clicked.connect(pressQ)
TypeError: argument 1 has unexpected type 'NoneType'


NOTE: It simulates the q key being pressed after the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment