View difference between Paste ID: NLWYRjqQ and WTnx12KC
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
13+
import os, datetime, pynotify
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
binFolder = os.getenv("HOME") + "/Videos/Desktop_Recording/" + nowstring + "/"
28
videoStream = binFolder + "desktop_recording_on_" + nowstring + ".mkv"
29
audioStream = binFolder + "microphone_input_on_" + nowstring + ".mp3"
30
mergedVideo = binFolder + "screencast_on_" + nowstring + ".mkv"
31
32
# Create datestamped folder
33-
os.system("cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
33+
34
35
#Record video stream with FFmpeg
36
os.system("gnome-terminal -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
37
38
#Record audio stream with FFmpeg
39
os.system("gnome-terminal -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
40
41
#Capture webcam with VLC
42
os.system("gnome-terminal -x cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
43
44
#Rename VLC screencast window, move it to top-right corner, and make it sticky
45
os.system("sleep 1 && xdotool  search --name " + '"' + "VLC Media Player" + '"' + " windowmove 1046 0 set_window --name " + '"' + "TCG Screencast" + '"' + " windowraise")
46
#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
47
48
convertPrompt = input("""Do you want to merge the streams? 
49
1. Yes
50
2. No
51
52
Please enter your choice: """)
53
54
if convertPrompt == 1:
55
	os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
56
	sendmessage(py_notify_title, py_notify_message)
57
else:
58
	exitQuestion = input("Are you done? (Press 1) ")		
59
	if exitQuestion == 1:
60
		exit()
61
	else:
62
		exit()
63
64
exitQuestionFinal = input("Are you done? (Press 1) ")
65
if exitQuestionFinal == 1:
66
	os.system("nautilus " + binFolder)
67
	exit()
68
else:
69
	exit()