Video Edition notes on OpenBSD
827 words, 4 minutes
To create the “OpenBSD Workstation for the
People
PeerTube”
video, I used KDEnlive on OpenBSD.
But for reasons, I also had to use other tools.
Install the software
The whole recording and editing process was done on OpenBSD ; using tools that are available as packages for the 7.5/amd64 release.
# pkg_add audacity cmixer ffmpeg mediainfo kdenlive
cmixer
is not a must have ; but it can be easier to look at than a
full mixerctl
output.
Prepare the system
I’m using a simple Jabra Evolve 40 wired headset. It is plugued in my ThinkPad X1 Carbon gen10 using the 3.5mm jack.
By default, OpenBSD does not allow recording from the mic or the webcam.
Have a look at the Multimedia
FAQ
for more information and
options. I just recorded the screen and my voice so there were no need
for sndiod
tuning.
I enabled the mic recording:
$ doas sysctl kern.audio.record=1
I set the volume levels to value that I thought were good for me:
$ doas mixerctl inputs.mic=192 record.volume=192 outputs.master=128
Record the screen
I was using a PiKVM session to record what happened on a remote computer. So all I wanted to capture was the PiKVM window. I stole ideas from Effortless OpenBSD Audio and Desktop Screen Recording Guide, from Rafael Sadowski and How to record a specific window using ffmpeg, from Lu Xu and mixed it into a shell script.
#!/bin/sh
xwininfo | {
while IFS=: read -r k v; do
case "$k" in
*"Absolute upper-left X"*) x=$v;;
*"Absolute upper-left Y"*) y=$v;;
*"Border width"*) bw=$v ;;
*"Width"*) w=$v;;
*"Height"*) h=$v;;
esac
done
for i in 3 2 1; do echo "$i"; sleep 1; done
ffmpeg -y \
-f sndio -thread_queue_size 4096 -i snd/0 \
-f x11grab -thread_queue_size 4096 -framerate 30 -video_size "$((w))x$((h))" \
-i "+$((x+bw)),$((y+bw))" \
-c:a aac -b:a 160k -ar 48000 \
-c:v libx264rgb -crf 0 -b:v 10000k -preset ultrafast \
screenrecord.mp4
}
From a terminal, run the script, select an X window and the recording
starts 3 seconds later.
Press <Ctrl>-C
in the terminal to stop recording the screen.
After each satisfaying take, I simply renamed screenrecord.mp4
to
described its content.
Not that every time the script is called, the “screenrecord.mp4” file
gets overwritten.
Edit and render the video
Using KDEnlive, I added, shrinked and speed up every video bits I needed. In the end, I exported the video results into an H264 encoded video file.
If you’re new to KDEnlive too, here are a list of videos I found useful to get started with:
- Learn KDEnlive in 15 minutes, Chris' Tutorials .
- KDEnlive Tutorial: How To Edit Audio .
- KDEnlive Tutorial: How to Add Track .
- KDEnlive Tutorial: How to Add Transitions .
Remove Audio noise
Not sure if it’s the hardware and/or the sound level, but the audio recording had a bit of “wind” noise ; like a fan blowing in your ears. I personnaly hate this kinda sound so I wanted to remove it.
The directions come from Video noise reduction using KDEnlive and Audacity, from Rich Bowen .
Start extracting the audio track from the video you rendered:
$ ffmpeg -i ffmpeg -i openbsd-workstation.mp4 openbsd-workstation.mp3
Then launch Audacity
and open the audio track. OpenBSD shipped with
Audacity 3.4.2-alpha-20240316 so the menus were a bit different than
those indicated in Rich’s post.
I had to zoom in to locate section with no voice and only the wind noise. From the track zone, click and drag to select a zone with only the noise to be removed.
Then select the Effect > Noise Removal and Repair > Noise Reduction...
menu item. Click the Get Noise Profile
button.
Then use the Select > None
menu item to unselect all selection. And use the
Effect > Noise Removal and Repair > Noise Reduction...
menu item
again. This time, click the Ok
button. Wait until the process is
finished.
When done, export the results using the File > Export Audio...
menu
item. I used the defaults “MP3 Files @ 48000 Hz”.
Replace Audio track in Video
For some reasons, KDEnlive didn’t want me to replace the audio track
with the one I just cleaned. So after a bunch of retries and 어@$#!
, I
decided to do it using ffmpeg
.
$ ffmpeg -i openbsd-workstation.mp4 -i openbsd-workstation-noiseremoved.mp3 \
-c:v copy -map 0:v:0 -map 1:a:0 openbsd-workstation-noiseremoved.mp4
Normalize Audio
I felt like the volume was a bit low compared to what I got from YT
videos. From How can I normalize audio using
ffmpeg?
, I learned ffmpeg
tricks to
correct this.
Using the following ffmpeg
command:
$ ffmpeg -i openbsd-workstation-noiseremoved.mp4 -af "volumedetect" \
-vn -sn -dn -f null /dev/null
I learned that my max_volume
was -4.5 dB. A “proper” value should be
near 0 dB. So I applied the following command:
$ ffmpeg -i openbsd-workstation-noiseremoved.mp4 -af "volume=5.6dB" \
-c:v copy -c:a aac -b:a 192k openbsd-workstation-noiseremoved-normalize.mp4
to raise it. It ended at a level of -0.5 dB which sounds acceptable.
And that’s all for me. Happy Editing!