Python Video Production System
My first training video, Game Development with PyGame, involved a lot of editing. I have seen coding demonstrations at conferences, with the presenter typing and explaining the code at the same time. They make it look so easy. Trying to do it myself, without hesitation or humming and hawing, I realised that takes a lot of experience and preparation.
To get really clear sound and professional sounding voice over, I decided to record it one sentence at a time. I created a Python program which shows me the next sentence to record, records it, lets me play it back and re-record it if necessary. The front end consists of some simple webpages in the browser, with Flask driving the back end.
There is a very powerful Python library, pyAutoGUI, which allows Python to type text and move the mouse pointer. I used it to slowly type and run Python code, to create examples of Python code in action. It also presses the screen recorder’s start and stop button, to capture the code as it is being entered and run.
Driven by Python, ffmpeg is used to combine the images, videos and source recordings into video snippets, and then into video segments.
The starting point is a plain text file, one per chapter/segment. Unique identifiers are automatically added to the text files. These are linked to the audio recordings, making it very easy to re-arrange the recordings. Special codes are used to identify Python code, code to run in a terminal window, slide layout and more.
For example ‘vo’ for voice over, ‘>>>’ for Python code, and ‘t_h1’ and ‘t_li’ header 1 and list items for the text slides
Having created three 90-minute videos using this system, I’m very pleased with the results. And I’m still amazed by how easy it is to use, and how effective it is in ‘glueing-together’ functionality from other sources, such as external packages and some of the enormous number of freely available Python packages. This is why, when I was asked to do a talk for PyBerlin about the system, I called it “Python: my favourite Swiss army knife”.