cjxl fails on "MotionPhoto" jpegs #3504
Replies: 1 comment
-
More generally it would be good if we have a better way to treat "semantically meaningful" tail data when transcoding JPEG files. Besides these "MotionPhoto" cases, there is also UltraHDR (which has a gain map in the tail data) and MPF in general (Multi Picture Format) like some examples I've seen where the main image has fake bokeh applied to the background but the original image with a sharp background is still there in the tail data; also just a concatenation of JPEG files (which is something e.g. ffmpeg can ingest) could be seen as an example of this. Currently tail data is stored in the It would be cleaner if we would define some kind of recursive structure in the file format where there is an optional box, name TBD but for the purpose of discussion we could call it Maybe instead of This method could also be used to extend the JXL file format to allow representing sequences of images that are coded completely independently (i.e. not as frames within a single JXL codestream), which can be useful since multi-frame single-codestream JXL has the limitation that all frames need to have the same dimensions and colorspace. I am turning this issue into a discussion since this is not just a libjxl issue but changing anything here would require extending the spec (ISO/IEC 18181-2 in this case). |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
MotionPhotos are a cursed file where a video appended to a jpeg file.
cjxl
will currently fail to transcode the image with lossless bitstream reconstruction data with the error "JPEG bitstream reconstruction data could not be created. Possibly there is too much tail data."To Reproduce
cjxl filein.jpeg fileout.jxl
File provided
Expected behavior
A) CJXL could discard the data and throw a message to the user. While discarding this data isn't technically lossless as far as the entire image file is concerned. This extra data doesn't pertain to the actual jpeg itself needed for proper reconstruction of the "image". CJXL should likely by default exit with an "Error" to bail out of any scripts unless an extra flag is passed.
B) CJXL could append the same video file to the end of the JXL file in the same manor as a motionphoto. This would retain "true" losslessness of the entire file and not just the jpeg data.
Screenshots
Not Aplicable
Environment
Additional context
MotionPhotos are cursed, but there are a good number of them out in the wild and failing to transcode these with lossless reconstruction is a pain point for at least some users
Exiftool can identify multiple types of motionphotos "Motion Photo" is the most common, However some "Micro Videos" exist too. exiftool can find the appropriate offset for those using
exiftool "$FILENAME" | grep "Micro Video Offset" | sed -E 's/^[^:]+: ([0-9]+)$/\1/'
Almost all motion photos seem to be mp4 based and have a
ftypmp42
signature to them. Identification based on this seems reliable.to extract the video from a MotionPhoto
exiftool -b -EmbeddedVideoFile motionphoto.jpg > out.mp4
to extract the JPEG data from a motionphoto (replaces the current file, creates a new "original file")
exiftool -b -trailer:all= motionphoto.jpeg
Example Image
Beta Was this translation helpful? Give feedback.
All reactions