Marginal / QLVideo

This package allows macOS Finder to display thumbnails, static QuickLook previews, cover art and metadata for most types of video files.
GNU General Public License v2.0
2.5k stars 87 forks source link

Videos are displayed as a static snapshot in QuickLook previews. #3

Open Marginal opened 10 years ago

cytec commented 9 years ago

would absolutely fantastic if they could be played back like mp4 files do

Marginal commented 9 years ago

I think that the only way to achieve this with the current QuickLook API would be to dynamically transcode the content into a format that AVFoundation can understand - i.e. into some version of MPEG. This might be just about usable for content that is already encoded as an MPEG stream but within a different container (e.g. within a .flv, .mov or .mkv file). I imagine that it would be painfully slow and lossy for other kinds of content.

cytec commented 9 years ago

afaik VLCKit provides VLCMediaPlayer thought it would be possible somehow to initialize that in the QuickLook view?

Marginal commented 9 years ago

You can get a CGContext that VLCMediaPlayer could draw to ('though I didn't manage to get this working myself) by calling QLPreviewRequestCreateContext. But that context is intended for drawing a static bitmap, so I don't think that it can be dynamically updated.

If you could get hold of the Finder's QuickLook preview window/panel then maybe VLCMediaPlayer could draw into that. But I don't know of any way to get hold of the Finder's QuickLook preview window/panel. (There's QLPreviewView, but I think that's for embedding a quicklook preview in your own app).

magdesign commented 9 years ago

Thanks for your work! Maybe you can get videos previewed with a hack like this (not sure yet how to activate intermediate codec or all available codecs in /Library/QuickTime) http://www.quicklookplugins.com/2007/12/16/mkv-matroska-video-files/

Marginal commented 9 years ago

@magdesign No, that sort of approach doesn't work in Mavericks and later because QuickLook no longer uses the QuickTime framework. It uses the AVFoundation framework instead, but AVFoundation has no (published) API for additional formats or codecs.

jnai7 commented 9 years ago

Hello, you have 100% more experience with Quick Look than me :-) I have just got an idea for previewing non-native video formats. The minimal requirements is easy activation (Space), playing video and easy cancel (close playing a video with Space). That's what using QL for video is all about. Would it be possible to activate an existing application with QL hotkey (Space) passing a parameter of video file so that the program starts playing a video. When a focus changes, QL generator should send another file name to play. It's essentially abusing QL just to activate playing a video. Since you are using VLC to get metadata and thumbnail, how about running a part or full VLC inside QL preview window? I know it's dirty as hell, but since Maverick, no video QL is available for non H246 MP4. There are a lot of requests nobody is doing much, because Apple is hiding the APIs. What do you think?

Marginal commented 9 years ago

@jnai7 No; it's not possible to get notified when the default Movie generator starts playing an MPEG file into the QuickLook preview window, neither is it possible to substitute another file at that point. Nor is it possible to get VLC to draw to the Finder's QuickLook preview window for the reasons discussed above.

christopheranderton commented 9 years ago

Not a solution for this, but i saw someone (was in Japanese, and the URL is dead) using some kind of key action (using most likely a 3rd party solution) that passed the playback to a shell script (workaround style) invoking mplayer (in the example he used a Homebrew installed binary of mplayer). Have been trying myself, but no luck yet (making it seamless or usable).

Some former colleagues working at a Encoding company (they have extremely good communication with Apple), said that they maybe have a solution for this (the issue). I'll keep you posted.

Marginal commented 9 years ago

The ideal solution would be to do the same as whatever the default Movie generator is doing in order to play the video into the Finder's Preview window. But I've tried and failed to reverse engineer what the Movie generator is doing so unless your guys at Telestream or anyone else can provide some pointers this is currently a dead end.

I hadn't considered the approach of intercepting a keystroke and playing the video directly into a "fake" preview window. I guess the main challenge here is tracking the user's navigation in the Finder window in order to keep the contents of the "fake" preview window reflecting the user's selection - i.e. emulating QuickLook's behaviour. And if that turns out to be too difficult then I'm not sure we've achieved anything worthwhile - after all ⌘-↓ is a perfectly good existing keyboard shortcut for just playing a video file :-)

jeanlain commented 9 years ago

