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 : )
3 Answers 3
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.
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)
-
2although this command might be helpful, this is not what the OP askedRituraj Borpujari– Rituraj Borpujari2024年06月20日 08:27:19 +00:00Commented Jun 20, 2024 at 8:27
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"
-qscale:v. Try a value between 2-5. A lower value is a higher quality.