0

I have a problem using ffmpeg on images. My problem is that quite a lot of images on the internet has incorrect extension ( png files names .jpg and jpg files named .png) which makes the ffmpeg fail.

I couldn't find any documentation on the internet how can this be fixed? Can I force somehow ffmpeg to try to look in other codec types too not just the ones the extension suggests?

To reproduce this you just need to download a png from the internet and rename it's extension to .jpg

And even if you use the simplest command like ffmpeg -i image.jpg it fails with:

ffprobe.exe -i tux.jpg -report
ffprobe version N-61663-g19139d8 Copyright (c) 2007-2014 the FFmpeg developers
  built on Mar 20 2014 22:06:17 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52. 67.100 / 52. 67.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 34.101 / 55. 34.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
[AVIOContext @ 00000000041614e0] Statistics: 41236 bytes read, 0 seeks
[mjpeg @ 0000000004160d60] marker=db avail_size_in_buf=41068
[mjpeg @ 0000000004160d60] dqt: invalid precision
[mjpeg @ 0000000004160d60] marker parser used 3 bytes (20 bits)
[mjpeg @ 0000000004160d60] marker=fe avail_size_in_buf=40036
[mjpeg @ 0000000004160d60] marker parser used 2 bytes (16 bits)
[mjpeg @ 0000000004160d60] marker=cf avail_size_in_buf=39899
[mjpeg @ 0000000004160d60] mjpeg: unsupported coding type (cf)
[mjpeg @ 0000000004160d60] marker parser used 0 bytes (0 bits)
[mjpeg @ 0000000004160d60] marker=c3 avail_size_in_buf=39465
[mjpeg @ 0000000004160d60] sof0: picture: 4697x50895
[image2 @ 000000000415fee0] decoding for stream 0 failed
[image2 @ 000000000415fee0] Could not find codec parameters for stream 0 (Video: mjpeg): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
tux.jpg: End of file

PS: I tried to increase analyzeduration and probsize if that's not obvious but same thing happens.

1
  • How is this about general computing hardware and software? FFMPEG is used for programming audio-video tools. I believe this makes the question directly involving tools used primary for programming. Since when does encoding and generating video automated counts as GENERAL?
    – G.T.
    Mar 25, 2014 at 7:01

1 Answer 1

1

It's not a perfect answer, but maybe you can check for failure and then try a different format, e.g.:

ffmpeg -c:v png -i lol.jpg

Where lol.jpg is really a png. Or maybe rename the file to have the correct extension once you know the true format.

3
  • It works, but unfortunately at this form it's not applicable for me. Manually this would work great for a couple of inputs, I would check if I can convert it, if not then I'll try again with this form. However I need to automate the process. It would be nice if I could add parameter if fails try this way, but to parse the output console and rerun again with other option has a huge overhead and complexity. I'm trying to run this in the and on an arm processor, where every overhead counts.
    – G.T.
    Mar 25, 2014 at 6:57
  • Rather than parsing the output, maybe you can simply check the return value of ffprobe? E.g. if $(ffprobe unknown.png >/dev/null 2>&1) ; then echo "yes" ; else echo "no" ; fi
    – njahnke
    Mar 25, 2014 at 16:04
  • 1
    I was able to automate this process using your solution. First I tried for every input if I was able to open it with ffmpeg, if not then try it again with the -c:v command.
    – G.T.
    Mar 26, 2014 at 10:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.