I have video content in MJPEG format which I try to decode. It has been encoded using ffmpeg 3.2. The hardware decoder gives an error saying the stream is not supported. If I split the content into seperate frames (in MJPEG each frame is standard JPEG image) the 'X170 JPEG Decoder' tools says 'JPEGDEC_UNSUPPORTED'. If I load the same image in GIMP (image editing software) and save it then I can decode the image just fine. I have not been able to find export settings in GIMP which make the decoding fail. I also tried to examine the headers using this website https://cyber.meme.tips/jpdump/# but without knowing the exact specifications of the hardware decoder I don't know what to look for. I see differences between a file which works and which doesn't but that's it.
Has anyone experienced similar problems? It seems somehow ffmpeg is creating incompatible MJPEG content. I would like to know if there are any ffmpeg settings that have an effect on the JPEG encoding (I already tried a few but no success) or whether there is an older version of ffmpeg which encodes differently.
Thanks in advance!
Hello Nico,
By default the Linux BSP of the i.MX8M does not have the ffmpeg available you need to add the recipe, using yocto in
conf/local.conf
add:
IMAGE_INSTALL_append = "ffmpeg"
LICENSE_FLAGS_WHITELIST = 'commercial'
or add:
IMAGE_INSTALL_append = "gst-ffmpeg"
LICENSE_FLAGS_WHITELIST = 'commercial'
Thanks for responding but I'm not using Yocto but Debian and not ffmpeg but I'm using the VPU wrapper library (which is a thin layer on top of the hardware decoder) to decode MJPEG content. It is the hardware decoder which refuses decoding the MJPEG input which was created using ffmpeg on a PC.
Meanwhile my client is using an older version of the video transcoding package they use which (under the hood) uses a different version of ffmpeg. This seems to work so far.
The problem hasn't been solved. It turns out that when ffmpeg is set to YUV420 it works but YUV422 and YUV444 do not work. The decoder (IMX8MQ) says 'unsupported JPEG' for the latter two formats. This is becoming a blocking issue for my customer because they have no way to generate the proper video content so I hope someone at NXP can give me answer on what is going on and hopefully provide a solution. I have attached two images to this posting; the first decodes OK, the second doesn.t
(hopefully the webserver doesn't do any conversion on the images).
I have analysed the JPEG files furthers. It turns out the ffmpeg MJPEG encoder uses very odd sampling factors. A YUV444p image saved by Gimp uses sampling factors 1/1, 1/1, 1/1 for each component where ffmpeg uses 1/2,1/2,1/2. I have looked into the source of ffmpeg and it seems this odd behaviour is caused by how ffmpeg works with planar images. Worse, it will be very hard to fix ffmpeg. All in all the conclusion is that the MJPEG files created by ffmpeg are not compatible with the iMX8MQ hardware decoder except when using YUV420p.