diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index b5cc3fa023..c2c65f7970 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1209,6 +1209,25 @@ static void do_video_out(OutputFile *of,
             if (format_video_sync == VSYNC_CFR && copy_ts) {
                 format_video_sync = VSYNC_VSCFR;
             }
+            /* 2-pass encoding with pass 1 to null muxer and auto vsync is
+             * problematic: null has AVFMT_NOTIMESTAMPS which selects passthrough,
+             * but pass 2 typically outputs to a format like MP4 that uses CFR.
+             * This causes frame count mismatch and crashes in the encoder.
+             * Only error if input appears to be VFR (r_frame_rate != avg_frame_rate),
+             * since CFR input with passthrough will produce consistent frame counts. */
+            if ((enc->flags & AV_CODEC_FLAG_PASS1) &&
+                !strcmp(of->ctx->oformat->name, "null") &&
+                format_video_sync == VSYNC_PASSTHROUGH &&
+                ist && ist->st->avg_frame_rate.num && ist->st->r_frame_rate.num &&
+                av_cmp_q(ist->st->avg_frame_rate, ist->st->r_frame_rate)) {
+                av_log(NULL, AV_LOG_FATAL,
+                       "2-pass encoding of VFR content with pass 1 to null output requires\n"
+                       "explicit -vsync. The null muxer uses passthrough timing, but pass 2\n"
+                       "output formats typically use CFR, causing frame count mismatch.\n"
+                       "Please specify -vsync cfr for consistent results, or use the same\n"
+                       "output format for both passes.\n");
+                exit_program(1);
+            }
         }
         ost->is_cfr = (format_video_sync == VSYNC_CFR || format_video_sync == VSYNC_VSCFR);
 
