View difference between Paste ID: QaQvxfhe and NLWYRjqQ
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
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-
# Create datestamped folder
32+
#procFFmpeg = "/usr/bin/ffmpeg"
33
34
1# Create datestamped folder
35
os.system("mkdir " + binFolder)
36-
os.system("gnome-terminal -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
36+
37
#Record video stream with FFmpeg
38
os.system("gnome-terminal --title=Video_Stream -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
39-
os.system("gnome-terminal -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
39+
40
#Record audio stream with FFmpeg
41
os.system("gnome-terminal --title=Audio_Stream -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
42-
os.system("gnome-terminal -x cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
42+
43
#Capture webcam with VLC
44
os.system("gnome-terminal --title=VLC_Capture -x cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
45
46
#Rename VLC screencast window, move it to top-right corner, and make it sticky
47
os.system("sleep 1 && xdotool  search --name " + '"' + "VLC Media Player" + '"' + " windowmove 1046 0 set_window --name " + '"' + "TCG Screencast" + '"' + " windowraise")
48
49
#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")
50
51
#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
52
53
#Defining what I need in order to open and edit the text file to be used later
54
55-
	os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
55+
56
1. Yes
57
2. No
58
59
Please enter your choice: """)
60
61
if convertPrompt == 1:
62
	#os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
63
	subprocess.call(['/usr/bin/ffmpeg', '-i', videoStream, '-i', audioStream, mergedVideo])
64
	sendmessage(py_notify_title, py_notify_message)
65
else:
66
	exitQuestion = input("Are you done? (Press 1) ")		
67
	if exitQuestion == 1:
68
		exit()
69
	else:
70
		exit()
71
72
exitQuestionFinal = input("Are you done? (Press 1) ")
73
if exitQuestionFinal == 1:
74
	os.system("nautilus " + binFolder)
75
	exit()
76
else:
77
	exit()