[英]Is there another way to save a video in directshow
我正在使用DirectShow.Net,我正在從網絡攝像頭捕獲視頻並將其保存到AVI文件中。 AVI文件可能會變大,我想以不同的格式保存它。 我正在使用ICaptureGraphBuilder2 :: SetOutputFileName(MediaSubType.type,name,out,out)。 ICaptureGraphBuilder只允許我使用.AVI或.ASF的MediaSubType來保存文件。 如果我嘗試更改它嘗試保存的類型,它將崩潰:
graphBuilder = (IGraphBuilder) new FilterGraph();
//Create the Capture Graph Builder
ICaptureGraphBuilder2 captureGraphBuilder = null;
captureGraphBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();
//Create the media control for controlling the graph
mediaControl = (IMediaControl) this.graphBuilder;
// Attach the filter graph to the capture graph
int hr = captureGraphBuilder.SetFiltergraph(this.graphBuilder);
DsError.ThrowExceptionForHR(hr);
//Add the Video input device to the graph
hr = graphBuilder.AddFilter(theDevice, "source filter");
DsError.ThrowExceptionForHR(hr);
//Add the Video compressor filter to the graph
hr = graphBuilder.AddFilter(theCompressor, "compressor filter");
DsError.ThrowExceptionForHR(hr);
//Create the file writer part of the graph. SetOutputFileName does this for us, and returns the mux and sink
IBaseFilter mux;
IFileSinkFilter sink;
hr = captureGraphBuilder.SetOutputFileName(MediaSubType.MPEG1Video, textBox1.Text, out mux, out sink);
captureGraphBuilder.SetOutputFileName
DsError.ThrowExceptionForHR(hr);
//Render any preview pin of the device
hr = captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, theDevice, null, null);
DsError.ThrowExceptionForHR(hr);
有沒有辦法在沒有太多麻煩的情況下保存到AVI或ASF以外的任何東西?
問題很可能不是AVI容器格式,而是您用來壓縮視頻的編解碼器。
你需要添加一個不同的視頻壓縮過濾器(可能是MPEG4或AVC),無論你得到什么,它都可能提供你可以而且應該使用的MP4多路復用器,而不是你現在使用的avi mux。
您是否看過EmguCV( www.emgu.com ,這是一個開放cv的.net包裝器。它有許多類可能有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.