Notes on video editing
Recently I was asked to create a video on assemblying LEGO constructions to visualize planar motions. The video was planned to be presented at the International Conference on STEAM Education, Jerusalem, Israel.
Flyer of the STEAM Education conference
In this note I summarize my experiences on assembling such a video by using (mostly) free software for the preparations. Since English is not my native tounge, I decided to use the text of a recent paper written for the Virginia Mathematics Teacher journal. It has already been peer reviewed, so I could be sure that there were no big issues with its English.- As a first attempt I read the text loudly and learned that the duration of the video will be over 12 minutes. My limit was about 10 minutes, so I had to remove some sentences. Also, I decided to edit some of the sentences to be shorter and easier to follow. In some cases I split long sentences into two shorter ones.
- I then created a table with 3 columns: the first one was for simple enumeration, the second one contained the text, each sentence in a different cell, and the third one contained a short memo on plans what kind of video should be used for the given sentence.
- I checked the Internet about suggestions on using text-to-speech software. In my home office I use Ubuntu Linux 17.10, so my first option was to try flite and espeak. Basically, I did not want to use my own voice for the video. I preferred to ask one of my students (some of them surely has better pronounciation than I), but at the end of the semester it was difficult to find someone with dedicated time for that. Actually, I was not satisfied with the quality of these two pieces of software, so I decided to give Windows software a try.
- I have some machines at home with Windows 10 installed, so I gave Balabolka a try. Its default settings were very promising (it uses Microsoft's Speech API 5 by default). I decided to use it to have .wav audio output of my textual input. Some minor changes had to be performed on my text, e.g. the year numbers had to be changed a bit, and the labels of some geometric objects and the math formulas, too.
- Later I learned that Balabolka has a command line tool as well that supports creating subtitles. That is, the tool balcon.exe is capable of producing .srt files from the .txt inputs. A little trick was to save the sound output to a file, so that the .srt file was created very quickly. (Actually I had to change the output .srt a bit by writing back the original texts on year numbers, geometric labels and math formulas, but it was a quick step. Also, I split one very long sentence into more pieces.)
- When having .srt files, there are two options to show them on the video. One can directly "print" them over the movie and save them permanently ("hard" subtitles), or just to show them optionally ("soft" subtitles). I went for the second option and kept the .srt files only. This was useful later when uploading the video and the subtitles separately to YouTube. (Hard subtitles can be nicely created with the handbrake package. I learned that the subtitles must be enumerated in a proper way, shown at the Wikipedia article SubRip, otherwise the subtitling will not work.)
- The biggest part of work was done by using kdenlive. It is a cross-platform tool with a nice graphical user interface. It is not always self-explanatory, but mostly. The biggest challenge was to correctly add cross-fading between videos. A video tutorial was very helpful for me. The most problematic issue was to learn that kdenlive sometimes incorrectly detects the channels for fading from and to, and this must be fixed manually later.
- The short video parts that showing the LEGO constructions while moving were created by recording movies by two different cameras. My students Cornelia and Özge used a Nikon D3200 and an iPad to record the short videos in 25 and 30 FPS, respectively, in 1080p HD. (These were the default settings.)
- Also, the GeoGebra tutorial videos were recorded in Linux, on my 1080p HD monitor, by using Gnome Xorg as graphical desktop environment and the tool gtk-recordmydesktop. (Note that this tool requires Xorg mode instead of Wayland which is the default in newer Ubuntu versions.) I used Google Chrome to open the GeoGebra applets and clicked on the icon to set them full-screen. I simply sent a termination signal to gtk-recordmydesktop (by stopping it on the console) to notify it to stop recording start encoding.
- kdenlive can cut short movies by starting them from an arbitrary position, but I also used ffmpeg to have as short videos as inputs as possible. A short tutorial is available on AskUbuntu.
- A nice online tool helped converting a .gif input to .avi. I needed the short video on Watt's linkage used in car suspensions several times consecutively, and kdenlive had problems by concatenating the same .gif after each other. With .avi inputs, luckily, it was not a problem any longer.
- kdenlive had some problems with speeding up some input videos. The following command line helped to slow down the motion by 50%: ffmpeg -i input.avi -c:v libx264 -crf 20 -c:a aac -strict -2 -filter:v "setpts=2.0*PTS" output.avi.
- Since the beginning of the movie started earlier than the audio (by 5 seconds), finally I needed another online tool for the .srt file to shift the subtitles by 5 seconds. This tool requires the .srt input in DOS text format (with CR/LF), so I needed first the unix2dos tool (from the dos2unix package), too.
- When rendering the final video, I used the default .webm format. This can also be uploaded to YouTube.
The final result can be found on YouTube. In case I will have some free time I would be happy to improve some parts of it. For the reference, all ingredients can be downloaded from my Google Drive folder (please rename the files to contain "percent" characters in their filename instead of "underscore"). Credits for some external materials are also available.
Comments