hiç python bilgim yok, internetten bulduğum kodlarla ekran ve ses kaydı alıyorum 20 saniyelik.
kodlar ayrı ayrı iyi çalışıyorlar, kodları alt alta çalıştırdığımda diğer kod daha sonra çalışmaya başlıyor ve senkron sorunu oluyor.
kodları senkronlu bir şekilde nasıl çalıştırabilirim?
ses kodu
import pyaudio
import wave
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 44100
RECORD_SECONDS = 20
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
print("* recording")
frames = []
for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()ekran kayıt koduimport sys
import time
from screen_recorder_sdk import screen_recorder
def main ():
#hours = int(input("Hours : "))
#seconds = int(input("Seconds : "))
#enable dev logger
screen_recorder.enable_dev_log ()
params = screen_recorder.RecorderParams ()
#intialize the screen recoder
screen_recorder.init_resources (params)
#take screenshot and save it
screen_recorder.get_screenshot (5).save ('sample.png')
print('Screenshot taken')
#start video recording
print('Video Started')
screen_recorder.start_video_recording ('sample.mp4', 30, 8000000, True)
#time limit
#time.sleep (hours*60+seconds)
time.sleep(200)
#stop the recording
screen_recorder.stop_video_recording ()
print('Video Stopped')
if __name__ == "__main__":
main ()