4

I've been looking around for a while for a way to start packing image bytestreams into HEIF files, since macOS High Sierra and and iOS 11 are now out. Haven't had much luck, just large numbers of people converting .heic files to .jpg, and the Nokia JS viewer on GitHub

To start, I am not looking to convert my existing Photo Library all to HEVC encoded .heic files, there's diminishing returns to be had there since they're already jpegged and have had quality loss from the original. So this question is not a duplicate of the "Convert whole library to new .HEIC format" question

My goal:

  • Take both a mpeg bytestream and a PNG or JPG bytestream and pack them into a .heic file

  • Take multiple PNG and/or JPG bytestreams and make a .heic file of them (like a burst series of photos)

HEIF is just a container, so while it was designed for HEVC use, it does support other data types like jpg, png, pretty much anything that the viewing applications support in their natives file formats.

I just haven't been able to find any software that will let me do it. Everything I search for to do with HEIF or HEIC in the term just pumps me with tech news headlines about Apple trying to replace jpeg, and people converting their .heic files once their imported from their computer (which seems like it would take effort to do since iOS defaultly will convert them for you if you try to import them or share them anywhere it can't explicitly confirm the reaching end supports them...)

So I'm hoping someone here knows a thing or two and could point me in the right direction at least.

I'm not adverse to command line tools, or even doing some development myself if I can get pointed at a library I can import into a Swift application (I'm a late bloomer in programming, and while I could say the same for Javascript, if I was to build an app around a library to do this work, I'd much rather use Swift than use a scripting language)

So hopefully someone has thought the same thing and had better luck than me finding this! :)

Edit 1, Nov 10:

I've found a site by a bloke called Ben Gotow that talks about converting existing JPEGs into HEVC bitstreams, and then putting them into a .heic or .heif container. It's close, but he hadn't been able to find a lot of detail for doing more than that. I'm not adding this as an answer, just as an edit since it is relevant but doesn't actually achieve my goal. hope anyone else finding this question will find his site useful!
jpgtoheif.com

  • 1
    it feels it will be very hard to find the answer on "making" these files on your own, since it's hard to find even a viewer-app for HEIC, not even saying about creation/editing... – Farside Nov 9 '17 at 11:21
  • Yeah, that is my worry... Still, at least if I ask the question, hopefully gradually other people will find this question and maybe even contribute what they have found. For them moment all I can find, no matter what I search, is "How do I convert HEIC/HEIF to JPEG" posts. And one website talking about converting jpegs and videos to HEVC and putting them in a HEIF container (I'm about to add that to the original question as an edit, since it has a little relevant data anyway :) – FreelancerJ Nov 10 '17 at 5:54
2

This use of GPAC may move closer to the goals you desire:

What is GPAC?

GPAC is an Open Source multimedia framework. GPAC is used for research and academic purposes and beyond through industrial collaborations! The project covers different aspects of multimedia, with a focus on presentation technologies (graphics, animation and interactivity) and on multimedia packaging formats such as MP4.

More details:

A little more research and an answer here provides the way! We need several things installed, ideally with homebrew:

  • x265 and GPAC brew install x265 gpac
  • FFmpeg with x265 support

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265 Reference

Now that you have the tools, try a script like this to convert images in a folder to HEIF/HEIC:

for F in *.jpg *.png *.tif *.tiff; \ do ffmpeg -i "$F" -crf 23 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -preset slower -pix_fmt yuv420p -f hevc "${F%.*}.hvc" && \ MP4Box -add-image "${F%.*}.hvc" -ab heic -new "${F%.*}.heic" && \ rm "${F%.*}.hvc"; done;

I tried it with a folder of images and it works. It turns images with odd dimensions to even dimensions, for instance, but besides a few caveats it works.

  • 1
    I'm gonna be doing a lotta reading now, it looks like! If it can get what I'm after down pat, I'll be back here and edit what I find onto the end of your answer for anyone else who might be after the same thing and mark it as accepted, unless someone else comes along with a better answer :) – FreelancerJ Mar 18 '18 at 7:15
  • No, this doesn't answer your taking multiple PNG and/or JPG bytestreams and making a .heic file of them (like a burst series of photos) - but I suspect it just requires learning some more GPAC. It seems pretty versatile! – Matthew Briggs Apr 7 '18 at 17:11
  • 1
    As a point of interest, you are not restricted to JPEG, PNG and TIFF images. FFmpeg supports other image formats. JPEG2000 worked out of the box when tested, for instance. – Matthew Briggs Apr 9 '18 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .