View difference between Paste ID: cefKhKLH and QaQvxfhe
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/python
2
#/home/clockworkpc/bin/screencast.py
3
4
# Released under a GPLv3 Licence by Clockwork PC 2013
5
# www.clockworkpc.com.au
6
7
# You are entitled to the following four freedoms:
8
# Freedom 0: To run this program for any purpose
9
# Freedom 1: To study how this program works and change it to make it do what you wish
10
# Freedom 2: To redistribute copies so you can help your neighbour
11
# Freedom 3: To distribute copies of your modified version to others
12
13
import os, datetime, pynotify, subprocess
14
15
py_notify_title = "Screencast"
16
py_notify_message = "Video has been merged"
17
18
def sendmessage(py_notify_title, py_notify_message):
19
	pynotify.init("Test")
20
	notice = pynotify.Notification(py_notify_title, py_notify_message)
21
	notice.show()
22
	return
23
24
now = datetime.datetime.now()
25
nowstring = str(now.strftime("%Y-%m-%d_%A_%H:%M:%S"))
26
27
# Define folders and files
28
binFolder = os.getenv("HOME") + "/Videos/Desktop_Recording/" + nowstring + "/"
29
videoStream = binFolder + "desktop_recording_on_" + nowstring + ".mkv"
30
audioStream = binFolder + "microphone_input_on_" + nowstring + ".mp3"
31
mergedVideo = binFolder + "screencast_on_" + nowstring + ".mkv"
32
#procFFmpeg = "/usr/bin/ffmpeg"
33
proc1 = "/usr/bin/ffmpeg"
34-
1# Create datestamped folder
34+
proc2 = "/bin/mkdir"
35
36
# Create datestamped folder
37
os.system("mkdir " + binFolder)
38
39
#Record video stream with FFmpeg
40
os.system("gnome-terminal --title=Video_Stream -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
41
42
#Record audio stream with FFmpeg
43
os.system("gnome-terminal --title=Audio_Stream -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
44
45
#Capture webcam with VLC
46
os.system("gnome-terminal --title=VLC_Capture -x cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
47
48
#Rename VLC screencast window, move it to top-right corner, and make it sticky
49
os.system("sleep 1 && xdotool  search --name " + '"' + "VLC Media Player" + '"' + " windowmove 1046 0 set_window --name " + '"' + "TCG Screencast" + '"' + " windowraise")
50
51
#os.system("sleep 1 && xdotool  search --name " + '"' + "VLC Media Player" + '"' + " windowmove 1046 0 set_window --name " + '"' + "TCG Screencast" + '"' + " windowraise windowactivate key --clearmodifiers alt+space type a")
52
53
#Not sure how to make it visible in all workspaces though, for some reason the command "wmctrl -r <WIN> -b add,sticky" doesn't work with os.system
54
55
#Defining what I need in order to open and edit the text file to be used later
56
57
convertPrompt = input("""Do you want to merge the streams? 
58
1. Yes
59
2. No
60
61
Please enter your choice: """)
62
63-
	subprocess.call(['/usr/bin/ffmpeg', '-i', videoStream, '-i', audioStream, mergedVideo])
63+
64
	#os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
65
	#subprocess.call(['/usr/bin/ffmpeg', '-i', videoStream, '-i', audioStream, mergedVideo])
66
	subprocess.call([proc1, '-i', videoStream, '-i', audioStream, '-ss', '00:00:02.0', '-b:v', '2000k', mergedVideo])
67
	sendmessage(py_notify_title, py_notify_message)
68
else:
69
	exitQuestion = input("Are you done? (Press 1) ")		
70
	if exitQuestion == 1:
71
		exit()
72
	else:
73
		exit()
74
75
exitQuestionFinal = input("Are you done? (Press 1) ")
76
if exitQuestionFinal == 1:
77
	os.system("nautilus " + binFolder)
78
	exit()
79
else:
80
	exit()