dreampiggy / AVIFQuickLook

AVIF QuickLook plugin on macOS
MIT License
171 stars 5 forks source link

Animated AVIF not playing #17

Open superbonaci opened 1 year ago

superbonaci commented 1 year ago

File sequence-without-pitm.avif from this bug is animated: AVIF (AV1 Image File Format): image sequence and animation support

But animation is not played by AVIFQuickLook, only static image. Google Chrome does play it.

$ qlmanage -p sequence-without-pitm.avif
Testing Quick Look preview with files:
    sequence-without-pitm.avif
2023-07-25 10:39:29.280 qlmanage[3543:28404] +[IKImageContentView _clampImageAlphaTo01:colorSpace:] no CIImage passed in
2023-07-25 10:39:29.280 qlmanage[3543:28404] IKImageView2 _updateContentForLayerUsingIOSurface Error: source rect and destination rect of tile being drawn are not the same
dreampiggy commented 1 year ago

Emmm...QuickLook API design (from Apple) does not support Animated Image. You see, it's received a CGContext (canvas, only draw one image), or CGImage (single frame)

We can only support to display animated AVIF into the static poster frame, is this enough for your use case ? @superbonaci

dreampiggy commented 1 year ago

For Preview (Space): image

For Icon Thumbnail (See in Finder): image

superbonaci commented 1 year ago

Emmm...QuickLook API design (from Apple) does not support Animated Image.

I can play perfectly animated gif inside Quick Look (select the gif then Space Bar), for example this file: https://giphy.com/gifs/tag-sample-BfbUe877N4xsUhpcPc

ezgif-3-db1fd31a43

If I click the "Open with Preview" button then it displays a static image, but that's not what I meant.

dreampiggy commented 1 year ago

You don't realize that GIF is Apple's internal QuickLook Plugin, which does not use the public API.

As a non-Apple company employee, I can not do the similiar thing, because the public API does not contains this ability.

qlmanage -m plugins

image

qlmanage -p example.avif

Check the verbose log, which point into this `/System/Library/QuickLook/Image.qlgenerator`
dreampiggy commented 1 year ago

If possible, I can try to dis-assemble that Apple's Image.qlgenerator and see how they render Animation on CGContext. Maybe using a Timer to refresh the canvas ?

Or find their private API, which may contains something like frame count, duration, etc

dreampiggy commented 1 year ago

Maybe the old generator based can not support animation. The new QLPreviewView (Which need a App, no longer a qlgenerator plugin) can custom draw anything on NSView

https://developer.apple.com/videos/play/wwdc2019/719?time=942 https://developer.apple.com/documentation/quicklookui/qlpreviewview https://developer.apple.com/documentation/quicklook/qlpreviewingcontroller?language=objc

Maybe this is the future way to support animation.

superbonaci commented 1 year ago

You don't realize that GIF is Apple's internal QuickLook Plugin, which does not use the public API.

You mean that GIF is AN internal QuickLook Plugin, not the only one. The video you quoted talks about thumbnails, just hope your app doesn't create such files. Viewing or previewing any file should not create any new file or "cache" in the filesystem.

I wonder if you can make this work as a "plugin" and not having to install a full .dmg program.

dreampiggy commented 1 year ago

Maybe it's just a AVIFQuickLook.app, you can place it into anywhere you like (Because Mac has a Spotlight service, will search all .app in your disk), like ~/Documents/Tools/AVIFQuickLook.app, you don't need to open it at all.

Then you can preview the AVIFs animation.