Advertisement
clockworkpc

Screencasting Script with FFmpeg and VLC on Ubuntu

Jun 17th, 2013
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
  14.  
  15. now = datetime.datetime.now()
  16. nowstring = str(now.strftime("%Y-%m-%d_%A_%H:%M:%S"))
  17.  
  18. binFolder = os.getenv("HOME") + "/Videos/Desktop_Recording/" + nowstring + "/"
  19. videoStream = binFolder + "desktop_recording_on_" + nowstring + ".mkv"
  20. audioStream = binFolder + "microphone_input_on_" + nowstring + ".mp3"
  21. mergedVideo = binFolder + "screencast_on_" + nowstring + ".mkv"
  22.  
  23. # Create datestamped folder
  24. os.system("mkdir " + binFolder)
  25.  
  26. #Record video stream with FFmpeg
  27. os.system("gnome-terminal -x ffmpeg -f x11grab -r 30 -s 1366x768 -i :0.0 -c:v libx264 -threads 0 " + videoStream)
  28.  
  29. #Record audio stream with FFmpeg
  30. os.system("gnome-terminal -x ffmpeg -f alsa -ac 2 -i pulse " + audioStream)
  31.  
  32. #Capture webcam with VLC
  33. os.system("cvlc --intf rc v4l2:// :v4l2-dev=/dev/video0 :v4l2-width=320 :v4l2-height=240")
  34.  
  35.  
  36. convertPrompt = input("""Do you want to merge the streams?
  37. 1. Yes
  38. 2. No
  39.  
  40. Please enter your choice: """)
  41.  
  42. if convertPrompt == 1:
  43.     os.system("gnome-terminal -x ffmpeg -i " + videoStream + " -i " + audioStream + " -b 2000k " + mergedVideo)
  44. else:
  45.     exitQuestion = input("Are you done? (Press 1) ")       
  46.     if exitQuestion == 1:
  47.         exit()
  48.     else:
  49.         exit()
  50.  
  51. exitQuestionFinal = input("Are you done? (Press 1) ")
  52. if exitQuestionFinal == 1:
  53.     os.system("nautilus " + binFolder)
  54.     exit()
  55. else:
  56.     exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement