Automating Toastmasters Meeting Recordings
During the summer, I was nominated and eventually elected to be the Public Relations chair for the Toastmasters club that I am a member of. One of the duties that the role has is to run the social media and other communication methods for the chapter. Oddly fitting that I am the current Secretary for my NSBE chapter which duties are similar in nature.
One of the things that I decided that would be more inviting to get people more active in the chapter is to post recordings of the meetings. This way, people can see what the meeting is like before the participate. They can also become familiar with how things are done before attending a meeting.
Using my GoPro to record the meeting results in large video files. Typical video length is from 10 GB to 18 GB of video at 1080p. Because the files are so large, the GoPro breaks the single video into multiple parts with the largest being 4GB.
One part of the process that I want to improve is the video creation. The multiple video files are rendered to be a single video file. In addition, I brand the video with the chapter name or the URL to the chapter's website. I created a script for this purpose so that I would not have to remember the command each time that I created a video.
#!/bin/bash
for videoFile in *MP4
do
echo "file ${videoFile}" >> ffmpeg.txt
done
/usr/bin/ffmpeg -y -loglevel error -safe 0 -init_hw_device vaapi=foo:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format nv12 -f concat -i "ffmpeg.txt" -filter_hw_device foo -vf "drawtext=textfile:'towertoastmasters.org':fontcolor=white:fontsize=h/25:x=w-tw-30:y=30:box=1:boxborderw=10:boxcolor=black@0.3:enable='gt(t,0)', format=vaapi|nv12,hwupload" -vcodec h264_vaapi "output.mp4"
Yes is a single command that I have created into a script. May eventually make it into a script that does more, but this is it for the current moment.
What this script does is run FFMPEG on the video files, merges them together, adds the branding, and creates a final output file, called "output.mp4" that is ready to be uploaded.
One additional benefit of recording the meeting, is that members that do a speech during the meeting can request a copy of the recording. At this time, still trying to figure out how to get such large video files sent to the members when they do a speech, but I believe that there are some online solutions that are available that could be utilized.
Shell Script
I have decided to create this command into a script that can be deployed and run as a system service. That way I only have to transfer files to the server for processing. Then the script will automatically process them when it runs. By setting this up as a system service, I will not have to start it because it will automatically run once the operating system has finished booting.
#!/bin/bash
while true
do
cd /mnt/3761e00d-e29b-4073-b282-589ade503755/toastmasters
for tsDirectory in $(ls -1d */)
do
if [ -f output.mp4 ]; then
continue;
fi
if [ -f ffmpeg.txt ]; then
rm ffmpeg.txt
fi
touch ffmpeg.txt
for videoFile in *MP4
do
echo "file ${videoFile}" >> ffmpeg.txt
done #end for
/usr/bin/ffmpeg -y -loglevel error -safe 0 -init_hw_device vaapi=foo:/dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format nv12 -f concat -i "ffmpeg.txt" -filter_hw_device foo -vf "drawtext=textfile:'towertoastmasters.org':fontcolor=white:fontsize=h/25:x=w-tw-30:y=30:box=1:boxborderw=10:boxcolor=black@0.3:enable='gt(t,0)', format=vaapi|nv12,hwupload" -vcodec h264_vaapi "output.mp4"
done #end for
sleep 3600
done #end while
System Service
To run the script as a system service, I created the following service file. This file is placed in the /etc/systemd/service directory on Ubuntu 20.04 LTS (may change in future Ubuntu releases).
[Unit]
Description=TM Video Processor
After=network.target
Documentation=https://thealmostengineer.com/technology
[Service]
Type=simple
Restart=always
ExecStart=/home/iamadmin/tmVideoProcessor.sh
User=iamadmin