Page 1 of 2

significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T14:02:59-07:00
by mabu
I have a script that runs that takes webcam .JPG images and converts it to an MPEG file using this command:

nice -n 5 /usr/local/bin/convert $ARCDIR/*.jpg -quality 85 /mpeg-archive/daily_timelapse.mpg

I recently moved this system/scripts from a FreeBSD 6.2 server using: ImageMagick 6.2.2 01/02/07 Q16
over to a FreeBSD 8.2 server using ImageMagick 6.6.6-10 2011-02-02 Q16

I have noticed the resulting .mpg files are noticeably worse quality even though the input .jpg images appear to be the same. Even with -quality 100 I still get very ugly, blocky mpeg video files. Does anyone have any ideas why?

The newer images are more pixelated. Are there other parameters that I can set to improve quality? Is there a way to tell if defaults for certain features have changed that might be affecting the output?

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T14:29:11-07:00
by fmw42
I am not an expert on this, but you could try the -sampling-factor. See http://www.imagemagick.org/script/comma ... ing-factor

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T16:07:23-07:00
by mabu
What would be a high-quality setting? I tried: -sampling-factor 1x1 and it didn't appear to make much of a difference.

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T16:19:08-07:00
by mabu
I just noticed something when I put new and old mpegs side-by-side. The original images are in 640x480 resolution and the output mpeg is in that resolution, but the new version convert seems to convert the image into a perfect square and that may be responsible for the horrible quality... how do keep it from messing with the aspect ratio?

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T17:30:34-07:00
by fmw42
mabu wrote:I just noticed something when I put new and old mpegs side-by-side. The original images are in 640x480 resolution and the output mpeg is in that resolution, but the new version convert seems to convert the image into a perfect square and that may be responsible for the horrible quality... how do keep it from messing with the aspect ratio?

I don't understand this. If both images are the same resolution 640x480 then they are the same size and aspect ratio. Is this with or without adding -sampling-factor? It could be related to a wrong sampling-factor, perhaps, though I am not an expert on that.

Can you post your exact command and links to your input and good and bad resulting images for just one frame and post those?

Seems to be more of an mpeg viewer issue, perhaps?

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T18:00:52-07:00
by mabu
The command is the same for both: convert *.jpg -quality 85 output.mpg

There is a file called ffmpeg2pass-0.log being generated that says stuff like: (don't know if it means anything)

in:471 out:471 type:2 q:3658 itex:252 ptex:778 mv:303 misc:1998 fcode:1 bcode:1 mc-var:103979 var:98645 icount:1 skipcount:1113 hbits:110;
in:472 out:472 type:2 q:3658 itex:0 ptex:387 mv:328 misc:1976 fcode:1 bcode:1 mc-var:97736 var:98457 icount:0 skipcount:1113 hbits:110;
in:473 out:473 type:2 q:3658 itex:0 ptex:594 mv:300 misc:1959 fcode:1 bcode:1 mc-var:98272 var:98470 icount:0 skipcount:1115 hbits:110;
in:474 out:474 type:2 q:3658 itex:0 ptex:690 mv:308 misc:1890 fcode:1 bcode:1 mc-var:99406 var:96957 icount:0 skipcount:1134 hbits:110;
in:475 out:475 type:2 q:3658 itex:0 ptex:689 mv:170 misc:1835 fcode:1 bcode:1 mc-var:98909 var:98310 icount:0 skipcount:1148 hbits:110;
in:476 out:476 type:2 q:3658 itex:0 ptex:921 mv:204 misc:1824 fcode:1 bcode:1 mc-var:100642 var:96988 icount:0 skipcount:1147 hbits:110;
in:477 out:477 type:2 q:3658 itex:0 ptex:701 mv:177 misc:1815 fcode:1 bcode:1 mc-var:97864 var:97205 icount:0 skipcount:1149 hbits:110;
in:478 out:478 type:2 q:3658 itex:0 ptex:511 mv:202 misc:1828 fcode:1 bcode:1 mc-var:96401 var:97254 icount:0 skipcount:1142 hbits:110;
in:479 out:479 type:2 q:3658 itex:0 ptex:279 mv:165 misc:1776 fcode:1 bcode:1 mc-var:94765 var:97087 icount:0 skipcount:1162 hbits:110;
in:479 out:479 type:2 q:3658 itex:0 ptex:279 mv:165 misc:1776 fcode:1 bcode:1 mc-var:94765 var:97087 icount:0 skipcount:1162 hbits:110;

It looks to me like the new mpg output is not the same resolution as the source input files - I do not know how or why that is changing. I'm using the simplest of commands to generate the mpg. I am at a loss as to what's wrong.

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T18:21:05-07:00
by mabu
# convert -list configure

Path: /usr/local/lib/ImageMagick-6.6.6/config/configure.xml

Name Value
-------------------------------------------------------------------------------
CC cc -std=gnu99 -std=gnu99
CFLAGS -I/usr/local/include/lqr-1 -I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -O2 -pipe -fno-strict-aliasing -Wall
CONFIGURE ./configure '--enable-shared' '--without-dps' '--disable-hdri' '--with-perl=/usr/local/bin/perl5.10.1' '--without-threads' '--disable-openmp' '--with-modules' '--without-openexr' '--without-djvu' '--without-gslib' '--with-lqr' '--with-fftw' '--with-fpx' '--without-gvc' '--with-freetype' '--with-fontconfig' '--without-wmf' '--without-rsvg' '--without-xml' '--with-x' '--x-libraries=/usr/local/lib' '--x-includes=/usr/local/include' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/local/info/' '--build=i386-portbld-freebsd8.0' 'build_alias=i386-portbld-freebsd8.0' 'CC=cc' 'CFLAGS=-O2 -pipe -fno-strict-aliasing' 'LDFLAGS=-L/usr/local/lib' 'CPPFLAGS=-I/usr/local/include' 'CPP=cpp' 'CXX=c++' 'CXXFLAGS=-O2 -pipe -fno-strict-aliasing' 'FONTCONFIG_CFLAGS=-I/usr/local/include' 'FONTCONFIG_LIBS=-L/usr/local/lib'
COPYRIGHT Copyright (C) 1999-2011 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick
CXX c++
CXXFLAGS -O2 -pipe -fno-strict-aliasing
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib fftw fpx fontconfig freetype jbig jpeg jng jp2 lcms lqr png tiff x11 zlib
DISTCHECK_CONFIG_FLAGS 'CC=cc' 'CFLAGS=-O2 -pipe -fno-strict-aliasing' 'CPPFLAGS=-I/usr/local/include' 'CXX=c++' 'LDFLAGS=-L/usr/local/lib' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-djvu=no --with-gslib=no --with-fontpath= --with-gvc=no --with-openexr=no --with-rsvg=no --with-wmf=no --with-xml=no --with-perl=/usr/local/bin/perl5.10.1
EXEC-PREFIX /usr/local
FEATURES
HOST i386-portbld-freebsd8.0
LDFLAGS -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -R/usr/local/lib
LIB_VERSION 0x666
LIB_VERSION_NUMBER 6,6,6,10
LIBS -lMagickCore -llcms -ltiff -lfreetype -ljpeg -L/usr/local/lib -llqr-1 -lglib-2.0 -lfftw3 -L/usr/local/lib -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lltdl
NAME ImageMagick
PCFLAGS
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 2011-02-02
VERSION 6.6.6
WEBSITE http://www.imagemagick.org

Path: [built-in]

Name Value
-------------------------------------------------------------------------------
NAME ImageMagick


old server:

convert -list configure

Path: /usr/local/lib/ImageMagick/config/configure.xml

Name Value
-------------------------------------------------------------------------------
CC cc
CFLAGS -O2 -fno-strict-aliasing -pipe -Wall
CONFIGURE ./configure --enable-shared --with-perl=/usr/local/bin/perl5.8.7 --without-threads --with-fpx --without-dot --without-wmf --with-dps --with-gslib --with-x --x-libraries=/usr/X11R6/ lib --x-includes=/usr/X11R6/include --prefix=/usr/local --build=i386-portbld-freebsd6.0
COPYRIGHT Copyright (C) 1999-2005 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include
CVS_BRANCH_TAG HEAD
CXX c++
CXXFLAGS -O2 -fno-strict-aliasing -pipe
DEFS -DHAVE_CONFIG_H
DISTCHECK_CONFIG_FLAGS --enable-shared --with-perl=/usr/local/bin/perl5.8.7 --without-threads --with-fpx --without-dot --without-wmf --with-dps --with-gslib --with-x --x-libraries=/usr/X11R6/lib --x-includes=/usr/X11R6/include --prefix=/usr/local --build=i386-portbld-freebsd6.0'CC=cc' 'CFLAGS=-O2 -fno-strict-aliasing -pipe ' 'CPPFLAGS=-I/usr/local/include' 'CXX=c++' 'LDFLAGS=-L/usr/loc al/lib'
EXEC-PREFIX /usr/local
HOST i386-portbld-freebsd6.0
LDFLAGS -L/usr/local/lib -L/usr/local/lib -L/usr/X11R6/lib -L/usr/local/lib -Wl,--rpath -Wl,/usr/local/lib -lfreetype -lz -L/usr/local/lib
LIB_VERSION 0x622
LIB_VERSION_NUMBER 6.2.2,1
LIBS -lMagick -ljbig -llcms -ltiff -lfreetype -ljasper -ljpeg -lpng -lfpx -ldpstk -ldps -lXext -lXt -lSM -lICE -lX11 -lbz2 -lxml2 -lz -lm
NAME ImageMagick
PCFLAGS
PREFIX /usr/local
QuantumDepth 16
RELEASE_DATE 01/02/07
VERSION 6.2.2
WEBSITE http://www.imagemagick.org

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T18:30:47-07:00
by fmw42
I don't see an mpeg in your list of DELEGATES or in the old system LIBS?

On my system:


DELEGATES bzlib fftw fontconfig freetype gs jpeg jng jp2 lcms2 lqr lzma mpeg openexr png rsvg tiff x11 xml zlib

Again I am no expert on this. So I cannot say much about the delegate issue for you.

Looking at your mpeg files, the sizes (resolutions are the same), but it appears that the mpeg encoding is lower quality (higher compression) as you said on the new version. You could try increasing the -quality value above 85 and see if that helps.

It is possible that the mpeg encoder has changed with versions of IM. But then I don't know as your DELEGATES does not list how that is happening.

One of the IM developers may need to respond to this.

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T18:48:05-07:00
by mabu
I get almost identical results if I use "-quality 100" - it makes no sense and is driving me crazy... HELP!!

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T18:52:39-07:00
by mabu
actually, wtf..... the web site says: 'The current release is ImageMagick 6.6.9-8.' why do I have 6.6.6.10?

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T19:18:00-07:00
by fmw42
mabu wrote:actually, wtf..... the web site says: 'The current release is ImageMagick 6.6.9-8.' why do I have 6.6.6.10?

one is 6.6.9.x and yours is 6.6.6.x

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T19:18:46-07:00
by anthony
Also have a look at the notes of video format handling
http://www.imagemagick.org/Usage/formats/#mpeg

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T19:41:41-07:00
by mabu
I tried using m2v: as in: convert ar1-*.jpg m2v:out.mpg

It still resulted in a 1.5MB crappy quality file

I'm stuck.

Is there an alternative to IM to use for something like this? I simply want to create a time-lapse video of approximately 400-500 jpgs that is of non-horrendous quality.

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T19:46:02-07:00
by fmw42
try ffmpeg at http://www.ffmpeg.org/

That is what I installed to get mpeg showing in my list of DELEGATES (after re-installing IM so it recognized it). (Though I have little experience using it outside or within IM).

Re: significant quality loss moving from 6.2 to 6.6..

Posted: 2011-05-11T20:00:37-07:00
by mabu
I can't find any examples of directly calling ffmpeg that work for me. It's installed on the system and apparently used by IM.