{"id":4673,"date":"2014-03-30T14:30:19","date_gmt":"2014-03-30T14:30:19","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ffmpeg-drops-frames-when-encoding-a-png-image-sequence-into-an-x264-mp4-video-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:30:19","modified_gmt":"2014-03-30T14:30:19","slug":"ffmpeg-drops-frames-when-encoding-a-png-image-sequence-into-an-x264-mp4-video-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/ffmpeg-drops-frames-when-encoding-a-png-image-sequence-into-an-x264-mp4-video-collection-of-common-programming-errors\/","title":{"rendered":"FFmpeg drops frames when encoding a png image sequence into an x264 mp4 video-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/YuPYy.png?s=32&amp;g=1\" \/><br \/>\nPtrFdr<\/p>\n<p>I&#8217;m trying to encode an image-sequence (<code>frame0001.png<\/code>, <code>frame0002.png<\/code>, &#8230; , <code>frame0160.png<\/code>) into an x264 video using the following command:<\/p>\n<pre><code>ffmpeg -i frame%04d.png -sameq -r 24 out.mp4\n<\/code><\/pre>\n<p>After encoding, it says <code>drop=5<\/code> and indeed there are noticeable &#8220;jumps&#8221; in the video.<\/p>\n<p>It appears someone else had a similar problem, but for me the accepted answer isn&#8217;t very useful since <strong>I&#8217;d like to have no frames dropped.<\/strong><\/p>\n<p><em>Is a switch missing from the command? Or am I doing something else wrong?<\/em><\/p>\n<p><strong>Edit:<\/strong> Added console output:<\/p>\n<pre><code>ffmpeg version N-42347-g299387e Copyright (c) 2000-2012 the FFmpeg developers\n  built on Jul  8 2012 15:46:39 with gcc 4.7.1\n  configuration: --disable-static --enable-shared --enable-gpl --enable-version3\n --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enable-bzli\nb --enable-frei0r --enable-libass --enable-libcelt --enable-libopencore-amrnb --\nenable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lam\ne --enable-libnut --enable-libopenjpeg --enable-librtmp --enable-libschroedinger\n --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc\n--enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --en\nable-libxavs --enable-libxvid --enable-zlib\n  libavutil      51. 64.100 \/ 51. 64.100\n  libavcodec     54. 33.100 \/ 54. 33.100\n  libavformat    54. 15.102 \/ 54. 15.102\n  libavdevice    54.  1.100 \/ 54.  1.100\n  libavfilter     3.  1.100 \/  3.  1.100\n  libswscale      2.  1.100 \/  2.  1.100\n  libswresample   0. 15.100 \/  0. 15.100\n  libpostproc    52.  0.100 \/ 52.  0.100\nInput #0, image2, from 'frame%04d.png':\n  Duration: 00:00:06.40, start: 0.000000, bitrate: N\/A\n    Stream #0:0: Video: png, rgb24, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc\n[graph 0 input from stream 0:0 @ 01cd1f60] w:1920 h:1080 pixfmt:rgb24 tb:1\/25 fr\n:25\/1 sar:0\/1 sws_param:flags=2\n[output stream 0:0 @ 01cd2220] No opaque field provided\n[auto-inserted scaler 0 @ 01cd3540] w:1920 h:1080 fmt:rgb24 sar:0\/1 -&gt; w:1920 h:\n1080 fmt:yuv420p sar:0\/1 flags:0x4\n[libx264 @ 01cd0dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64\n[libx264 @ 01cd0dc0] profile High, level 4.0\n[libx264 @ 01cd0dc0] 264 - core 125 r2200 999b753 - H.264\/MPEG-4 AVC codec - Cop\nyleft 2003-2012 - http:\/\/www.videolan.org\/x264.html - options: cabac=1 ref=3 deb\nlock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 m\ne_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chro\nma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i\nnterlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1\nb_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenec\nut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=\n0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00\nOutput #0, mp4, to 'out.mp4':\n  Metadata:\n    encoder         : Lavf54.15.102\n    Stream #0:0: Video: h264 ([33][0][0][0] \/ 0x0021), yuv420p, 1920x1080, q=-1-\n-1, 24 tbn, 24 tbc\nStream mapping:\n  Stream #0:0 -&gt; #0:0 (png -&gt; libx264)\nPress [q] to stop, [?] for help\nframe=    8 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   15 fps= 15 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   22 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   29 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   36 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   43 fps= 14 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   47 fps= 11 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits\/s\nframe=   53 fps= 11 q=28.0 size=     111kB time=00:00:00.04 bitrate=21735.2kbits\nframe=   59 fps= 11 q=28.0 size=     268kB time=00:00:00.29 bitrate=7527.8kbits\/\nframe=   63 fps= 10 q=28.0 size=     375kB time=00:00:00.45 bitrate=6708.1kbits\/\nframe=   69 fps= 10 q=28.0 size=     538kB time=00:00:00.70 bitrate=6219.6kbits\/\nframe=   74 fps= 10 q=28.0 size=     675kB time=00:00:00.91 bitrate=6032.7kbits\/\nframe=   79 fps= 10 q=28.0 size=     802kB time=00:00:01.12 bitrate=5840.7kbits\/\nframe=   84 fps= 10 q=28.0 size=     922kB time=00:00:01.33 bitrate=5662.9kbits\/\nframe=   89 fps=9.9 q=28.0 size=    1060kB time=00:00:01.54 bitrate=5633.3kbits\/\nframe=   94 fps=9.9 q=28.0 size=    1186kB time=00:00:01.75 bitrate=5551.2kbits\/\nframe=   98 fps=9.7 q=28.0 size=    1309kB time=00:00:01.91 bitrate=5594.3kbits\/\nframe=  103 fps=9.7 q=28.0 size=    1436kB time=00:00:02.12 bitrate=5536.4kbits\/\nframe=  107 fps=9.6 q=28.0 size=    1533kB time=00:00:02.29 bitrate=5481.7kbits\/\nframe=  112 fps=9.5 q=28.0 size=    1654kB time=00:00:02.50 bitrate=5421.3kbits\/\nframe=  117 fps=9.4 q=28.0 size=    1781kB time=00:00:02.70 bitrate=5386.9kbits\/\nframe=  123 fps=9.4 q=28.0 size=    1925kB time=00:00:02.95 bitrate=5331.5kbits\/\nframe=  128 fps=9.4 q=28.0 size=    2030kB time=00:00:03.16 bitrate=5250.8kbits\/\nframe=  133 fps=9.4 q=28.0 size=    2210kB time=00:00:03.37 bitrate=5363.8kbits\/\nframe=  138 fps=9.3 q=28.0 size=    2356kB time=00:00:03.58 bitrate=5386.0kbits\/\nframe=  142 fps=9.3 q=28.0 size=    2465kB time=00:00:03.75 bitrate=5384.3kbits\/\nframe=  147 fps=9.3 q=28.0 size=    2602kB time=00:00:03.95 bitrate=5385.0kbits\/\nframe=  151 fps=9.2 q=28.0 size=    2706kB time=00:00:04.12 bitrate=5374.3kbits\/\nframe=  155 fps=9.2 q=28.0 size=    2812kB time=00:00:04.29 bitrate=5367.7kbits\/\nframe=  155 fps=7.0 q=28.0 Lsize=    4129kB time=00:00:06.37 bitrate=5306.4kbits\n\/s dup=0 drop=5\nvideo:4128kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.035320%\n[libx264 @ 01cd0dc0] frame I:2     Avg QP:21.97  size: 79850\n[libx264 @ 01cd0dc0] frame P:153   Avg QP:23.43  size: 26579\n[libx264 @ 01cd0dc0] mb I  I16..4:  9.6% 70.5% 19.9%\n[libx264 @ 01cd0dc0] mb P  I16..4:  7.0% 15.3%  0.7%  P16..4: 45.2%  9.1%  2.2%\n 0.0%  0.0%    skip:20.5%\n[libx264 @ 01cd0dc0] 8x8 transform intra:66.7% inter:85.7%\n[libx264 @ 01cd0dc0] coded y,uvDC,uvAC intra: 38.6% 58.0% 6.0% inter: 16.2% 27.2\n% 0.2%\n[libx264 @ 01cd0dc0] i16 v,h,dc,p: 35% 29% 17% 19%\n[libx264 @ 01cd0dc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 21% 31%  3%  4%  5%  4%\n 4%  3%\n[libx264 @ 01cd0dc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 19% 13%  5%  8%  9%  7%\n 6%  4%\n[libx264 @ 01cd0dc0] i8c dc,h,v,p: 49% 23% 23%  5%\n[libx264 @ 01cd0dc0] Weighted P-Frames: Y:0.0% UV:0.0%\n[libx264 @ 01cd0dc0] ref P L0: 84.5% 10.9%  3.5%  1.1%\n[libx264 @ 01cd0dc0] kb\/s:5235.14\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/9d96093408df0463815ff4d9b8a0c1a9?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nslhck<\/p>\n<p>By looking at the console output, it seems that the default framerate of the input sequence is 25 fps:<\/p>\n<pre><code>Input #0, image2, from 'frame%04d.png':\n  Duration: 00:00:06.40, start: 0.000000, bitrate: N\/A\n    Stream #0:0: Video: png, rgb24, 1920x1080, 25 fps, 25 tbr, 25 tbn, 25 tbc\n<\/code><\/pre>\n<p>From the documentation:<\/p>\n<blockquote>\n<p>To force the frame rate of the input file (valid for raw formats only) to 1 fps and the frame rate of the output file to 24 fps:<\/p>\n<pre><code>ffmpeg -r 1 -i input.m2v -r 24 output.avi\n<\/code><\/pre>\n<\/blockquote>\n<p>So, all I needed to do just to add another <code>-r 24<\/code>:<\/p>\n<p><code>ffmpeg<\/code><strong><em><code>-r 24<\/code><\/em><\/strong><code>-i frame%04d.png -r 24 out.mp4<\/code><\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>PtrFdr I&#8217;m trying to encode an image-sequence (frame0001.png, frame0002.png, &#8230; , frame0160.png) into an x264 video using the following command: ffmpeg -i frame%04d.png -sameq -r 24 out.mp4 After encoding, it says drop=5 and indeed there are noticeable &#8220;jumps&#8221; in the video. It appears someone else had a similar problem, but for me the accepted answer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4673","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4673"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4673\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}