AI is making linux so much better
This is happening through (1) making it much more powerful and (2) making it easier to deal with some of the drawbacks.
- The open nature of Linux makes it easy to script for!
- No more hunting around the internet for solutions to your errors
Example, obs replacement for desktop recording. I use OBS on my mac to record myself and send that out to the company. It’s a great practice which has saved me countless hours of meetings. I’m using a machine from 2013, OBS would be overkill. I asked an AI agent to write a script which uses FFMPEG to do the same, I even told it to capture video of me through my webcam!
These were the results after 3 minutes of back and forth.
#!/bin/sh
#This records a 4k screen and includes my face using video feed.
#This little script records my screen using minimal dependencies
#Dependencies are: ffmpeg ffplay wmctrl xdotool
# Settings
CAM_WIDTH=480
CAM_HEIGHT=270
SCREEN_WIDTH=3840
SCREEN_HEIGHT=2160
MARGIN=50
WINDOW_TITLE="WebcamPreview"
# Calculate position for bottom-right
POS_X=$((SCREEN_WIDTH - CAM_WIDTH - MARGIN))
POS_Y=$((SCREEN_HEIGHT - CAM_HEIGHT - MARGIN))
# Start ffplay webcam preview in the background
ffplay -f v4l2 -video_size ${CAM_WIDTH}x${CAM_HEIGHT} -i /dev/video0 \
-noborder -window_title "$WINDOW_TITLE" -x $CAM_WIDTH -y $CAM_HEIGHT \
-an -fflags nobuffer -hide_banner -loglevel quiet &
PREVIEW_PID=$!
# Wait until the window is created
until wmctrl -l | grep -q "$WINDOW_TITLE"; do sleep 0.2; done
# Move window to bottom-right and make it always-on-top
wmctrl -r "$WINDOW_TITLE" -e 0,$POS_X,$POS_Y,$CAM_WIDTH,$CAM_HEIGHT
wmctrl -r "$WINDOW_TITLE" -b add,above,sticky
# Start screen and audio recording
ffmpeg \
-f x11grab -video_size ${SCREEN_WIDTH}x${SCREEN_HEIGHT} -i :0.0 \
-f pulse -i default \
-vcodec libx264 -preset veryfast -crf 23 \
-acodec aac -b:a 128k \
-y screen_recording.mp4
# After recording ends, close the preview if it's still running
kill $PREVIEW_PID 2>/dev/null
This is incredible, it works perfectly and takes minimal resources. All you need is some basic knowledge on linux to be able to use this with quick keyboard shortcuts! It’s even more powerful than the native solution offered by mac which:
- Does not allow me to capture the video from my webcam
- The weight of the files generated is so big that I had to reconvert to .mp4 to be able to do anything useful with the files!
I wonder how much more simple automation I can do within my own machine?
This makes me feel so powerful - no more having to sift through ffmpeg documentation to write a one time script!