FFmpeg - PNG / JPG - Invalid data found when processing input

12,450

You need to provide two things:

  1. The proper dependencies
  2. The proper configure options

decoding dependencies

  • PNG decoding depends on the zlib library, so you need to install whatever package provides zlib.h before compiling ffmpeg.

  • JPEG decoding needs no additional external libraries.

configure options

By default you don't need to add any configure options for PNG and JPEG decoding.

If you used any --disable-* options, such as in the question above, they may disable components required for PNG and JPEG decoding. If that is the case, then you may need to add:

--enable-decoder=mjpeg,png
--enable-demuxer=image2
--enable-protocol=file
--enable-zlib

Make sure no following conflicting --disable-* options are used that will cancel out any of these options.

Share:
12,450

Related videos on Youtube

Jon G
Author by

Jon G

Updated on September 18, 2022

Comments

  • Jon G
    Jon G almost 2 years

    I am trying to add a watermark to a video with FFmpeg. I have a custom build of FFmpeg that I am creating with a view to keep the binary size down. I seem to have excluded the ability for FFmpeg to read PNG / JPG images in this process:

    ffmpeg -i ../weather.png
    ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.8 (Ubuntu 4.8.2-19ubuntu1)
      configuration: --prefix=/home/user/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/user/ffmpeg_build/include --extra-ldflags=-L/home/user/ffmpeg_build/lib --bindir=/home/user/bin --enable-gpl --disable-doc --enable-yasm --disable-decoders --enable-decoder=mpeg4 --enable-decoder=aac --enable-decoder=h264 --enable-decoder=mpegvideo --enable-decoder=mpeg1video --enable-decoder=mpeg2video --enable-decoder=png --disable-encoders --enable-encoder=mpeg4 --enable-encoder=aac --enable-encoder=h264 --enable-encoder=libx264 --enable-encoder=mpeg1video --enable-encoder=mpeg2video --enable-encoder=png --disable-parsers --enable-parser=aac --enable-parser=mpeg4video --enable-parser=ac3 --enable-parser=h261 --enable-parser=h264 --enable-parser=vc1 --enable-parser=mpegvideo --disable-demuxers --enable-demuxer=aac --enable-demuxer=h264 --enable-demuxer=mpegvideo --enable-demuxer=m4v --enable-demuxer=mov --enable-demuxer=vc1 --enable-demuxer=mp4 --enable-demuxer=concat --disable-muxers --enable-muxer=h264 --enable-muxer=mpeg1video --enable-muxer=mpeg2video --enable-muxer=m4v --enable-muxer=mov --enable-muxer=vc1 --enable-muxer=md5 --enable-muxer=mp4 --enable-protocols --enable-indev=v4l --enable-indev=v4l2 --disable-filters --enable-filter=aresample --enable-filter=scale --enable-filter=movie --enable-avfilter --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-symver --enable-network --enable-libx264 --enable-zlib
      libavutil      54. 20.100 / 54. 20.100
      libavcodec     56. 26.100 / 56. 26.100
      libavformat    56. 25.101 / 56. 25.101
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5. 12.100 /  5. 12.100
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    ../weather.png: Invalid data found when processing input
    

    I am mostly interested in PNG images, but thought I'd try JPG as well. You will notice I have --enable-encoder=png and --enable-decoder=png in my configuration. I noticed on SO that I should check that I had zlib1g-dev (Ubuntu) installed, which I do. Do I need to tell FFmpeg to use this in my compilation?

    Otherwise, what codec am I missing to include images in FFmpeg?

    Watermarking command:

    ffmpeg -y -i input.mp4 -i image.png -filter_complex "overlay=0:0" -codec:a copy -strict -2 output.mp4
    
  • Jon G
    Jon G about 9 years
    Minor addition: I needed to add "--enable-filter=overlay" too.
  • Shebuka
    Shebuka almost 9 years
    Having similar issue but with output i solved by adding --enable-muxer=image2