Create high quality JPEGs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Create high quality JPEGs

spookybathtub
How can I create high quality JPEGs with ffmpeg?  Using qscale 0 helps, but it still produces a file with noticeably less detail than the original, and macro blocking.

$ ffmpeg -i 0.tiff -qscale:v 0 0.jpeg
ffmpeg version 2.5.git Copyright (c) 2000-2015 the FFmpeg developers
  built on Feb  8 2015 16:44:44 with Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
  configuration: --prefix=/opt/local --enable-swscale --enable-avfilter --enable-avresample --enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libtheora --enable-libschroedinger --enable-libopenjpeg --enable-libmodplug --enable-libvpx --enable-libspeex --enable-libass --enable-libbluray --enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype --enable-libfribidi --disable-indev=jack --disable-outdev=xv --mandir=/opt/local/share/man --enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-vda --arch=x86_64 --enable-yasm --enable-gpl --enable-postproc --enable-libx264 --enable-libxvid --enable-nonfree --enable-libfdk-aac --enable-libfaac
  libavutil      54. 17.100 / 54. 17.100
  libavcodec     56. 20.100 / 56. 20.100
  libavformat    56. 19.100 / 56. 19.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5.  8.100 /  5.  8.100
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[tiff_pipe @ 0x7f9f8381bc00] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, tiff_pipe, from '0.tiff':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: tiff, rgb48le, 2048x1152 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
File '0.jpeg' already exists. Overwrite ? [y/N] y
[swscaler @ 0x7f9f83812800] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to '0.jpeg':
  Metadata:
    encoder         : Lavf56.19.100
    Stream #0:0: Video: mjpeg, yuvj444p(pc), 2048x1152 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.20.100 mjpeg
Stream mapping:
  Stream #0:0 -> #0:0 (tiff (native) -> mjpeg (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A    
video:270kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Carl Eugen Hoyos
Elliott Balsley <elliottbalsley <at> gmail.com> writes:

> it still produces a file with noticeably less detail than
> the original, and macro blocking.

Please provide your input sample.

Carl Eugen




_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

spookybathtub

Please provide your input sample.

Here is a sample TIFF: https://drive.google.com/file/d/0B52QuT8oHvtZZkhSUkswUDhJSlU/view?usp=sharing
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Carl Eugen Hoyos
Elliott Balsley <elliottbalsley <at> gmail.com> writes:

> Here is a sample TIFF:
> https://drive.google.com/file/d/0B52QuT8oHvtZZkhSUkswUDhJSlU

I tested the following two command lines but I am unable
to see any macro blocking in the output files.
Where do you see it?
$ ffmpeg -i 0.tiff -qscale 0 out1.jpg
$ ffmpeg -i 0.tiff -qscale 2 out2.jpg

How do you test the output files?

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Moritz Barsnick
In reply to this post by spookybathtub
On Mon, Feb 09, 2015 at 17:56:06 -0800, Elliott Balsley wrote:
> Here is a sample TIFF: https://drive.google.com/file/d/0B52QuT8oHvtZZkhSUkswUDhJSlU/view?usp=sharing

I personally can't see the artifact. I had to subtract or XOR the two images
to identify the changes.

That said: ffmpeg with -qscale 0, 1, 2 creates (identical) images which
have approximately the same size as a conversion using ImageMagick with
libjpeg (albeit very old) with a "quality" setting of around 89%, which
is not generally considered "very good". YMMV

I'm trying to say: At first glance, ffmpeg either compresses much more
effectively (which I doubt) or doesn't use a high enough quality
setting. Whether that is intended, and whether the various qscale
settings should result in identical files, I can't say.

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Carl Eugen Hoyos
In reply to this post by Carl Eugen Hoyos
Carl Eugen Hoyos <cehoyos <at> ag.or.at> writes:

> $ ffmpeg -i 0.tiff -qscale 0 out1.jpg
> $ ffmpeg -i 0.tiff -qscale 2 out2.jpg

Sorry for these sample command lines:
The default minimal value for qscale is 2,
so these commands produce identical output.

To get a bigger output file use:
$ ffmpeg -i 0.tiff -qmin 1 -qscale 1 out.jpg

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Carl Eugen Hoyos
In reply to this post by Moritz Barsnick
Moritz Barsnick <barsnick <at> gmx.net> writes:

> ffmpeg with -qscale 0, 1, 2 creates (identical) images
> which have approximately the same size as a conversion
> using ImageMagick with libjpeg (albeit very old) with a
> "quality" setting of around 89%, which is not generally
> considered "very good". YMMV

Could you test again with -qmin 1 -qscale 1 ?

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Moritz Barsnick
On Tue, Feb 10, 2015 at 09:09:55 +0000, Carl Eugen Hoyos wrote:
> Could you test again with -qmin 1 -qscale 1 ?

-qscale 1:                276184 bytes
-qscale 1 (or 0) -qmin 1: 608994 bytes

I still don't see much of a visual difference, and no blocking or other
artifacts.

With paint.NET's XOR layer filter, I do see differences and -qmin 1
seems to have less of them.

608994 bytes is close to 95% quality with ImageMagick, which is
probably considered good-ish, but I'm not a total expert. And I don't
know what the OP is expecting.

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

Carl Eugen Hoyos
Moritz Barsnick <barsnick <at> gmx.net> writes:

> -qscale 1:                276184 bytes
> -qscale 1 (or 0) -qmin 1: 608994 bytes
>
> I still don't see much of a visual difference,
> and no blocking or other artifacts.
>
> With paint.NET's XOR layer filter, I do see differences
> and -qmin 1 seems to have less of them.
>
> 608994 bytes is close to 95% quality with ImageMagick

Could you compare the 95% ImageMagick output with
the qscale 1 output?

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create high quality JPEGs

spookybathtub
In reply to this post by Carl Eugen Hoyos
Could you test again with -qmin 1 -qscale 1 ?  


I tested again with those settings, and the result is better, but still not as good as a conversion by OS X Preview.  I’m only observing visually, using Preview.app.  The blockiness is especially noticeable on the black shirt chest area.  Here are example files. The one created by FFmpeg with qmin 1 is 609KB.  The one created by Preview is 1.9MB, and is nearly identical to the TIFF.

Original TIFF: https://drive.google.com/file/d/0B52QuT8oHvtZZkhSUkswUDhJSlU/view?usp=sharing
Preview: https://drive.google.com/file/d/0B52QuT8oHvtZYU5MX0dJWjcxdkU/view?usp=sharing
FFmpeg: https://drive.google.com/file/d/0B52QuT8oHvtZRW9SZjhsU2pYakE/view?usp=sharing
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user