This is the sample file I used in this issue: https://roundup.ffmpeg.org/roundup/ffmpeg/issue872 ===== I try to transcode a flv file to mp4 using libx264, but encountered this error message "av_interleaved_write_frame(): Error while opening file". The command line I use is: $ffmpeg -i video.flv -vcodec libx264 video.mp4 The output is: FFmpeg version SVN-r17630, Copyright (c) 2000-2009 Fabrice Bellard, et al. configuration: --enable-gpl --enable-libx264 --enable-libfaac --enable-libfaad --enable-libmp3lame libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 0 / 52.20. 0 libavformat 52.30. 1 / 52.30. 1 libavdevice 52. 1. 0 / 52. 1. 0 built on Feb 27 2009 17:19:01, gcc: 4.0.1 (Apple Inc. build 5490) Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 30.00 (30/1) Input #0, flv, from 'video.flv': Duration: 00:05:38.30, start: 0.000000, bitrate: 361 kb/s Stream #0.0: Video: flv, yuv420p, 320x240, 297 kb/s, 30 tbr, 1k tbn, 1k tbc Stream #0.1: Audio: mp3, 22050 Hz, mono, s16, 64 kb/s File 'video.mp4' already exists. Overwrite ? [y/N] y Output #0, mp4, to 'video.mp4': Stream #0.0: Video: libx264, yuv420p, 320x240, q=2-31, 200 kb/s, 90k tbn, 30 tbc Stream #0.1: Audio: libfaac, 22050 Hz, mono, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 [libx264 @ 0x1008a00]using cpu capabilities: MMX2 SSE2Fast SSSE3 PHADD SSE4.1 Cache64 [libx264 @ 0x1008a00]profile Baseline, level 1.3 Press [q] to stop encoding [libx264 @ 0x1008a00]error, non monotone timestamps 488 >= 488 429.7kbits/s av_interleaved_write_frame(): Error while opening file My investigation showed me that the cause was introduced in r17555: [ybian@wukong:ybian/src/ffmpeg-svn]$ svn log -r 17555 ------------------------------------------------------------------------ r17555 | michael | 2009-02-24 23:06:17 +0800 (Tue, 24 Feb 2009) | 4 lines Do not duplicate frames if the muxer claims that it is not needed. Note to release manager, this is risky and should be reverted if it causes any problem. ------------------------------------------------------------------------ [ybian@wukong:ybian/src/ffmpeg-svn]$ svn diff -r 17555:17554 Index: ffmpeg.c =================================================================== --- ffmpeg.c (revision 17555) +++ ffmpeg.c (revision 17554) @@ -865,7 +865,7 @@ //FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c if (vdelta < -1.1) nb_frames = 0; - else if (video_sync_method == 2 || (video_sync_method<0 && (s->oformat->flags & AVFMT_VARIABLE_FPS))) + else if (video_sync_method == 2) ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base)); else if (vdelta > 1.1) nb_frames = lrintf(vdelta); If I reverted the change in revision 17555, the problem disappeared.