DEV Community

Cover image for Prepare Your Own Video Wallpaper with FFmpeg (and Run It with EWRE on Windows)
John Wick
John Wick

Posted on

Prepare Your Own Video Wallpaper with FFmpeg (and Run It with EWRE on Windows)

Live wallpaper engines can play most video files as they are. But a raw 4K movie clip with a stereo audio track is not the ideal wallpaper. It's bigger than it needs to be, it may stutter on weaker hardware, and it probably doesn't loop cleanly.

A few FFmpeg commands fix all of that. In this post I'll prepare a clip for use with EWRE, a free live wallpaper engine for Windows 10 and 11 that plays MP4, MKV, WebM, MOV, AVI and more.

You don't need to convert anything for EWRE to work. This is optional tuning for smaller files and a cleaner result.

What makes a good wallpaper clip

  • Short. 5 to 20 seconds is plenty for a loop.
  • No audio. A wallpaper doesn't need a sound track.
  • Right resolution. Match your monitor, not more.
  • Compatible pixel format. 8-bit 4:2:0 is the safest choice for hardware decoders.
  • Loop-friendly. The end should lead back to the start without a jarring jump.

1. Trim the clip

Cut a 10-second section starting at 5 seconds:

ffmpeg -ss 00:00:05 -i input.mp4 -t 10 -c copy trimmed.mp4
Enter fullscreen mode Exit fullscreen mode

-c copy is instant because it doesn't re-encode, but it cuts at keyframes, so the start can be slightly off. If you need exact cuts, drop -c copy and let the next step re-encode.

2. Resize, remove audio, and set a compatible format

ffmpeg -i trimmed.mp4 \
  -vf "scale=1920:-2" \
  -c:v libx264 -crf 20 -preset slow \
  -pix_fmt yuv420p \
  -an \
  -movflags +faststart \
  wallpaper.mp4
Enter fullscreen mode Exit fullscreen mode

What each part does:

Option Purpose
scale=1920:-2 Resize to 1920 wide, keep the aspect ratio, keep height even
-c:v libx264 Encode with H.264, which hardware decoders handle widely
-crf 20 Quality level. Lower is better quality and a bigger file
-preset slow Better compression for the same quality
-pix_fmt yuv420p 8-bit 4:2:0, the most compatible format
-an Strip the audio track
-movflags +faststart Moves metadata to the front of the file

For a 1440p or 4K monitor, change 1920 to 2560 or 3840.

3. Reduce the frame rate if you want a lighter file

If the source is 60 FPS and you'd rather save space and decoding work:

ffmpeg -i wallpaper.mp4 -vf "fps=30" -c:v libx264 -crf 20 -pix_fmt yuv420p -an wallpaper_30fps.mp4
Enter fullscreen mode Exit fullscreen mode

Don't use fps=60 on a 30 FPS source. It only duplicates frames and makes the file bigger without making it smoother.

4. Make a loop-friendly clip

If the end of your clip doesn't match the start, the loop point will show. A simple trick is a "boomerang": play the clip forward, then backward.

ffmpeg -i wallpaper.mp4 \
  -filter_complex "[0:v]reverse[r];[0:v][r]concat=n=2:v=1:a=0" \
  -c:v libx264 -crf 20 -pix_fmt yuv420p \
  boomerang.mp4
Enter fullscreen mode Exit fullscreen mode

The reverse filter loads the whole clip into memory, so keep the input short (a few seconds). It works best for slow, ambient footage like clouds, water, or particles. It looks odd with anything that has obvious direction, like text or walking people.

5. Check the result

ffprobe -v error -show_entries stream=codec_name,width,height,r_frame_rate,pix_fmt -of default=nw=1 wallpaper.mp4
Enter fullscreen mode Exit fullscreen mode

You should see h264, your target resolution, the frame rate you chose, and yuv420p.

6. Set it as your wallpaper

  1. Install EWRE from the Microsoft Store.
  2. Select your processed file.
  3. Assign it to one monitor, or span it across all of them.

EWRE pauses automatically when a fullscreen game launches, when you're on battery, when the PC is locked, or when displays power down, so a lean clip plus smart pausing keeps the overhead low.

Batch tip

To process a whole folder of clips from PowerShell:

Get-ChildItem *.mp4 | ForEach-Object {
  ffmpeg -i $_.FullName -vf "scale=1920:-2" -c:v libx264 -crf 20 -pix_fmt yuv420p -an "wall_$($_.Name)"
}
Enter fullscreen mode Exit fullscreen mode

Wrap up

Trim it, resize it, strip the audio, and make the loop clean. Five minutes of FFmpeg work gives you a smaller file and a better-looking desktop.

Got a favorite FFmpeg one-liner for wallpapers? Drop it in the comments. ๐Ÿ‘‡

EWRE: EWRE - Live Desktop Wallpaper ยท Developer: github.com/StayElite

Top comments (0)