Hello. First off, thank you so much for writing this quick look generator. I'm not a developer (I only did a little cocoa programming as a hobby) so this comment may not be helpful or accurate. This is about 3rd-party components for the AVFoundation stack. It might be possible that the "camera import SDK" released with FCP X 10.0.1 allows writing such components. This is mostly speculation, as this SDK is apparently only available to camera manufacturers. An interesting piece of information came from the recent release of the Pro Video Formats 2.0 by Apple. The codecs themselves are provided at Quicktime components, which go in /Library/QuickTime/ and as VideoToolBox components, which go in /Library/Video/. This update also brought MXF (which is a container, not a codec) support in Final Cut. Curiously, playback is enabled by a Quicktime component only, so that QT player X still cannot play MXF files. QT player 7 now does, so does FCP classic (tested in FCP 6). (FCP X 10.1.4, even though it is based on AVFoundation, can use this component (!) to edit MXF file natively (if this component is removed, FCP X complains that a module is missing). Earlier version of FCP X probably won't support that, but I haven't checked). Anyway, there's probably a reason why Apple didn't simply add support for the mxf container right into AVFoundation, which would allow playing mxf files in QT player X and QuickLook. It suggests that the new video frameworks are not ready yet to support other containers (only codecs), or at least not mxf.

Marginal commented 9 years ago

Turns out that movie previews aren't produced by the QuickLook generator plugin /System/Library/QuickLook/Movie.qlgenerator. (Presumably this is because QuickLook generator plugins can't produce anything other than static text or images). Instead, movie previews are produced by /System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework/PlugIns/Movie.qldisplay or ./LegacyMovie.qldisplay. (The former uses AVKit, the latter QTKit).

The good news is that these are also plugins, so in theory it might be possible to produce a similar plugin for non-native video files. The bad news is that I can't see any evidence that OSX looks anywhere outside of /System for such plugins, and the plugin interface (QLDisplayBundle) is undocumented and non-trivial.

jeanlain commented 9 years ago

Interesting. I suppose that the LegacyMovie plugin isn't used in Mavericks(?). If so, is there a way to force Mavericks to use it? It won't be ideal since mkv and wmv never worked very well with quick look, but it may help. I suppose that an AVFoundation plugin would be better than a qldisplay plugin since it would work in every app using AVFoundations/AVKit as well. AFAIK, neither kind of plugin is documented.

Marginal commented 9 years ago

Interesting. I suppose that the LegacyMovie plugin isn't used in Mavericks(?). If so, is there a way to force Mavericks to use it?

It doesn't appear to be used, and I don't know how to force it.

Agree that an AVFoundation plugin would be preferable as more general solution. But a QLDisplayBundle plugin might possibly be easier to reverse engineer.

christopheranderton commented 9 years ago

Just a ”update”. Maybe it should be posted at some rumour forum than in this thread. You may remove this as this highly off topic, and with no named sources.

I talked yesterday with a friend at the company i mentioned earlier. They have now a somewhat working plugin for Quicklook with video playback for third party codecs (only installed within their own applications in someway, but that includes almost every codec made). But it's very unstable (causing Kernel Panics at it worsts), and is also not developed anymore in-house (and no, they don't want to open source it).

But he said that there is a strong possibility that the Finder will have their own extensions (think Photos.app that is built on adding features with extensions for both Apple in-house and 3rd party) in coming versions of Mac OS X (10.11 maybe?).

When i asked how so, he said they (Apple) is developing a somewhat rewritten (again!) Finder that will get some stuff from iOS (the return of the Simple Finder!), but will also please ”power users” with the just mentioned extensions. According to him, in the internal development version, they used a extension Boilerplate (no surprise of course) and added some of the Photos.app extensions to the Finder (Photos.app will be more integrated in the Finder), but also 1 (internal test) extension showing of some kind of file comparison capabilities you see in the app Kaleidoscope (and other diff apps), and 1 extension for viewing common medical image formats.

That would make it possible for extensions for different 3rd party media codecs (because it's targeted to 3rd party developers. Of course there will be some shortcomings with restrictions and more sandbox features.)

That may sound like just some wishful thinking, but the guy that i worked with, has worked at Apple (Quicktime and Final Cut Pro as i remember), while it was a pretty long time ago, he still have friends inside, but also have some access for testing new things (within the company he works for), which is pretty unusual for Apple. He don't comment on future stuff most of the time, but when he has, everything turned out true (except some minor details that Apple may have changed). I don't out him with this post (taken care of that) if you wonder.

Even if it's 100% true, Apple can change it at anytime (when i met the Quicktime Core Developers at a talk in Sweden 1 month before the release of QuickTime 4.0 back in 1999, they dismissed MP3 support as ”that's just crap pirates using, so there is no way we are adding that”. But as it turned, Steve Jobs himself demanded MP3 support. So they added support only a week before the release).

