#4523 closed defect (worksforme)
JPEG2000 yuv420p file generated by ffmpeg with libopenjpeg codec is broken
| Reported by: | Stefano Sabatini | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | libopenjpeg |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
Summary of the bug:
How to reproduce:
$ ffmpeg -i fate-samples/lena.pnm -strict -2 -c libopenjpeg -pix_fmt yuv420p -y lena.yuv420p.j2k
ffmpeg version N-71578-g57865a9 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --extra-cflags=-I/home/stefano/include --extra-ldflags=-L/home/stefano/lib --enable-libopenjpeg --enable-pic --enable-fontconfig --enable-libass --enable-version3 --prefix=/home/stefano --disable-shared --enable-static --enable-debug=3 --enable-pthreads --disable-optimizations --enable-libvorbis --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libtheora --enable-gpl --enable-x11grab --enable-frei0r --enable-libfaac --enable-libcaca --enable-libflite --enable-libzmq --enable-libfreetype --enable-libopencv --enable-libgme --enable-libcdio --enable-libvo-aacenc --enable-libx264 --enable-ladspa --enable-libquvi --enable-opengl --enable-libvpx --enable-libxcb
libavutil 54. 23.100 / 54. 23.100
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, image2, from 'fate-samples/lena.pnm':
Duration: 00:00:00.04, start: 0.000000, bitrate: 39333 kb/s
Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, image2, to 'lena.yuv420p.j2k':
Metadata:
encoder : Lavf56.30.100
Stream #0:0: Video: jpeg2000 (libopenjpeg), yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 libopenjpeg
Stream mapping:
Stream #0:0 -> #0:0 (ppm (native) -> jpeg2000 (libopenjpeg))
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:46kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
The generated file lena.yuv420p.j2k can be successfully decoded, but contains chroma artifacts. Of the three applications used to display it (ffplay, okular, display) only okular was able to show the image correctly.
Re-encoding the file with ffmpeg generates a corrupted image, showing the same artifacts as the image displayed by ffplay (see attachment):
ffmpeg -i lena.yuv420p.j2k lena.yuv420p.png
ffmpeg version N-71578-g57865a9 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --extra-cflags=-I/home/stefano/include --extra-ldflags=-L/home/stefano/lib --enable-libopenjpeg --enable-pic --enable-fontconfig --enable-libass --enable-version3 --prefix=/home/stefano --disable-shared --enable-static --enable-debug=3 --enable-pthreads --disable-optimizations --enable-libvorbis --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libtheora --enable-gpl --enable-x11grab --enable-frei0r --enable-libfaac --enable-libcaca --enable-libflite --enable-libzmq --enable-libfreetype --enable-libopencv --enable-libgme --enable-libcdio --enable-libvo-aacenc --enable-libx264 --enable-ladspa --enable-libquvi --enable-opengl --enable-libvpx --enable-libxcb
libavutil 54. 23.100 / 54. 23.100
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, j2k_pipe, from 'lena.yuv420p.j2k':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: jpeg2000 (JPEG 2000 codestream restriction 0), yuv420p, 256x256, 25 tbr, 25 tbn, 25 tbc
File 'lena.yuv420p.png' already exists. Overwrite ? [y/N] y
Output #0, apng, to 'lena.yuv420p.png':
Metadata:
encoder : Lavf56.30.100
Stream #0:0: Video: apng, rgb24, 256x256, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 apng
Stream mapping:
Stream #0:0 -> #0:0 (jpeg2000 (native) -> apng (native))
Press [q] to stop, [?] for help
[apng @ 0x24703c0] Only a single frame so saving as a normal PNG.
frame= 1 fps=0.0 q=0.0 Lsize= 140kB time=00:00:00.04 bitrate=28599.6kbits/s
video:140kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.019585%
The problem doesn't exist if I use -pix_fmt yuv444p.
Attachments (2)
Change History (13)
by , 11 years ago
| Attachment: | lena.yuv420p.j2k added |
|---|
by , 11 years ago
| Attachment: | lena.yuv420p.png added |
|---|
PNG version generated by ffmpeg from the broken J2K file
comment:1 by , 11 years ago
| Priority: | important → normal |
|---|---|
| Reproduced by developer: | unset |
I cannot reproduce your issue, please upload lena.yuv420p.j2k / duplicate of ticket #3619
follow-up: 3 comment:2 by , 11 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
Sorry for the last post, I didn't see the files.
Works fine here:
$ ffmpeg -i fate-suite/lena.pnm -pix_fmt yuv420p -f crc -
ffmpeg version N-71737-gb410c69 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.7 (SUSE Linux)
configuration: --enable-gpl --enable-libopenjpeg
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 31.100 / 56. 31.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, image2, from 'fate-suite/lena.pnm':
Duration: 00:00:00.04, start: 0.000000, bitrate: 39333 kb/s
Stream #0:0: Video: ppm, rgb24, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, crc, to 'pipe:':
Metadata:
encoder : Lavf56.31.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (ppm (native) -> rawvideo (native))
Press [q] to stop, [?] for help
CRC=0xe29408ed
frame= 1 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate= 3.0kbits/s
video:96kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
$ ffmpeg -vcodec libopenjpeg -i lena.yuv420p.j2k -f crc -
ffmpeg version N-71737-gb410c69 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.7 (SUSE Linux)
configuration: --enable-gpl --enable-libopenjpeg
libavutil 54. 23.101 / 54. 23.101
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 31.100 / 56. 31.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, j2k_pipe, from 'lena.yuv420p.j2k':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: jpeg2000, yuv420p, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, crc, to 'pipe:':
Metadata:
encoder : Lavf56.31.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (jpeg2000 (libopenjpeg) -> rawvideo (native))
Press [q] to stop, [?] for help
CRC=0xe29408ed
frame= 1 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate= 3.0kbits/s
video:96kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
comment:3 by , 11 years ago
| Resolution: | worksforme |
|---|---|
| Status: | closed → reopened |
Replying to cehoyos:
Sorry for the last post, I didn't see the files.
Works fine here:
[...]
Yes, but if I use the native decoder I get a different value:
$ ffmpeg -i lena.yuv420p.j2k -f crc -
ffmpeg version N-71578-g57865a9 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
configuration: --extra-cflags=-I/home/stefano/include --extra-ldflags=-L/home/stefano/lib --enable-libopenjpeg --enable-pic --enable-fontconfig --enable-libass --enable-version3 --prefix=/home/stefano --disable-shared --enable-static --enable-debug=3 --enable-pthreads --disable-optimizations --enable-libvorbis --enable-gpl --enable-nonfree --enable-libmp3lame --enable-libtheora --enable-gpl --enable-x11grab --enable-frei0r --enable-libfaac --enable-libcaca --enable-libflite --enable-libzmq --enable-libfreetype --enable-libopencv --enable-libgme --enable-libcdio --enable-libvo-aacenc --enable-libx264 --enable-ladspa --enable-libquvi --enable-opengl --enable-libvpx --enable-libxcb
libavutil 54. 23.100 / 54. 23.100
libavcodec 56. 35.101 / 56. 35.101
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 14.100 / 5. 14.100
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, j2k_pipe, from 'lena.yuv420p.j2k':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: jpeg2000 (JPEG 2000 codestream restriction 0), yuv420p, 256x256, 25 tbr, 25 tbn, 25 tbc
Output #0, crc, to 'pipe:':
Metadata:
encoder : Lavf56.30.100
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 256x256, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc
Metadata:
encoder : Lavc56.35.101 rawvideo
Stream mapping:
Stream #0:0 -> #0:0 (jpeg2000 (native) -> rawvideo (native))
Press [q] to stop, [?] for help
CRC=0x62f5dca0
frame= 1 fps=0.0 q=0.0 Lsize= 0kB time=00:00:00.04 bitrate= 3.0kbits/s
video:96kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
In short, of the various options I tried (libavcodec native decoder, display, okular, irfanview), only ffmpeg+libopenjpeg and okular were able to correctly decode the file generated by ffmpeg with libopenjpeg. It could also be a problem related to libopenjpeg.
comment:4 by , 11 years ago
Of course!
The native j2k decoder is highly experimental, it does not work (correctly!) for any input file. But you reported an issue with libopenjpeg encoder, I see no indication that this issue exists: What version of ImageMagick did you test?
follow-ups: 9 11 comment:5 by , 11 years ago
Works fine with Preview 8.0 and jasper. Why do you believe there is an issue with the file you attached?
How does the output of identify lena.yuv420p.j2k looks like?
comment:7 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | reopened → closed |
Conversion of the file you attached works fine with current ImageMagick.
$ convert --version Version: ImageMagick 6.9.1-2 Q16 x86_64 2015-04-28 http://www.imagemagick.org Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC License: http://www.imagemagick.org/script/license.php Features: DPC OpenMP Delegates (built-in): bzlib fontconfig freetype jp2 jpeg lzma pangocairo tiff x zlib
comment:8 by , 11 years ago
| Resolution: | fixed → worksforme |
|---|
follow-up: 10 comment:9 by , 11 years ago
Replying to cehoyos:
Works fine with Preview 8.0 and jasper. Why do you believe there is an issue with the file you attached?
How does the output ofidentify lena.yuv420p.j2klooks like?
$ identify lena.yuv420p.j2k lena.yuv420p.j2k JP2 256x256 256x256+0+0 8-bit DirectClass 47.4KB 0.030u 0:00.019
$ identify --version Version: ImageMagick 6.7.7-10 2014-03-06 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC Features: OpenMP
Will try with a more recent version of imagemagik.
comment:10 by , 11 years ago
Replying to saste:
$ identify lena.yuv420p.j2k lena.yuv420p.j2k JP2 256x256 256x256+0+0 8-bit DirectClass 47.4KB 0.030u 0:00.019
It looks slightly different here:
$ identify lena.yuv420p.j2k lena.yuv420p.j2k J2K 256x256 256x256+0+0 8-bit YUV 47.4KB 0.000u 0:00.000
comment:11 by , 11 years ago
Replying to cehoyos:
Works fine with Preview 8.0 and jasper. Why do you believe there is an issue with the file you attached?
How does the output ofidentify lena.yuv420p.j2klooks like?
I confirm that this is working fine with latest version of imagemagick.
So I guess the problem is probably related to the various software versions I tried rather than being a problem with the encoder. I'll leave this ticket closed until there is an evidence that the problem is in the openjpeg FFmpeg encoder.
Thanks for your assistance.



File generated by ffmpeg