Closed jaideep602 closed 5 years ago
Yes, I wanted to complete this project adding the possibility to record videos.
Thank you for your reply. I was able to implement video recording feature for my own project and I'm sharing my code with you. I hope it will help. I have modified your prepare function in dshow_graph.py as (Repeated definition GUIDs are for clarity purposes):
def prepare(self):
assert self.capture_filter is not None
assert self.render_filter is not None
GUID_MEDIASUBTYPE_Avi = GUID('{e436eb88-524f-11ce-9f53-0020af0ba770}')
MEDIATYPE_Video = GUID('{73646976-0000-0010-8000-00AA00389B71}')
PIN_CATEGORY_PREVIEW = GUID('{fb6c4282-0353-11d1-905f-0000c0cc16ba}')
PIN_CATEGORY_CAPTURE = GUID('{fb6c4281-0353-11d1-905f-0000c0cc16ba}')
self.capture_builder = client.CreateObject(DirectShowLib.CaptureGraphBuilder2)
self.capture_builder.SetFiltergraph(self.filter_graph)
self.AVI_Mux, self.AVI_File_Sink = self.capture_builder.SetOutputFileName(GUID_MEDIASUBTYPE_Avi, "FILEPATH")
if self.sample_grabber is None:
self.capture_builder.RenderStream(PIN_CATEGORY_PREVIEW,
MEDIATYPE_Video,
self.capture_filter, None, self.render_filter)
self.capture_builder.RenderStream(PIN_CATEGORY_CAPTURE,
MEDIATYPE_Video,
self.capture_filter, None, self.AVI_Mux)
else:
self.capture_builder.RenderStream(PIN_CATEGORY_PREVIEW,
MEDIATYPE_Video,
self.capture_filter, self.sample_grabber, self.render_filter)
self.capture_builder.RenderStream(PIN_CATEGORY_CAPTURE,
MEDIATYPE_Video,
self.capture_filter, None, self.AVI_Mux)
self.sample_grabber_cb.image_resolution = self.get_sample_grabber_resolution()
self.media_control = self.filter_graph.QueryInterface(quartz.IMediaControl)
self.media_event = self.filter_graph.QueryInterface(quartz.IMediaEvent)
Thanks very much for sharing your code! I'll update this project when I find some time...
Video recording implelented, see commit 4014e64f98b543768b06abfe2a211bf871b489ff (https://github.com/andreaschiavinato/python_grabber/commit/4014e64f98b543768b06abfe2a211bf871b489ff)
Are you planning to complete ICaptureGraphBuilder2 interface for video recording purposes?