qbektrix commented 8 years ago

@christopheranderton Any update? I am on 10.11.3 & when I tried to play webm, all I get is a static image. While webp & gifv shows gibberish & html respectively.

christopheranderton commented 8 years ago

@qbektrix I'm sorry, but i think you need to address that to the developers of the media player you are using. This repo is for a Quick Look-plugin by @Marginal and it will not playback unsupported media files. From the README:

This package allows OSX Finder to display thumbnails, static previews, cover art 
and metadata for most types of video files
QuickLook and Spotlight on OSX 10.9 and later understand a limited number 
of media files - mostly only MPEG audio and video codecs within MPEG container files. 
This package adds support for wide range of other codecs and "non-native" media file types, 
including .asf, .avi, .flv, .mkv, .rm, .webm, .wmf etc.

About my earlier post, as you may know, OS X 10.11.x didn't contain any of the features mentioned. It may come in the feature, or not (giving Apple's track record, i wouldn't count on it).

Marginal commented 8 years ago

While webp & gifv shows gibberish & html respectively.

webp is a static image format. There's a QuickLook plugin for it here.

gifv "files" are actually either mp4 or webm. Sounds like you downloaded some HTML wrapper rather than the video content.

Michelasso commented 8 years ago

First of all thanks for your work. Then I didn't understand well: is mkv supported? I mean, I do get the thumbnails, but that's it. And I have VLC installed if it matters.

cytec commented 8 years ago

@Michelasso mkv playback ist NOT supported... you will however get a static thumbnail for mkv files

Michelasso commented 8 years ago

@cytec all right, thanks. I wanted to be sure there wasn't something wrong with my installation. :)

digital-pers0n commented 8 years ago

/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework/PlugIns/Movie.qldisplay or ./LegacyMovie.qldisplay. (The former uses AVKit, the latter QTKit).

If you rename LegacyMovie.qldisplay to Movie.qldisplay it will work with non-native video containers as on pre-10.9 OS X

The good news is that these are also plugins, so in theory it might be possible to produce a similar plugin for non-native video files.

I think this is impossible, because all *.qldisplay IDs are hardcoded into QuickLook.framework

The bad news is that I can't see any evidence that OS X looks anywhere outside of /System for such plugins, and the plugin interface (QLDisplayBundle) is undocumented and non-trivial.

Maybe there is a way to choose display bundle programmatically but I don't know how to do this.

Marginal commented 8 years ago

If you rename LegacyMovie.qldisplay to Movie.qldisplay it will work with non-native video containers as on pre-10.9 OS X

LegacyMovie.qldisplay does OK on some codec/container combinations if you have Perian installed, but it's painfully slow on some of my .mkv test files. Weirdly it can't handle some combinations e.g. DV, or H.264 in .mts, that Movie.qldisplay handles fine.

I've created a new branch LegacyMovie which defers to LegacyMovie if LegacyMovie can preview the content, and provides static previews otherwise.

For this to work you have to:

Let me know how it works for you if you try this.

milobmx commented 8 years ago

Marginal,

