Using ffmpeg to make a movie from png files

26,076

This is the wrong syntax for passing multiple images as input to ffmpeg. Please have a look at the FFmpeg Wiki guide on creating a video slideshow and the image2 demuxer options.

You need to tell it to use three digits for the sequence numbers, and start at 84, i.e.

ffmpeg -start_number 84 -i island_sizes-CSH\(II\)-%03d.png output.mpg

Some further tips:

  • MPEG-1 as a video codec is less than optimal and gives you bad quality at high file sizes. Unless you want compatibility for old devices or computers (or Windows XP without any codecs), scratch that and use an MPEG-4 Part 10 encoder (H.264), such as libx264:

    ffmpeg -i … -c:v libx264 out.mp4
    

    For a tutorial on x264 options (how to change the quality etc.) check the x264 encoding guide.

  • PNG files use an RGB pixel format, which is not supported in normal video codecs. With MPEG-1 it does not matter, but with MPEG-4 codecs it would, since ffmpeg would automatically convert the pixel format to non-subsampled YUV. In that case you need to translate this to chroma-subsampled formats such as YUV 4:2:0, otherwise your video might not play in most applications:

    ffmpeg -i … -c:v libx264 -pix_fmt yuv420p out.mp4
    
Share:
26,076

Related videos on Youtube

rhombidodecahedron
Author by

rhombidodecahedron

Updated on September 18, 2022

Comments

  • rhombidodecahedron
    rhombidodecahedron almost 2 years

    I have 277 800x600 png files with filenames with the format island_sizes-CSH(II)-###.png where ### is a number starting with 084 and ending at 360.

    I'm doing

    ffmpeg -i island_sizes-CSH\(II\)-*.png output.mpg -y
    

    but it doesn't work:

    ffmpeg -f image2 -i island_sizes-CSH\(II\)-*.png video.mpg -y
    ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
      built on May 10 2013 15:14:14 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
      configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping
      libavutil      52. 18.100 / 52. 18.100
      libavcodec     54. 92.100 / 54. 92.100
      libavformat    54. 63.104 / 54. 63.104
      libavdevice    54.  3.103 / 54.  3.103
      libavfilter     3. 42.103 /  3. 42.103
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    Input #0, image2, from 'island_sizes-CSH(II)-084.png':
      Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
        Stream #0:0: Video: png, rgba, 800x600 [SAR 3937:3937 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
    [png @ 0x1468c20] ff_frame_thread_encoder_init failed
    Output #0, image2, to 'island_sizes-CSH(II)-085.png':
        Stream #0:0: Video: png, rgba, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Output #1, image2, to 'island_sizes-CSH(II)-086.png':
        Stream #1:0: Video: png, rgba, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    ...
    Output #274, image2, to 'island_sizes-CSH(II)-359.png':
        Stream #274:0: Video: none, rgba, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Output #275, image2, to 'island_sizes-CSH(II)-360.png':
        Stream #275:0: Video: none, rgba, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Output #276, mpeg, to 'video.mpg':
        Stream #276:0: Video: none, yuv420p, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
    Stream mapping:
      Stream #0:0 -> #0:0 (png -> png)
      Stream #0:0 -> #1:0 (png -> png)
    ...
      Stream #0:0 -> #274:0 (png -> png)
      Stream #0:0 -> #275:0 (png -> png)
      Stream #0:0 -> #276:0 (png -> mpeg1video)
    Error while opening encoder for output stream #218:0 - maybe incorrect parameters such as bit_rate, rate, width or height
    
    • Eddy_Em
      Eddy_Em almost 11 years
      From man mencoder: mencoder "mf://*.jpg" -mf fps=25 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4, similar for ffmpeg
    • slhck
      slhck almost 11 years
      @Eddy_Em It's not similar for ffmpegmencoder has completely different syntax, unfortunately.
  • rhombidodecahedron
    rhombidodecahedron almost 11 years
    You. I like you.