C.W.K.
Stream
Lesson 05 of 08 · published

Image Sequence ↔ Video

~10 min · image-sequence, frames, stop-motion

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

Frames in, video out

FFmpeg can read numbered image sequences as if they were video. Useful for AI-generated frames, stop-motion, vfx renders, screenshots assembled into a timelapse.

The pattern: -framerate N -i 'frame_%04d.png'. The %04d is printf-style: frame_0001.png, frame_0002.png, …

Code

Image sequence → video·bash
# Numbered PNGs at 30 fps → MP4
ffmpeg -framerate 30 -i 'frame_%04d.png' \
  -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p \
  out.mp4

# Glob pattern (when filenames aren't strictly numbered)
ffmpeg -framerate 30 -pattern_type glob -i 'shot_*.png' \
  -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p \
  out.mp4

# Add audio
ffmpeg -framerate 30 -i 'frame_%04d.png' -i music.wav \
  -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p \
  -c:a aac -b:a 192k -shortest \
  out_with_audio.mp4
Video → image sequence·bash
# Every frame as PNG
ffmpeg -i in.mp4 'frames/frame_%04d.png'

# Every frame as JPG (smaller files)
ffmpeg -i in.mp4 -q:v 2 'frames/frame_%04d.jpg'

# Only one frame every 0.5 seconds
ffmpeg -i in.mp4 -vf 'fps=2' 'frames/frame_%04d.png'

# Smart frames (one per scene change)
ffmpeg -i in.mp4 -vf "select='gt(scene,0.4)'" -vsync vfr 'frames/scene_%03d.png'

External links

Exercise

Generate (or download) a sequence of 60 PNG frames (any source — Stable Diffusion frames, screenshots, photos). Convert to a 30 fps MP4. Then take any video and dump every frame as JPG. Verify the count: ls frames/ | wc -l ≈ duration × fps.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.