Need some clarification (I'm not well versed in coding/computer terms). When you say "Symlink LegacyMovie.qldisplay as Movie.qldisplay" followed by the terminal commands, do you simply copy and paste that text into terminal? Thanks in advance.

milobmx commented 8 years ago

Marginal,

Clarification no longer needed. I just copied and pasted into terminal and it worked like a charm! I even tried it in 10.11 (El Capitan) and it worked! All I had to do was disable System Integrity Protection, add the command to terminal, and re-enable System Integrity Protection. Thanks for this!

gitguys commented 7 years ago

LegacyMovie.qldisplay does OK

Marginal, if I'm to understand correctly is there now a workaround that makes QLVideo work (as in play video) with more video formats than before? For example, QLVideo doesn't currently play .flv video formats and shows still images. If I perform the SymLink directions above, will .flv videos play in QuickLook now?

Also, in your instructions you say to move "Movie.qldisplay out the way". Can I just rename it with an underscore in front of it so I can easily change it back later if needed? Also, is changing this stuff risky to the system stability?

The other thing I'm trying to understand - Do I have to use the new branch LegacyMovie you link to for any of this to work? I don't see a package download for it, so I'm confused as to how I should implement it with your instructions above.

Thank you!

Marginal commented 7 years ago

The instructions above allow .flv and other "non-native" video types to play in QuickLook on 10.9 and 10.10, and on 10.11 and later if you first disable SIP.

in your instructions you say to move "Movie.qldisplay out the way". Can I just rename it with an underscore in front of it so I can easily change it back later if needed?

Yes.

Do I have to use the new branch LegacyMovie you link to for any of this to work?

That branch has been folded into the master branch. Just make sure you're on the latest release of QLVideo. Actually QLVideo isn't required at all to get .flv videos to play in QuickLook, but it's still useful to have for videos that the LegacyMovie QuickLook plugin can't handle.

gitguys commented 7 years ago

Thank you, Marginal. It works great.

christopheranderton commented 7 years ago

Cheers Marginal, works as advertised. Haven't installed Sierra yet, but i assume it works the same way as in 10.11?

gitguys commented 7 years ago

christopheranderton, I can confirm the symlink trick still works in Sierra. I had it working in Mavericks, then upgraded to Sierra and during the upgrade process the files were overwritten with new ones and it stopped working in Sierra, of course.

I disabled SIP in Sierra, followed the same steps from the May 5 post above (except I already had Perian installed so that was skipped), then I reenabled SIP in Sierra afterwards. I should note there's a current bug in Sierra 10.12.0 where the Recovery System doesn't show the proper menu bar to get to the Terminal app. I followed some advice here and kept trying until I got the menu bar back and then was able to open Terminal and enable SIP back on again.

Now I'm able to use QuickLook within Sierra on all kinds of formats including .webm, .flv videos that play video within the QuickLook window once again.

screen shot 2016-10-11 at 6 10 54 am

Marginal, it does play mp3. It didn't play a .flac file I tested, but I don't think I ever had that working with QuickLook even back with Mavericks and earlier. I couldn’t find any readily available APE audio files to test.

screen shot 2016-10-11 at 5 57 35 am

Marginal, thank you so much for all your hard work. I now have all the benefits of Sierra without the drawback of losing QuickLook video on many formats.

gitguys commented 7 years ago

Dammit. 10.12.1 broke it again. I'll see if the same steps works again later to fix it and post update.

gitguys commented 7 years ago

I have bad news and I'm very bummed. 10.12.1 broke it in some new way I can't resolve.

In the past when I upgraded to 10.12.0, it disabled QLVideo and I was able to simply disable SIP and reimplement the same steps I outlined in my post above.

Now with 10.12.1 I noticed that the symlink was still in place, but QLVideo just stopped working anyway. I removed the symlink after disabling SIP again and tried the terminal command:

sudo ln -s LegacyMovie.qldisplay /System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework/PlugIns/Movie.qldisplay

No dice, still didn't work. So I tried reinstalling the QLVideo package again, removed the symlink again, redid the terminal command again, restarted, etc. and still doesn't work.

Marginal, do you have any ideas for workarounds to get it working again in 10.12.1?

christopheranderton commented 7 years ago

@gitguys @Marginal It still works in 10.12.1. Tested in a Virtual Machine with a vanilla install of 10.12.1. Installed Perian, QLVideo and followed the instructions from this thread. No problem at all. Created a ”test” with videos encoded in various ways. Only ”problems” was with some MKV (not all) and WebM files (only showed a two frames still image preview). Ah, also, a VC-1 file did not work. But that's to be expected.

You may need to reinstall Perian with SIP disabled. That's what i would try (if you not already have tried that).

screen shot 2016-11-05 at 14 30 59 screen shot 2016-11-05 at 14 33 03

screen shot 2016-11-05 at 14 33 46 screen shot 2016-11-05 at 14 31 06 screen shot 2016-11-05 at 14 31 14

gitguys commented 7 years ago

@christopheranderton thank you for your testing!

Were you able to get flash video .flv or AVI to work? That used to work in 10.12.0 and stopped with 10.12.1 and I don't see any examples of those formats working in your post.

I think the difference may be that you started with a vanilla 10.12.1 install instead of perhaps updating a previous setup from 10.12.0 to 10.12.1 like I did.

Either way, your tests got me thinking and I was able to not only get QLVideo working again, but it also works with .flv and .avi formats again now as well.

I copied the old LegacyMovie.qldisplay folder from my 10.12.0 version and replaced it over to my 10.12.1 upgrade LegacyMovie.qldisplay folder that I had installed on my secondary hard drive. I then did the symlink Terminal command shown by Marginal above and it's all working again in 10.12.1. Such a relief.

Beforehand, I tried reinstalling QLVideo, etc. and I even tried reinstalling Perian and reimplementing the symlink steps, etc. to no avail. It wasn't until I copied over the old LegacyMovie.qldisplay folder did it finally fix the issue.

Hopefully this will help out anyone else who updates from 10.12.0 to 10.12.1. If anyone has any questions, I be happy to assist with more details.

christopheranderton commented 7 years ago

@gitguys Ah, forgot the AVI. But .flv using codecs like VP8 or H.264 worked without problems. I still waiting to upgrade to Sierra from El Capitain on my main working machine. Still waiting for updates or solutions for some essential software i'm working with. But when i do, i will see if my experiences are the same. If so, i'm gonna try to find out why.

gordio commented 7 years ago

@gitguys try reinstall Perian

gitguys commented 7 years ago

Thank you, gordon for your help. Not certain if you saw my last post, but I did get it working in Sierra 10.12.1.

The only issue that really still bothers me is QuickTime Player Pro 7 AV controls don't work properly (brightness/contrast/etc.) if I change the video properties (turn video upside-down, etc.) -- but that's not related to QLVideo at all I doubt.

gitguys commented 7 years ago

FYI - Followed my steps fro 10.12.1 and now working again in 10.12.2

gitguys commented 7 years ago

Got it working again in 10.12.3.

  1. Disabled SIP

  2. Used my old copy of LegacyMovie.qldisplay that I've kept from 10.12.0 to copy over folder of same name at this path:

/System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework/PlugIns/

I guess the 10.12.2 LegacyMovie.qldisplay folder would work too, but I'm just sticking with what I know works from before.

  1. Ran terminal command:

sudo ln -s LegacyMovie.qldisplay /System/Library/Frameworks/Quartz.framework/Frameworks/QuickLookUI.framework/PlugIns/Movie.qldisplay

  1. Works again.

5) Re-enabled SIP

