Võ Anh Kiệt
Võ Anh Kiệt

Reputation: 409

HEVC Encoder (convert from JPG to HEIC)

I have some trouble when converting from JPG to HEIC format (using HEVC Encoding) on Android

I'm using Nokia HEIF's library (https://github.com/nokiatech/heif/) for parsing data which I need to put some data includes:

  1. Decoder config data (as a byte array) following the name called by Nokia, I think that data can be profile data, header data, ... that store the VPS/PPS, Exif, metadata ...

  2. Image data following the name called by Nokia -> This may is a bitstream of HEVC Encoding.

So now, I got the image data bitstream (2) based FFMPEG tool by command as bellow: ffmpeg -i oktest.png -crf 12 -preset medium -pix_fmt yuv420p -f hevc.bin

This is a referring link from Nokia that they guide how to do feed data and encode to HEIF format. https://github.com/nokiatech/heif/issues/44

But, I didn't understand how I can get the decoder config data from the FFMPEG tool because I'm developing on Android platforms instead. I mean some definitions are determined different from the mind so I can't find any solutions for this. I already request a ticket to Nokia support, but no response yet.

        val heif = HEIF()
       val decoderConfig = context.assets.open(bitStreamDecoderConfig).readBytes()
        val decoderConfig = decoderBuffer?.array() ?: ByteArray(0)
        val imageData = FileInputStream(bitStreamData).readBytes()
        val imageItem =
            HEVCImageItem(heif, Size(imageWidth, imageHeight), decoderConfig, imageData)
        heif.primaryImage = imageItem
        heif.majorBrand = HEIF.BRAND_MIF1
        heif.addCompatibleBrand(HEIF.BRAND_HEIC)
        heif.save("$targetOutputFolder/$fileNameNoneExtension.${destinationType()}")

Upvotes: 1

Views: 2910

Answers (1)

There is a page at http://jpgtoheif.com/ which suggest use ffmpeg itself instead the nokia tool.

there is another solution libheif with a windows build is at https://github.com/pphh77/libheif-Windowsbinary/releases

Upvotes: -1

Related Questions