Directshow in Python

Sayanan Sivaraman sayananbig at
Fri Sep 19 00:11:39 CEST 2008

Hey all,

I'm trying to use DirectShow to display videos [I'm kind of new to
Python, from more of a C++ background on windows].  I found some
sample code online, but I am having trouble with calling the I

import ctypes
from ctypes import *
from comtypes import client
from ctypes.wintypes import *
import sys
import time

filename = sys.argv[1]

qedit = client.GetModule('qedit.dll') # DexterLib
quartz= client.GetModule("quartz.dll")

CLSID_FilterGraph = '{e436ebb3-524f-11ce-9f53-0020af0ba770}'
filter_graph =
filter_builder = filter_graph.QueryInterface(qedit.IGraphBuilder)
filter_builder.RenderFile(filename, None)

media_control = filter_graph.QueryInterface(quartz.IMediaControl)

    # Look at IMediaEvent interface for EOS notification
    while True:
except KeyboardInterrupt:

# Need these because finalisers don't have enough context to clean up
# themselves when script exits.
del media_control
del filter_builder
del filter_graph

This code works fine.  What I would like to know, is how do I declare
filename in the Python program to be of type LPCWSTR, so that I don't
need to parse the command line in order to call the function


More information about the Python-list mailing list