Creating a Loom-like Video with FFmpeg

Abstract: Use FFmpeg to record screen and webcam inputs, then composite them with precise positioning and audio mixing for a professional Loom-style video.

Created: 2026-10-09 by
Use FFmpeg to record your screen and overlay a webcam feed, creating a professional Loom-style video. This guide covers capturing inputs on Linux, Windows, or macOS, then compositing them into a single file with precise positioning and audio mixing for immediate sharing.

Recording Your Screen and Webcam

To create a Loom-like video, you first need to capture two distinct sources: your desktop environment and your face via a webcam. While specialized software exists, FFmpeg can handle both tasks simultaneously if configured correctly. The process varies slightly depending on your operating system because each platform uses different backend libraries for screen capture.

On Linux, the x11grab input device is standard for X11-based systems. You must specify the display name and the area to capture. For example, to record the entire primary display at 30 frames per second, use the following command structure:

ffmpeg -f x11grab -r 30 -s 1920x1080 -i :0.0+0,0 output.mp4

The :0.0+0,0 syntax tells FFmpeg to grab from display :0, screen 0, starting at offset 0,0. If you are using Wayland, you may need to use pulseaudio for audio and potentially gdigrab equivalents or third-party tools like OBS as an intermediary, as native Wayland support in FFmpeg has historically been limited compared to X11.

For Windows users, the dshow or gdigrab filters are commonly used. To list available devices, run ffmpeg -list_devices true -f dshow -i dummy. Once identified, you can combine screen and camera inputs. On macOS, the avfoundation input device is the most reliable method. It allows you to select specific devices by index or name.

Compositing Multiple Inputs

Once you have separate video files for your screen and your webcam, or if you are recording them in real-time using complex filters, you need to merge them visually. This is where FFmpeg's filtergraph comes into play. The goal is to place the webcam footage in a corner of the screen recording, similar to how Loom positions the user avatar.

You will use the overlay video filter. This filter takes two input streams and draws one on top of the other. Suppose you have a screen recording named screen.mp4 and a webcam clip named webcam.mp4. The basic command to overlay the webcam in the bottom-right corner looks like this:

ffmpeg -i screen.mp4 -i webcam.mp4 \
-filter_complex "overlay=W-w-10:H-h-10" \
-c:a copy output_loom.mp4

In this command, W-w-10 calculates the X-coordinate by taking the width of the main video (W) minus the width of the overlay (w) minus a 10-pixel margin. Similarly, H-h-10 handles the vertical positioning. This ensures the webcam box does not touch the edge of the screen recording, providing a clean aesthetic.

If you need to resize the webcam feed before overlaying it, you can chain filters within the -filter_complex argument. For instance, to scale the webcam to half its original size and then position it:

ffmpeg -i screen.mp4 -i webcam.mp4 \
-filter_complex "[1:v]scale=iw/2:ih/2[wm];[0:v][wm]overlay=W-w-10:H-h-10" \
-c:a copy output_scaled.mp4

This approach is highly efficient because it avoids re-encoding the entire screen video if you only adjust the overlay parameters. However, note that adding filters often forces a re-encode of the video stream unless you use stream copying for non-modified parts, which is not possible with the overlay filter since it modifies the pixel data.

Handling Audio Mixing

A Loom-style video typically includes narration from the microphone. If you recorded audio separately or captured it alongside the video, you must mix it with any existing system audio from the screen recording. FFmpeg’s aformat and amix filters facilitate this.

Assuming you have audio tracks from both sources, you can combine them using the amix filter. This is crucial because simply appending audio streams results in silent or distorted playback. The command might look like:

ffmpeg -i screen.mp4 -i webcam.mp4 \
-filter_complex "[0:a][1:a]amix=inputs=2:duration=first:dropout_transition=2[a]" \
-map "0:v" -map "[a]" output_final.mp4

The inputs=2 parameter specifies that two audio streams are being combined. The duration=first option ensures the output audio matches the length of the shortest input, preventing errors if one track is longer than the other. Adjusting the volume levels individually before mixing can prevent clipping, ensuring clear narration over background sounds.

Optimizing Output Settings

After composing the visual and audio elements, the final step is encoding the result into a shareable format. MP4 with H.264 video and AAC audio is the universal standard for web sharing. Use the -crf (Constant Rate Factor) flag to control quality. A value between 18 and 23 is generally recommended for high-quality recordings without excessive file sizes.

ffmpeg -i screen.mp4 -i webcam.mp4 \
-filter_complex "[1:v]scale=iw/2:ih/2[wm];[0:v][wm]overlay=W-w-10:H-h-10" \
-c:v libx264 -crf 21 -preset medium -c:a aac output_loom_final.mp4

The -preset medium setting offers a good balance between encoding speed and compression efficiency. Faster presets like fast may increase file size, while slower ones like slow take significantly longer to process with diminishing returns on quality. Always test with a short clip before processing a long recording to ensure the filtergraph logic holds up under load.

For more advanced editing, such as concatenating multiple clips while preserving timestamps, refer to our guide on FFmpeg: Honoring Outpoint Timestamps with Concat Demuxer and Preserving Input Codec Parameters. Additionally, if you wish to stack videos vertically rather than overlay them, check out Efficient Way of Stacking Two Videos Vertically Using FFmpeg.

Frequently Asked Questions

Why is my webcam overlay appearing black?

This usually happens if the webcam input fails to initialize or if the resolution mismatch causes rendering issues. Ensure your webcam is not being used by another application like Zoom or Teams, as these apps lock the device exclusively. Also, verify that the avfoundation or dshow device index corresponds to the correct camera in your system list.

Can I add text annotations to the video?

Yes, you can add text overlays using the drawtext filter within the -filter_complex chain. You would define the text string, font path, and position coordinates similarly to how you positioned the webcam overlay. This allows you to add titles or callouts directly during the FFmpeg processing stage.

How do I reduce the file size of the final video?

Increase the CRF value above 23, though this reduces quality. Alternatively, switch from libx264 to libx265 (HEVC), which offers better compression at the same quality level but requires significantly more CPU power during encoding. You can also lower the frame rate if 30fps is unnecessary for your content.

Is it possible to record and edit in real-time?

FFmpeg processes files sequentially, so it cannot "live edit" and output simultaneously in the way a video editor like Premiere Pro does. However, you can pipe outputs using Unix pipes or named pipes to create near-real-time workflows, but this introduces complexity and potential latency. For live streaming, consider using RTMP output instead of local file recording.

What should I do if the audio is out of sync?

Audio desync often occurs when video frames are dropped or when mixing audio streams with different sample rates. Ensure both input videos have consistent frame rates. When mixing, use the aresample filter to normalize sample rates before feeding them into amix. Checking the timestamps with ffprobe can help diagnose drift issues.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More