krokofant commented 6 years ago

It stopped working for me. Webms won't play anymore. :(

Tried reinstalling QLVideo and Perian and re-linking the LegacyMovie -> Movie without success.

I'm on 10.12.5 and updated a short while ago.

iiiGerardoiii commented 6 years ago

@krokofant but QLVideo has never made webms playable on QuickLook afaik, it has always shown only thumbnails of them.

Am I missing something here?

krokofant commented 6 years ago

@iiiGerardoiii It says webm right in the README.

This package adds support for wide range of other codecs and "non-native" media file types, including .asf, .avi, .flv, .mkv, .rm, .webm, .wmf etc.

gitguys commented 6 years ago

@krokofant it's working for me with webm and all those other formats in 10.12.6. After updating to 10.12.6 from 10.12.3, I followed the same steps I list above in my Feb 25th post. Do you also have Perian 1.3.2 installed? Pretty sure that has to be that version installed too.

krokofant commented 6 years ago

@gitguys Yes, Perian 1.3.2 is installed and has been re-installed.

I've followed those steps 😕 My LegacyMovie also seems to be my old one.

krokofant commented 6 years ago

It seems that without Perian I get the static (full-width) preview but with Perian I get the following: image

So Perian does something but the webm won't play.

christopheranderton commented 6 years ago

@krokofant Have you tried som other .webm clips? I remember that some webm files i tested worked, while some did not. I don't know, but maybe it's a issue with Perian being really old, so it cannot handle some (or all) clips using .webm files with VP9 codecs (used in the .webm container).

krokofant commented 6 years ago

@christopheranderton I've tested against saved webms that was playable before.

gitguys commented 6 years ago

@krokofant I just grabbed webm video file from here: http://www.webmfiles.org/demo-files/

It's playing fine with QuickLook, although I did just notice it has an "Open in Chromium" option top-right I never noticed before. And when I do "Get Info" it shows "Open with" Chromium and will play the video preview there in the "Get Info" window. Not sure if that's relevant or not.

screen shot 2017-08-11 at 9 19 32 am

screen shot 2017-08-11 at 9 31 01 am

The only other thing I can think of is maybe you need QuickTime 7 installed? I've also found if I have glitches with QuickLook a restart will sometimes fix it. Please let us know if you get it working or not, I may have some other ideas for you.

gitguys commented 6 years ago

@krokofant you ever get your issue with webm resolved?

krokofant commented 6 years ago

@gitguys Sorry for my delayed answer. I've not found any solution. I've installed updates, reinstalled whatever I could think of incl. iTunes (🤢).

I tested with several previous working webms including a big buck bunny one.