Opened 4 years ago

Closed 4 years ago

#4689 closed defect (fixed)

jpeg2000: kakadu doesn't like ffmpeg-generated jp2 files

Reported by: ami_stuff Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: j2k
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

irfanview also refuses to process them

C:\>ffmpeg -i test.bmp -vcodec jpeg2000 -strict -2 out.jp2
ffmpeg version N-73189-g7728d23 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-l
ibilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enab
le-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --en
able-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --ena
ble-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc
 --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enabl
e-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --ena
ble-decklink --enable-zlib
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 45.100 / 56. 45.100
  libavformat    56. 38.102 / 56. 38.102
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 18.100 /  5. 18.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, bmp_pipe, from 'test.bmp':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: bmp, bgr24, 999x749, 25 tbr, 25 tbn, 25 tbc
File 'out.jp2' already exists. Overwrite ? [y/N] y
Output #0, image2, to 'out.jp2':
  Metadata:
    encoder         : Lavf56.38.102
    Stream #0:0: Video: jpeg2000, rgb24, 999x749, q=2-31, 200 kb/s, 25 fps, 25 t
bn, 25 tbc
    Metadata:
      encoder         : Lavc56.45.100 jpeg2000
Stream mapping:
  Stream #0:0 -> #0:0 (bmp (native) -> jpeg2000 (native))
Press [q] to stop, [?] for help
frame=    1 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:881kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing o
verhead: unknown
C:\>kdu_render.exe -i out.jp2 -o out.bmp
Kakadu Core Error:
Code-stream must start with an SOC marker!
Error in Kakadu Region Compositor:
Unable to create imagery layer for direct rendering of image components from
codestream (index starting from 0) 0: codestream cannot be opened.

Attachments (6)

out.jp2 (881.4 KB) - added by ami_stuff 4 years ago.
test.bmp (2.1 MB) - added by ami_stuff 4 years ago.
lead.jp2 (704.9 KB) - added by ami_stuff 4 years ago.
jasper.jp2 (103.6 KB) - added by cehoyos 4 years ago.
image_to_j2k.jp2 (103.6 KB) - added by cehoyos 4 years ago.
patchftyp.diff (500 bytes) - added by cehoyos 4 years ago.

Change History (16)

Changed 4 years ago by ami_stuff

Changed 4 years ago by ami_stuff

comment:1 Changed 4 years ago by cehoyos

Could you also test with -pred 1 (to activate the lossless mode)?

comment:2 Changed 4 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords j2k added
  • Version changed from unspecified to git-master

And with -format j2k.

comment:3 follow-up: Changed 4 years ago by ami_stuff

  1. "-pred 1" alone doesn't change anything

but

  1. "-format j2k" file decodes correctly with kakadu/irfanview (with or without "-pred 1")
Last edited 4 years ago by ami_stuff (previous) (diff)

comment:4 in reply to: ↑ 3 ; follow-up: Changed 4 years ago by cehoyos

Replying to ami_stuff:

  1. "-format j2k" file decodes correctly with kakadu/irfanview (with or without "-pred 1")

Then I assume there is just a missing feature in kakadu: You could also test with jasper jp2 encoding or image_to_j2k jp2 encoding.

comment:5 in reply to: ↑ 4 Changed 4 years ago by ami_stuff

Replying to cehoyos:

Replying to ami_stuff:

  1. "-format j2k" file decodes correctly with kakadu/irfanview (with or without "-pred 1")

Then I assume there is just a missing feature in kakadu: You could also test with jasper jp2 encoding or image_to_j2k jp2 encoding.

I belive it's a bug in ffmpeg's code. Attached jp2 file decodes correctly with kakadu.

Changed 4 years ago by ami_stuff

Changed 4 years ago by cehoyos

Changed 4 years ago by cehoyos

comment:6 follow-up: Changed 4 years ago by cehoyos

Could be an issue with the length of the ftyp atom. Do the attached samples also work?

comment:7 in reply to: ↑ 6 Changed 4 years ago by ami_stuff

Replying to cehoyos:

Could be an issue with the length of the ftyp atom. Do the attached samples also work?

yes

C:\>kdu_render.exe -i jasper.jp2 -o out.bmp
Rendering finished, using 8 parallel threads of execution.

C:\>kdu_render.exe -i image_to_j2k.jp2 -o out.bmp
Rendering finished, using 8 parallel threads of execution.

Changed 4 years ago by cehoyos

comment:8 Changed 4 years ago by cehoyos

Does attached patch make a difference?

comment:9 Changed 4 years ago by cehoyos

  • Reproduced by developer set
  • Status changed from new to open

No need to test, it works, I will send the patch in a moment.

comment:10 Changed 4 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.