Automatic Lifelogging: My Setup
VIDEO:
Setting up automatic lifelogging is easy on Linux with the use of system services. You’ll need to be root for the following steps. If your OS uses systemd, you’ll need to create two files:
/etc/systemd/system/record_screen_and_camera.service
[Unit]
Description="Record screen and camera."
Wants=graphical.target
[Service]
Type=simple
ExecStart=/usr/bin/record_screen_and_camera.sh
Restart=on-failure
RestartSec=30
User=username
[Install]
WantedBy=graphical.target
Where username
is your current username (replace it!). This defines a system service to be started when you log in. On failure, it will attempt to restart in 30 second intervals.
We’ll also have to create the script:
/usr/bin/record_screen_and_camera.sh
#!/bin/bash
date=$(date -Iseconds)
framerate=5
filter="[0:v]pad=1920:0:(ow-iw)/2:0[top];[top][1:v]vstack,scale=iw/2:ih/2"
ffmpeg \
-f v4l2 -r ${framerate} -s 1280x720 -vcodec rawvideo -i /dev/video0 \
-f x11grab -r ${framerate} -s 1920x1080 -i :0.0 \
-filter_complex "${filter}" \
-vcodec libx265 -crf 28 "/path/to/storage/${date}.mkv"
Here you’ll need to replace path/to/storage
with a directory which is available at system startup. If you’re dual-booting with Windows, you may want to create a /storage
NTFS partition which is automatically mounted from /etc/fstab
. You’ll need to disable “fast boot” on Windows (a minor inconvenience), and then both OSes can access the storage partition.
The script also assumes that you have a single 1920x1080 screen and a 1280x720 built-in camera at /dev/video0
. You may need to adapt the resolutions otherwise. It records video at a frame rate of 5 to ease hardware load. Increase it for smoother video at the cost of higher CPU load and storage requirements.
Next, we need to enable the system service. First, let’s make our script executable:
chmod ugo+x /usr/bin/record_screen_and_camera.sh
Then, enable the system service and start it:
systemctl enable --now record_screen_and_camera.service
If everything worked, you should now find your camera light shining (if you have one), and a video should be recorded to your storage location. The service will stop automatically at shutdown, and re-start when you log in after startup.
AUDIO:
I manually use AudioRec with the date and time as the default title, and automatic deletion upon uploading to my unlimited cloud storage I can’t actually access on my own since it is in a data trust. I start a new file whenever I start or end my day, or before a social event.
For audio files I have permission to access myself, I manually upload it to my other unlimited cloud storage option. I have unlimited Google Drive thanks to Columbia, and I think other students would also be able to have this thanks to Google for Education.
APPS:
I love my:
Fitbit, Daylio, Daily Dozen, and Dozy apps (and will detail why in a future post).
Happy lifelogging!