How I made video recording software (TURN ON SUBTITLES)
00:00 Intro
01:09 Modules
02:27 File Writer and File Naming
04:22 Thread
04:45 Audio Recorder
07:50 Video Recorder
13:11 Video Writing Done
14:20 File Merging
14:59 File Deletion
15:25 How To Use
16:28 Plans For The Future
17:33 Why This Video How It Is
# https://www.geeksforgeeks.org/create-a-screen-recorder-using-python/
# info on .avi file type: https://www.aiseesoft.com/resource/avi-vs-mp4.html
# https://stackoverflow.com/questions/22748617/python-avi-to-mp4
# info on .wmv file type: https://www.bing.com/search?q=wmv+files&cvid=7e9ff449ece94cda86b5fd1ec94ce4fd&aqs=edge.5.69i57j0l6.4655j0j9&FORM=ANAB01&PC=U531&adlt=strict
# https://stackoverflow.com/questions/30509573/writing-an-mp4-video-using-python-opencv
# mss module: https://python-mss.readthedocs.io/examples.html
# info on mss: https://stackoverflow.com/questions/65459388/typeerror-expected-ptrcvumat-for-argument-mat-using-mss-library-in-python, https://nitratine.net/blog/post/how-to-take-a-screenshot-in-python-using-mss/
# cropping info (maybe not working): https://github.com/opencv/opencv/issues/18120, https://www.life2coding.com/crop-image-using-mouse-click-movement-python/#:~:text=You%20can%20easily%20crop%20an%20image%20using%20mouse,you%20need%20call%20the%20OpenCV%20cv2.setMouseCallback%20%28%E2%80%9Cwindow%E2%80%9D%2C%20image%29.
# open cv2 documentation: https://docs.opencv.org/3.4/d4/d15/group__videoio__flags__base.html#gaeb8dd9c89c10a5c63c139bf7c4f5704d
# WORKING CROPPING: https://stackoverflow.com/questions/15589517/how-to-crop-an-image-in-opencv-using-python
# putting text on a cv2 window without an image: https://answers.opencv.org/question/219860/can-i-use-cv2puttext-on-a-window-without-an-image/
# info on recording audio: https://realpython.com/playing-and-recording-sound-python/, https://python-sounddevice.readthedocs.io/en/latest/, https://python-sounddevice.readthedocs.io/en/latest/installation.html
# info on threading: https://docs.python.org/3/library/threading.html, https://docs.python.org/3/library/threading.html#threading.Thread.run, https://www.youtube.com/watch?v=jnrCpA1xJPQ, https://www.datacamp.com/community/tutorials/threading-in-python,
# putting audio and video together: https://stackoverflow.com/questions/28219049/combining-an-audio-file-with-video-file-in-python
# parallel file running: https://stackoverflow.com/questions/51969662/run-multiple-python-scripts-at-the-same-time
# info on keyboard module: https://www.delftstack.com/howto/python/python-detect-keypress/#:~:text=Here%2C%20we%20are%20using%20three%20methods%20to%20detect,p.%20The%20read_key%20%28%29%20function%20returns%20a%20character.
# info on killing a thread: https://www.geeksforgeeks.org/python-different-ways-to-kill-a-thread/
# create a sound file with arbitrary duration: https://python-sounddevice.readthedocs.io/en/0.4.1/examples.html?highlight=recording%20with%20arbitrary%20duration#recording-with-arbitrary-duration
# (not used)info on pynput module: https://pythonhosted.org/pynput/keyboard.html#monitoring-the-keyboard
# detecting keypresses without blocking: https://stackoverflow.com/questions/24072790/detect-key-press-in-python,
# combining audio and video:https://www.bing.com/videos/search?q=python+how+to+merge+audio+and+video+files&adlt=strict&view=detail&mid=BEAA9A97E61C61E832F9BEAA9A97E61C61E832F9&&FORM=VRDGAR&ru=%2Fvideos%2Fsearch%3Fq%3Dpython%2Bhow%2Bto%2Bmerge%2Baudio%2Band%2Bvideo%2Bfiles%26FORM%3DHDRSC3%26adlt%3Dstrict&adlt=strict
# importing the required packages
import pyautogui
import cv2
import numpy as np
from PIL import Image
import moviepy.editor as mpy
from moviepy.editor import *
import ffmpeg
import time
import datetime
import os
import sys
import argparse
import tempfile
import queue
import sounddevice as sd
from scipy.io.wavfile import write
import wave
import soundfile as sf
import keyboard
import threading
import trace
python = True
toggleable = True
d = datetime.date.today()
d = str(d)
t = time.localtime()
current_time = time.strftime("%H:%M:%S", t)
codec = cv2.VideoWriter_fourcc(*"mp4v")
filename1 = 'TRecording-' + current_time + '_' + d + '.mp4'
filename2 = 'TRecording-' + current_time + '_' + d + '.wav'
filename3 = 'Recording-' + current_time + '_' + d + '.mp4'
filename1 = filename1.replace(':', '-')
filename2 = filename2.replace(':', '-')
filename3 = filename3.replace(':', '-')
filename = filename1
if python == True:
resolution = (1614, 706)
else:
resolution = (1920, 1080)
Fps = 23.0
fs = 44100
tt = 0
outvideo = cv2.VideoWriter(filename, codec, Fps, resolution)
cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
cv2.namedWindow("FPS", cv2.WINDOW_FREERATIO)
cv2.namedWindow("Audio", cv2.WINDOW_FREERATIO)
cv2.resizeWindow("Live", 480, 270)
cv2.resizeWindow("FPS", 430, 150)
cv2.resizeWindow("Audio", 430, 150)
cv2.moveWindow("FPS", 1939, 310)
cv2.moveWindow("Audio", 1939, 500)
togled = 0
n = 0
math = 0