Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- #/home/clockworkpc/bin/screencast.py
- # Released under a GPLv3 Licence by Clockwork PC 2013
- # www.clockworkpc.com.au
- # You are entitled to the following four freedoms:
- # Freedom 0: To run this program for any purpose
- # Freedom 1: To study how this program works and change it to make it do what you wish
- # Freedom 2: To redistribute copies so you can help your neighbour
- # Freedom 3: To distribute copies of your modified version to others
- # You will need to install pynotify and googlecl:
- # sudo apt-get install googlecl python-notify xcowsay
- import os, datetime, pynotify, subprocess
- py_notify_title = "Screencast"
- py_notify_message = "Video has been merged"
- def sendmessage(py_notify_title, py_notify_message):
- pynotify.init("Test")
- notice = pynotify.Notification(py_notify_title, py_notify_message)
- notice.show()
- return
- now = datetime.datetime.now()
- nowstring = str(now.strftime("%Y-%m-%d_%A_%H:%M:%S"))
- # Define folders and files
- binFolder = os.getenv("HOME") + "/Videos/Desktop_Recording/" + nowstring + "/"
- videoStream = binFolder + "desktop_recording_on_" + nowstring + ".mkv"
- audioStream = binFolder + "microphone_input_on_" + nowstring + ".mp3"
- mergedVideo = binFolder + "screencast_on_" + nowstring + ".mkv"
- #procFFmpeg = "/usr/bin/ffmpeg"
- proc1 = "/usr/bin/ffmpeg"
- proc2 = "/bin/mkdir"
- # Create datestamped folder
- os.system("mkdir " + binFolder)
- #Record video stream with FFmpeg
- os.system("gnome-terminal --title=Video_Stream -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
- #Record audio stream with FFmpeg
- os.system("gnome-terminal --title=Audio_Stream -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
- #Capture webcam with VLC
- os.system("gnome-terminal --title=VLC_Capture -x cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
- #Rename VLC screencast window, move it to top-right corner, and make it sticky
- os.system("sleep 1 && xdotool search --name " + '"' + "VLC Media Player" + '"' + " windowmove 1046 0 set_window --name " + '"' + "TCG Screencast" + '"' + " windowraise")
- #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")
- #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
- #Defining what I need in order to open and edit the text file to be used later
- convertPrompt = input("""Do you want to merge the streams?
- 1. Yes
- 2. No
- Please enter your choice: """)
- if convertPrompt == 1:
- #os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
- #subprocess.call(['/usr/bin/ffmpeg', '-i', videoStream, '-i', audioStream, mergedVideo])
- subprocess.call([proc1, '-i', videoStream, '-i', audioStream, '-ss', '00:00:02.0', '-b:v', '2000k', mergedVideo])
- sendmessage(py_notify_title, py_notify_message)
- videoTitle = raw_input("Enter the video title: ")
- os.system("google youtube post --verbose --category News " + mergedVideo + " --title " + "'" + videoTitle + "'")
- else:
- exitQuestion = input("Are you done? (Press 1) ")
- if exitQuestion == 1:
- exit()
- else:
- exit()
- exitQuestionFinal = input("Are you done? (Press 1) ")
- if exitQuestionFinal == 1:
- os.system("nautilus " + binFolder)
- exit()
- else:
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement