Detect Directshow filters on Windows

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Detect Directshow filters on Windows

Post by Cairoo » Tue Nov 01, 2022 9:48 am

Dear forum,

I would like to know how to make my Windows app to reliably detect if there is a 64-bit Directshow filter installed that can play the video I know to be encoded with a specific codec.

This post -> https://forums.livecode.com/viewtopic.p ... AV#p218603
gave a link to where the LAV filters for Windows can be downloaded.

I need the app to reliably detect if the necessary filters are installed or not before trying to play the video, so if it's not installed, the app can try to install it, or at least prompt the user to download and install the LAV filters. Can anyone share some advice?

Thank you, Gerrie

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Detect Directshow filters on Windows

Post by paul@researchware.com » Wed Nov 02, 2022 1:27 pm

Here is a function to tell whether LAV Filters are installed:

function lavFiltersInstalled
-- only applies to Windows and LC9+ (with DirectShow)
-- returns true if installed, false if not
-- two tests are available (1) file location (could be different) and (2) registry entry (should always be accurate)
-- 1) default installed file path (user may have overridden) C:\Program Files (x86)\LAV Filters
-- put (there is a folder "C:/Program Files (x86)/LAV Filters") into tInstalled
-- 2) Windows Registry path: Computer\HKEY_CURRENT_USER\Software\LAV which contains the subkeys Audio, Splitter, Video
-- put (listRegistry("HKEY_CURRENT_USER\Software\LAV\") is not empty) into tInstalled

local tTest1 = false
local tTest2 = false
local tInstalled = false
--
-- specialFolderPath(38) typically returns "C:/Program Files (x86)"
put specialFolderPath(38)&"/LAV Filters" into tTestPath
--
if platform() is "Win32" then
put (there is a folder tTestPath) into tTest1
put (listRegistry("HKEY_CURRENT_USER\Software\LAV\") is not empty) into tTest2
put tTest1 OR tTest2 into tInstalled
end if
return tInstalled
end lavFiltersInstalled

It checks BOTH the default installation path and for the presence of the main LAV Filters Registry key in case the software was installed at a different location. If either OR (in most cases) both are true, the function returns true.

This can tell you if LA Filters are installed.

As for the specific codecs, that is more complicated. We just looked up what file extensions (types) DirectShow supports (available on the Microsoft Developer's web site) and what file types LAV Filters supports. Then, because we're macOS too, we looked up on the Apple Developer site what file types AVF supports and make a list of the file extensios suported on both platforms.

We then just limited our answer file (see answer file[s] prompt [with defaultPath] [with type types [or type types ...]] [titled windowTitle] [as sheet]) to the types that are common, so a user can't select a video that is not actually openable.

I'll try again later today to find the spreadsheet of the types supported that we made and post it.
Paul Dupuis
Researchware, Inc.

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Detect Directshow filters on Windows

Post by paul@researchware.com » Wed Nov 02, 2022 1:42 pm

Ok, I found it. Attached is a ZIP with an Exce spreadsheet (from 2019) of media formats supported by various media frameworks. There are nots about our applications (HR=HyperRESEARCH and HT=HyperTRANSCRIBE) that you can ignore. I am not sure if it will be any help. The short answer is that for macOS (AVF) and Windows (DirectShow + LAV Filters) the list of common files we came up with was:

"AUDIO|3gp,aac,au,mp3,mp2,mpg,mpeg,m3u,mov,qt,avi,aif,aiff,wav,smi,smil,m4a,mp4"
"VIDEO|aac,adts,aif,aifc,aiff,amr,au,caf,m4a,m4b,m4p,m4r,mov,mp2,mp3,mp4,qt,wav,3g2,3gp,3gp2,3gpp,dv,m4v,mov,mpeg,mpg,qt"

This was for use in the answer file ... with type ... command. Hope that all may help. Media support is not easy in LiveCode (currently).
Attachments
MEDIA FORMATS 2019-03-20xlsx.zip
ZIP with Excel sheet of media formats
(24.39 KiB) Downloaded 107 times
Paul Dupuis
Researchware, Inc.

Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Re: Detect Directshow filters on Windows

Post by Cairoo » Wed Nov 02, 2022 4:19 pm

Thank you so much Paul, I appreciate the help. I suspected I would have to probe the registry but I was not sure where. The suggested code indeed detects if the LAV filters have been installed with the installer.
However, when the LAV video filter is manually installed by registering the LAVVideo.ax file with regsvr32, the LAV registry key is not created, but still DirectShow knows about the filter. I thought I might have to do whatever DirectShow does to find the right filter because it somehow knows what filter to use and the "HKEY_CURRENT_USER\Software\LAV\" registry key isn't even there in that case.

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Detect Directshow filters on Windows

Post by paul@researchware.com » Wed Nov 02, 2022 4:31 pm

I am not sure what to do in the case of detecting manual installation.

I do seem to recall that once LAV Filters is installed there is some sort of command line way ot getting the codecs that are installed(?) (not sure I am 100% remembering correctly - this was development we explored nearly 3 years ago). If correct, this suggests possible using the shell() function in Livecode to get detail from the installed version of the filters on what formats are supported.
Paul Dupuis
Researchware, Inc.

Cairoo
Posts: 107
Joined: Wed Dec 05, 2012 5:54 pm

Re: Detect Directshow filters on Windows

Post by Cairoo » Thu Nov 03, 2022 8:50 pm

I've done some more searching and discovered that the DirectShow filters are listed in the registry under the following key:
HKEY_CLASSES_ROOT\CLSID\{083863F1-70DE-11d0-BD40-00A0C911CE86}\Instance
each with a binary value named "FilterData" that contains the information used by DirectShow to match a filter with the media type or subtype.

I've also discovered this github resource that lists the GUIDs for all known media types: https://gix.github.io/media-types/

The only way that I can see how to read the FilterData in the registry is with the DirectShow API, and so one would have to write an LCB library that binds to the DirectShow API through the FFI.

*Sigh*... I was hoping for an easier way.

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Detect Directshow filters on Windows

Post by paul@researchware.com » Thu Nov 03, 2022 10:03 pm

I realize you have an immediate need, but given that Livecode 10 will switch from DirectShow to Microsoft Media Framework (MMF), you may want to log an enhancement request in the Livecode Qaulity Center (https://quality.livecode.com/) to add (if they exists) an API for returning the formats suported by MMF (and Apple. Anroid, etc.). I think returning file extensions for media types (if possible) would be most beneficial as they can be plugged right into an asnwer file command.
Paul Dupuis
Researchware, Inc.

Post Reply

Return to “Multimedia”