9

Before I ask I want to say that I know about ImageMagick and the other image processing tools but I explicitly need to use ffmpeg.

So, can someone tell me if there's a way to use ffmpeg to convert an image ( in any of the common formats ) to a jpeg format. I also need to scale it. Until now I've come with this:

ffmpeg -i <input-file> -vf "scale=<output-width>:-1" <output-file>

Any suggestion will be appreciated : )

asked Jun 12, 2013 at 13:15
5
  • This might be a better question for superuser (or just read this ffmpeg.org/…) Commented Jun 12, 2013 at 13:34
  • 1
    Your command looks fine to me. Have you tried it? You can increase output quality for jpeg output with -qscale:v. Try a value between 2-5. A lower value is a higher quality. Commented Jun 12, 2013 at 16:49
  • The command works as expected, but it produces a green overlay which I do not know how can be removed. Any ideas? Commented Jun 21, 2013 at 10:54
  • Please include the complete ffmpeg console output (and this should be a standard practice when asking ffmpeg usage questions). Commented Jun 21, 2013 at 16:19
  • @user931392 IMHO the green overlay may be caused by conversion between different pixel formats or color spaces. Are you sure the problem isn't unique to FFmpeg and occurs with alternatives like ImageMagick? Commented Oct 13, 2017 at 21:59

3 Answers 3

5

I just asked myself the same question and thought I'd put an answer here even if I'm ten years late.

ffmpeg -i <input-file> <output-file>

This just worked fine for me, which video filter works for you depends on your FFmpeg version, which should always be provided when asking questions about FFmpeg.

Here is a more complex example with filters: https://stackoverflow.com/a/41355827/2010467

Before I ask I want to say that I know about ImageMagick and the other image processing tools but I explicitly need to use ffmpeg.

I have the same or a very similar need and it is reasonable in some environments where you don't have access to the package manager or the package itself while you are already using a statically linked version of FFmpeg.

answered Feb 6, 2023 at 3:58
2

For reference, to convert all files in the current folder:

for f in *.webp; do ffmpeg -i "$f" "${f%.*}.png"; done

(from webp to png in this example)

answered May 28, 2023 at 12:07
1
  • 2
    although this command might be helpful, this is not what the OP asked Commented Jun 20, 2024 at 8:27
0

Create a batch file and add the following:

for %%i in (*.png) do ffmpeg -i "%%i" -q:v 2 "%%~ni.jpg"

This will convert *.png files into the higest quality *.jpg image file. This will work for .bmp, .tga, etc. You can adjust the jpeg quality from 2 (best) to 31 (worst), as of this post.

If you do not want to use a batch (.bat) file, remove one % from each input in the command line and run it:

for %i in (*.png) do ffmpeg -i "%i" -q:v 2 "%~ni.jpg"
answered Oct 28, 2024 at 1:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.