• DepthAI-v2
  • Issue with MJPEG Encoder and Lossless Option

Hello,

I have slightly modified this example to experiment with the MJPEG encoder. Here's my code :

I observed that when using videoEnc.setLossless(True), the output JPEG is not valid, and I receive the following error:

Traceback (most recent call last): File "/home/fabien/Dev/Python/depthai-experiments/gen2-record-replay/12mp_record_mjpeg.py", line 51, in <module> cv2.imwrite("test.jpg", img) cv2.error: OpenCV(4.8.0) /io/opencv/modules/imgcodecs/src/loadsave.cpp:787: error: (-215 failed) !_img.empty() in function 'imwrite'

If I remove the setLossless(True) option, test.jpg is correctly generated. Is there anything specific I need to do to decode a lossless image?

Thank you for your help.

  • jakaskerl replied to this.
  • Hi FabPoll

    It's non-standard so the decoding/viewing is different. You can use ffplay lossless.jpeg to view the saved image.

    Thanks,
    Jaka

    Hi FabPoll

    It's non-standard so the decoding/viewing is different. You can use ffplay lossless.jpeg to view the saved image.

    Thanks,
    Jaka

      a month later

      FabPoll

      Hi, the accepted answer shows how to view a saved image. But how did you manage to decode/save the file with the setLossless(True) option in your code?

        zepman
        I do not use this option since it produces a non standard jpeg. You need a decoder that supports lossless jpeg which is not my case.