[FFmpeg-user] Image Conversion TIFF > JPEG with yuv422 chroma subsampling

Andrea Rastelli a.rastelli at rbw-cgi.it
Wed Jan 21 09:33:21 CET 2015


On 20/01/2015 17:44, Moritz Barsnick wrote:
> On Tue, Jan 20, 2015 at 17:16:47 +0100, Andrea Rastelli wrote:
>> I'm sorry but even with your help seems impossible to properly convert
>> my images.
> It may depend heavily on the input, but at least I can successfully
> create JPEG from a TIFF, and it can be read by many programs:
>
> $ ffmpeg -i /usr/share/doc/tesseract-3.02.02/eurotext.tif -pix_fmt yuv422p -q 1 eurotext.jpg -y
> ffmpeg version 2.5.git Copyright (c) 2000-2015 the FFmpeg developers
>    built on Jan 11 2015 15:42:28 with icc (ICC) 14.0.3 20140422
>    configuration: --prefix=/usr/new/tools/video/install/ffmpeg/2015-01-10 --enable-gpl --enable-version3 --enable-nonfree --disable-shared --enable-gnutls --enable-libcdio --enable-libfreetype --enable-libx264 --enable-libmp3lame --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libass --enable-libv4l2 --enable-libvidstab --enable-libfdk-aac --enable-libsmbclient --enable-libquvi --cc=icc --cxx=icpc --extra-ldflags='-L/usr/new/tools/video/install/x264/current/lib -L/usr/new/tools/video/install/fdk-aac/current/lib' --extra-cflags='-I/usr/new/tools/video/install/x264/current/include -I/usr/new/tools/video/install/fdk-aac/current/include'
>    libavutil      54. 16.100 / 54. 16.100
>    libavcodec     56. 20.100 / 56. 20.100
>    libavformat    56. 18.100 / 56. 18.100
>    libavdevice    56.  3.100 / 56.  3.100
>    libavfilter     5.  7.100 /  5.  7.100
>    libswscale      3.  1.101 /  3.  1.101
>    libswresample   1.  1.100 /  1.  1.100
>    libpostproc    53.  3.100 / 53.  3.100
> Input #0, tiff_pipe, from '/usr/share/doc/tesseract-3.02.02/eurotext.tif':
>    Duration: N/A, bitrate: N/A
>      Stream #0:0: Video: tiff, monob, 1024x800 [SAR 1:1 DAR 32:25], 25 tbr, 25 tbn, 25 tbc
> Incompatible pixel format 'yuv422p' for codec 'mjpeg', auto-selecting format 'yuvj422p'
> [swscaler @ 0xb6962c0] deprecated pixel format used, make sure you did set range correctly
> Output #0, image2, to 'eurotext.jpg':
>    Metadata:
>      encoder         : Lavf56.18.100
>      Stream #0:0: Video: mjpeg, yuvj422p(pc), 1024x800 [SAR 1:1 DAR 32:25], 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:180kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
>
> Note the warning about the pixel format.
>
> Moritz

Actually the problem is not in the creation of the JPEG itself, but in 
the resulting chroma subsampling that (apparently) is not stored in the 
FFmpeg resulting image.
With ImageMagick, when I set -sampling-factor 4:4:4 or 4:2:2 a tool like 
"mediainfo" shows the exact subsampling. With ffmpeg this information is 
not set nor visible.
Also, ImageMagick produce a bigger file (1.4Mb) than ffmpeg (0.1Mb).
Some image comparation tool (or simple a "difference" color blending 
mode in photoshop) between ffmpeg and imagemagick results, shows HUGE 
differences in image production (with the same parameters: 4:4:4 and 
maximum quality):
ffmpeg => blocky, blurred
IM => sharp and more "like" the original

For this specific task I need the IM results because an image sequence 
in TIFF can fill my RAM to be previewed as video, instead the same image 
sequence in JPEG is more manageable, and the IM result produce each 
image in a "comparable" way with the TIFF source (for each color and 
sharpness).
The FFmpeg image sequence looks A LOT lighter than IM, but each image is 
(a lot) worse than the original, and can't be used for my comparation 
purpose.

If, with FFMpeg, exists some parameter that produce the same result that 
I have obtained with ImageMagick will be prefect (because, now, I have 
two different tools to manage in my scripts)


More information about the ffmpeg-user mailing list