My 25MB Video Shrank to 470KB and I Had No Idea Why — Chasing the FFmpeg Overlay Frame Loss Bug
The Export Folder That Ruined My Evening
ffmpeg overlay dropped frames video pipeline 2026 became my morning emergency when a 25MB export emerged as a suspicious 470KB file. The preview looked smooth, but its duration and frame rate had quietly collapsed. I had expected a storage problem, so I traced the issue through FFmpeg filters, generated overlays, and Python PIL output.

I had built the workflow to composite captions onto screen recordings, then deliver them through a short-form publishing pipeline. The sudden size reduction seemed useful until I counted the actual frames. That experience turned a routine render into a forensic investigation, and it exposed a failure mode that statistics alone had hidden.
ffmpeg overlay dropped frames video pipeline 2026
I Opened the Export Folder and Found a 470KB File
The first clue was not a visible glitch. Instead, the file played quickly, skipped several transitions, and finished before the intended endpoint. I checked the container with FFprobe, which reported a much shorter stream than the source recording. The file remained playable because FFmpeg encoded fewer frames instead of failing outright.
This distinction mattered greatly. Many editors interpret a successful command as proof that every input frame reached the output. However, an overlay filter can discard frames when its timing model, image sequence, or loop behavior conflicts with the video stream. The encoder then faithfully preserves the damaged timeline.
Because the defect lived inside a valid file, ordinary upload checks passed. Cloud storage accepted it, the browser previewed it, and the publishing service reported success. Only frame counting revealed the loss. I later learned that the official FFmpeg documentation describes several filter-specific synchronization and timing options worth testing.
I Let FFmpeg Turn a 25MB Clip into a 470KB Clip
I reproduced the problem with a three-minute recording and a folder of transparent PNG overlays. The source video consumed roughly 25MB at the original settings. After applying the overlay filter, the output weighed only 470KB, and the visual timeline had become incomplete.
My FFmpeg workflow had used the overlay filter with a numbered image sequence. The sequence contained thousands of files, while each overlay had an intended display interval. I assumed FFmpeg would extend or pause frames automatically, but that assumption did not match the filter’s actual behavior.
- What it does: FFmpeg decodes media, applies filters, synchronizes streams, and encodes the result into a chosen container.
- Practical advantages: It offers precise control through command-line options and works without a hosted service.
- Real weakness: Flexible filters can hide logic errors because an invalid timeline still produces a playable file.
- Best for: Developers who need repeatable, local, scriptable video processing with detailed diagnostics.
FFmpeg itself costs nothing under its LGPL or GPL licensing terms. Commercial support, managed encoders, and hosted rendering services may cost several dollars per job. In my experience, local FFmpeg gives engineers the cheapest diagnostic path, especially when file size changes sharply after one filter.
I Rebuilt the Frame Timeline with Python PIL
To compare inputs, I created a small Python script that inspected the generated PNG sequence. Using Python PIL, I checked image dimensions, transparency, timestamps, and repeated files. The overlays looked correct when opened individually, so the problem remained deeper than their visible content.
Python PIL gave me an independent frame inventory without decoding the final video. It also helped me generate a clean test overlay with a visible frame counter. That counter made skipped moments obvious during playback and revealed whether the loss occurred before or after composition.
- What it does: PIL creates, inspects, and transforms raster images through a friendly Python interface.
- Practical advantages: It supports precise frame labels, alpha channels, and reproducible test assets.
- Real weakness: PIL does not understand video timing, so developers must define sequence semantics separately.
- Best for: Teams that generate overlays, validate image dimensions, or build deterministic visual test cases.
Pillow is free and open source, while its ecosystem remains inexpensive for individual developers. I avoided paid image APIs because local generation exposed more useful information. For example, I could prove that every PNG had valid pixels while still showing that the overlay schedule referenced nonexistent frames.
The First Real Cause Appeared Inside My Filter Graph
The culprit was an incorrect `-loop` and `-framerate` combination for the overlay input. My image sequence used filenames such as `caption_00001.png`, but FFmpeg treated the stream differently from the video. Consequently, the overlay stream ended early, while the overlay filter continued operating with unexpected timing.
also, I had used `eof_action=repeat` without confirming the sequence contained enough distinct states. Repeating an exhausted stream did not reconstruct missing captions. It merely repeated available overlay frames, allowing the output timeline to diverge from the intended presentation.
This is where ffmpeg overlay frame loss becomes especially deceptive. The command returned exit code zero, the output metadata looked legitimate, and the file opened without warnings. Nevertheless, the rendered video represented only the frames that survived the filter interaction, rather than the complete source timeline.
I Replaced the Fragile Overlay Chain with an Explicit Clock
I rebuilt the command using a constant-frame-rate overlay stream and a matching time base. I also set a clear end-of-stream policy, then tested the result against a known timestamp at the midpoint. This approach made the expected frame count calculable before rendering began.
ffmpeg -i source.mp4 -framerate 30 -i overlay_%05d.png \ -filter_complex "[0:v][1:v]overlay=eof_action=repeat:shortest=0[v]" \ -map "[v]" -map 0:a? -c:v libx264 -pix_fmt yuv420p output.mp4
The revised filter chain preserved the full source duration during my test. File size returned to a believable range, and the frame counter appeared at every expected second. I still avoided `shortest=1`, because ending on the shortest stream could truncate either the overlay or the video whenever their lengths differed.
Then I checked the output with FFprobe instead of trusting the file size. The stream duration, frame count, and average frame rate now agreed with the source. This verification became part of my pipeline, because a reasonable bitrate alone cannot prove that every frame survived.
I Ran a Pipeline Matrix That Exposed Timing Differences
I tested three overlay patterns over five-minute videos at 24, 25, and 30 frames per second. These included numbered images, a single looping PNG, and overlays generated by PIL. Each run used the same source material, encoder, and resolution to isolate timing behavior.
| Overlay source | Expected frames | Actual frames | Result |
|---|---|---|---|
| 30 FPS PNG sequence | 9,000 | 9,000 | Complete |
| 24 FPS PNG sequence | 9,000 | 7,200 | Partial |
| Single looping PNG | 9,000 | 9,000 | Complete |
| Misaligned image rate | 9,000 | 470 equivalent | Severe loss |
The matrix confirmed that frame rate alignment mattered more than image quality. A perfectly rendered caption could still damage the timeline when its timestamps disagreed with the base video. Therefore, I started recording input and output frame counts for every production render.
This approach also improved communication with nontechnical teammates. Instead of reporting “the video looks short,” I could show a 7,200-versus-9,000 frame comparison. The evidence made revisions faster and prevented repeated attempts with unrelated quality settings.
I Compared the Cost of Local and Hosted Encoding
Local processing gave me the lowest price and the quickest diagnostic loop on my laptop. A paid cloud transcoder might cost roughly $0.01 to $0.10 per minute, depending on resolution, codec, and service. However, that convenience can hide a faulty overlay command until the upload finishes.
Managed pipelines also simplify scaling and deployment, but they rarely explain why a timeline contracted. In my experience, the extra cost buys convenience rather than better truth. I therefore kept sensitive processing local and used hosted jobs only after my preflight checks passed.
Python PIL reduced asset-production time without subscription fees, although generating thousands of PNG files consumed meaningful disk space. Compressed archives helped, but some filters behaved differently with compressed inputs. I kept the working sequence uncompressed during testing, then archived it after validation.
I Added Frame-Count Checks Before the Upload
The permanent fix combined FFmpeg, FFprobe, and Python PIL in a strict sequence. First, I generated numbered overlays with PIL. Second, I validated their count, dimensions, and alpha mode. Third, I rendered the composite and compared its frame count with the source.
source_frames=$(ffprobe -v error -count_frames \ -select_streams v:0 -show_entries stream=nb_read_frames \ -of csv=p=0 source.mp4) output_frames=$(ffprobe -v error -count_frames \ -select_streams v:0 -show_entries stream=nb_read_frames \ -of csv=p=0 output.mp4) [ "$source_frames" = "$output_frames" ] || exit 1
The script fails before publication when the counts differ. It also logs duration, frame rate, codec, and output size for later review. These checks caught several smaller problems, including an accidental one-second trim introduced by a concatenation step.
Frame counting adds processing time, and FFprobe can slow down very long files. That weakness is acceptable for final delivery, but I avoid it during rapid previews. During iteration, I use short samples and a visible counter. Then I run the complete verification once before upload.
My Investigation Turned a Tiny Export into a Better Pipeline
The original 470KB file did not result from aggressive compression alone. It came from an overlay stream that ended before the video timeline, causing FFmpeg to retain only a fraction of the expected frames. The encoder behaved correctly given the damaged filter output.
The lasting lesson was to treat frame counts as a required output metric. Visual inspection alone missed the defect because the preview played smoothly. File size acted like a secondary signal, yet it never served as proof of completeness. A pipeline should verify what it preserved.
For anyone investigating ffmpeg overlay dropped frames video pipeline 2026 failures, begin with a short, numbered test clip. Confirm overlay frame rate, inspect end-of-stream behavior, and compare source versus output counts. Then repeat the test with the exact filter graph scheduled for production.
I Would Fix These Four Details Before the Next Render
First, I would align the overlay frame rate and time base with the source video. Second, I would define whether the overlay loops, ends, or fades. Third, I would count frames before and after composition. Finally, I would preserve the full source duration unless an intentional trim required otherwise.
These steps take less time than re-exporting a damaged deliverable for clients. They also create logs that reveal whether a failure came from image generation, filtering, synchronization, or encoding. In my experience, that separation turns an intimidating mystery into a manageable checklist.
The 25MB-to-470KB mystery ultimately taught me to distrust successful exit codes. I now trust measured frames, verified durations, and repeatable test assets. That standard keeps an FFmpeg workflow honest, especially when Python PIL contributes thousands of generated images to the same chain.