6

Im using DirectShowLib in C#. I want to use File Writer in C# to set a file output. I want to use File Writer because Graph.SetOutputFileName() wont connect to my encoder, but File Writer will. How can i set the File that File Writer saves to in C#?

I tried pulling up its property pages like in the DxPropPages example but one won't come up for File Writer.

Grant
  • 684
  • 1
  • 7
  • 26

1 Answers1

4

Pulled from here

IBaseFilter ibf = new FileWriter() as IBaseFilter;

Update:

"I know how to add file writer to my graph in code i just dont know how to set the file path"

try the following:

FileWriter fileWriter = new FileWriter();
IFileSinkFilter fileSinkFilter = (IFileSinkFilter)fileWriter;
fileSinkFilter.SetFileName(fileOutput, null);

Here a useful link that shows a full running example. the example is demonstrating the use of DES but you should get the general idea from it.

Jalal Said
  • 15,906
  • 7
  • 45
  • 68
  • how does that let me set up a file for FileWriter? I know how to add file writer to my graph in code i just dont know how to set the file path – Grant Jun 21 '11 at 16:33
  • @Grant: Sorry, I misunderstand your question. – Jalal Said Jun 21 '11 at 16:51
  • in graphedit, inserting the File Writer filter brings up a dialog box to select where you want to save a file. In code, no option like that exists that i know of :( – Grant Jun 21 '11 at 16:56
  • 1
    @Grant: try this "I hope it will help this time :)": `FileWriter fileWriter = new FileWriter(); IFileSinkFilter fileSinkFilter = (IFileSinkFilter)fileWriter; fileSinkFilter.SetFileName(fileOutput, null);` – Jalal Said Jun 21 '11 at 17:40
  • I think thats getting closer :) i did that and said .SetFileName("C:\name.txt",null)and also .SetFileName("C:\\name.txt", null) and it created an AccessViolationException when i tried to do MediaControl.Run() – Grant Jun 21 '11 at 17:51
  • i tried making a filesinkfilter, setting its filename then converting it to a filewriter and didnt work too well, or maybe i just did it wrong. – Grant Jun 21 '11 at 18:02
  • ^__________________________________^ works in the simple case, shall require more testing – Grant Jun 21 '11 at 18:15