Last updated: 2026年1月
DirectShow.NET の代替:VisioForge .Net SDK への移行ガイド
DirectShow.NET(開発終了)から VisioForge .NET SDK への移行ステップバイステップガイド。.NET 6-10 でのビデオキャプチャ、再生、処理に対応。
DirectShow.NET(directshowlib)からモダンな .NET 6-10 ビデオキャプチャ、再生、処理 SDK へ移行する C# 開発者向け
なぜ DirectShow.NET を置き換えるべきか?
DirectShow.NET は2010年2月以降放棄されています — 15年以上アップデートなし。Microsoft の DirectShow API の生の COM インターフェース定義を提供していますが、Microsoft 自体が Media Foundation を推奨して DirectShow を非推奨にしています。
| リスク | 影響 |
|---|---|
| Microsoft が DirectShow を非推奨化 | 新機能、コーデック、プラットフォームサポートなし |
| ライブラリがメンテナンスされていない | .NET Framework 2.0、.NET 6+ サポートなし |
| COM の複雑さ | 基本的なタスクに数百行、手動メモリ管理 |
| コーデック探し | サードパーティの DirectShow フィルターを探し、インストール、登録する必要あり |
| フィルターグラフのデバッグ | 不透明なパイプライン障害、診断ツールなし |
| Windows のみ | COM/DirectShow は macOS、Linux、モバイルでは実行不可 |
| モダンなコーデックなし | サードパーティフィルターなしではネイティブ H.265、AV1、VP9 なし |
| レジストリの問題 | モダン Windows でのフィルター登録の問題 |
どの VisioForge SDK が何を置き換えるか?
DirectShow.NET の使用法から VisioForge への置き換え
| DirectShow.NET の使用法 | VisioForge の置き換え |
|---|---|
| フィルターグラフによる C# ウェブカメラキャプチャ | Video Capture SDK .Net — `VideoCaptureCoreX` |
| C# IP カメラキャプチャ(RTSP/MJPEG) | Video Capture SDK .Net — `RTSPSourceSettings` |
| C# 画面キャプチャと録画 | Video Capture SDK .Net — `ScreenCaptureSourceSettings` |
| `IGraphBuilder` によるファイル再生 | Media Player SDK .Net — `MediaPlayerCoreX` |
| `IDvdControl2` による DVD 再生 | Media Player SDK .Net — DVD ナビゲーション API |
| `IAMTVTuner` による TV チューナー | Video Capture SDK .Net — `VideoCaptureCore` |
| ファイルトランスコーディング | Video Edit SDK .Net — `VideoEditCoreX` |
| カスタムフィルターグラフ | Media Blocks SDK .Net — モジュラーパイプライン(400+ ブロック) |
| `ISampleGrabber` フレームアクセス | 任意の SDK の `OnVideoFrameBuffer` イベント |
C# DirectShow インターフェースマッピング
C# DirectShow インターフェースマッピング
| DirectShow.NET インターフェース | VisioForge 同等機能 |
|---|---|
| `IGraphBuilder` | SDK がパイプラインを自動構築 |
| `ICaptureGraphBuilder2` | `VideoCaptureCoreX` コンストラクター |
| `IMediaControl` (Run/Stop/Pause) | `StartAsync()` / `StopAsync()` / `PauseAsync()` |
| `IMediaEvent` | SDK イベント(`OnError`、`OnStop` など) |
| `IVideoWindow` | `VideoView` コントロール(WinForms/WPF/MAUI/Avalonia) |
| `ISampleGrabber` | `OnVideoFrameBuffer` イベント |
| `IBaseFilter` | 不要 — SDK がフィルターを内部で管理 |
| `IPin` / ピン接続 | 不要 — SDK がパイプラインを自動接続 |
| `DsDevice.GetDevicesOfCat()` | `DeviceEnumerator.Shared.VideoSourcesAsync()` |
| `FilterCategory.VideoInputDevice` | `DeviceEnumerator.Shared.VideoSourcesAsync()` |
| `FilterCategory.AudioInputDevice` | `DeviceEnumerator.Shared.AudioSourcesAsync()` |
| `IAMTVTuner` | `VideoCaptureCore.TVTuner` プロパティ |
| `IDvdControl2` | `MediaPlayerCore.DVD_*` メソッド |
| `Marshal.ReleaseComObject()` | `await sdk.DisposeAsync()` |
C# ウェブカメラキャプチャとプレビュー
DirectShow.NET — ウェブカメラキャプチャ(移行前)
C#// 80+ lines of COM interop
var graphBuilder = (IGraphBuilder)new FilterGraph();
var captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
int hr = captureGraph.SetFiltergraph(graphBuilder);
DsError.ThrowExceptionForHR(hr);
// Find video device
var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
IBaseFilter sourceFilter;
hr = graphBuilder.AddSourceFilterForMoniker(
devices[0].Mon, null, devices[0].Name, out sourceFilter);
DsError.ThrowExceptionForHR(hr);
// Render preview
hr = captureGraph.RenderStream(
PinCategory.Preview, MediaType.Video, sourceFilter, null, null);
DsError.ThrowExceptionForHR(hr);
// Set video window
var videoWindow = (IVideoWindow)graphBuilder;
videoWindow.put_Owner(panelHandle);
videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipSiblings);
videoWindow.SetWindowPosition(0, 0, panel.Width, panel.Height);
// Start
var mediaControl = (IMediaControl)graphBuilder;
hr = mediaControl.Run();
DsError.ThrowExceptionForHR(hr);
// Cleanup (must release EVERY COM object)
Marshal.ReleaseComObject(sourceFilter);
Marshal.ReleaseComObject(captureGraph);
Marshal.ReleaseComObject(graphBuilder);VisioForge — C# ウェブカメラキャプチャ(移行後)
C#var capture = new VideoCaptureCoreX(videoView);
var devices = await DeviceEnumerator.Shared.VideoSourcesAsync();
capture.Video_Source = new VideoCaptureDeviceSourceSettings(devices[0]);
await capture.StartAsync();
// Cleanup
await capture.StopAsync();
await capture.DisposeAsync();C# ウェブカメラ録画(MP4)
DirectShow.NET — ウェブカメラから MP4(移行前)
C#// Must find H.264 encoder filter, MP4 mux filter, file writer
// Each requires separate COM object management
var graphBuilder = (IGraphBuilder)new FilterGraph();
var captureGraph = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
captureGraph.SetFiltergraph(graphBuilder);
// Add source
var devices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
IBaseFilter sourceFilter;
graphBuilder.AddSourceFilterForMoniker(
devices[0].Mon, null, devices[0].Name, out sourceFilter);
// Find and add H.264 encoder (must be installed on system!)
// This varies by system — no guarantee the filter exists
Guid h264Clsid = new Guid("some-encoder-guid");
IBaseFilter encoder = (IBaseFilter)Activator.CreateInstance(
Type.GetTypeFromCLSID(h264Clsid));
graphBuilder.AddFilter(encoder, "H.264 Encoder");
// Find and add MP4 mux
// Find and add file writer
// Connect source → encoder → mux → writer pins manually
// Each pin connection can fail silently or throw cryptic COM errors
// Configure encoder properties via ICodecAPI or IPropertyBag
// Different for every encoder filter...
var mediaControl = (IMediaControl)graphBuilder;
mediaControl.Run();
// Cleanup: release 5+ COM objectsVisioForge — C# ウェブカメラ録画 MP4(移行後)
C#var capture = new VideoCaptureCoreX(videoView);
var devices = await DeviceEnumerator.Shared.VideoSourcesAsync();
capture.Video_Source = new VideoCaptureDeviceSourceSettings(devices[0]);
capture.Outputs_Add(new MP4Output("recording.mp4"), true);
await capture.StartAsync();C# ビデオファイル再生
DirectShow.NET — ビデオ再生(移行前)
C#var graphBuilder = (IGraphBuilder)new FilterGraph();
int hr = graphBuilder.RenderFile("video.mp4", null);
DsError.ThrowExceptionForHR(hr);
var videoWindow = (IVideoWindow)graphBuilder;
videoWindow.put_Owner(panelHandle);
videoWindow.put_WindowStyle(WindowStyle.Child);
videoWindow.SetWindowPosition(0, 0, panel.Width, panel.Height);
var mediaControl = (IMediaControl)graphBuilder;
mediaControl.Run();
// Seeking
var mediaSeeking = (IMediaSeeking)graphBuilder;
long position = 50000000; // 5 seconds in 100ns units
mediaSeeking.SetPositions(
ref position, AMSeekingSeekingFlags.AbsolutePositioning,
null, AMSeekingSeekingFlags.NoPositioning);VisioForge — C# ビデオプレーヤー(移行後)
C#var player = new MediaPlayerCoreX(videoView);
await player.OpenAsync(new Uri("video.mp4"));
await player.PlayAsync();
// Seeking
await player.SeekAsync(TimeSpan.FromSeconds(5));C# ビデオフレームキャプチャ
DirectShow.NET — ISampleGrabber フレームキャプチャ(移行前)
C#// Must insert ISampleGrabber into filter graph
var sampleGrabber = (ISampleGrabber)new SampleGrabber();
var mediaType = new AMMediaType();
mediaType.majorType = MediaType.Video;
mediaType.subType = MediaSubType.RGB24;
sampleGrabber.SetMediaType(mediaType);
graphBuilder.AddFilter((IBaseFilter)sampleGrabber, "Grabber");
// Connect pins...
sampleGrabber.SetBufferSamples(true);
// In callback: manually read buffer, create Bitmap from raw bytes
sampleGrabber.GetCurrentBuffer(ref bufferSize, buffer);
// Manual pixel format conversion, stride calculation, etc.VisioForge — C# ビデオフレームキャプチャ(移行後)
C#capture.OnVideoFrameBuffer += (s, e) =>
{
// Frame data available as managed buffer
// Or convert to SKBitmap/Bitmap directly
var bitmap = e.Frame.ToBitmap();
ProcessFrame(bitmap);
};移行チェックリスト
- DirectShow.NET の使用状況を監査 — すべての `using DirectShowLib` 参照を見つける
- フィルターグラフの目的を特定 — キャプチャ、再生、トランスコーディング、またはカスタム処理
- VisioForge SDK を選択 — Video Capture、Media Player、Video Edit、または Media Blocks
- NuGet パッケージをインストール — DirectShowLib NuGet を VisioForge パッケージに置き換え
- フィルターグラフコードを置き換え
- COM クリーンアップコードを削除 — VisioForge は `IAsyncDisposable` を使用
- サードパーティ DirectShow フィルター依存関係を削除 — VisioForge にはコーデックが含まれる
- モダン .NET をターゲット — .NET 6-10
- クロスプラットフォームテスト
- DirectShow フィルター登録を削除 — 不要に
移行後に得られるもの
| 項目 | DirectShow.NET | 移行後 |
|---|---|---|
| コード行数 | 機能あたり100行以上 | 機能あたり5-10行 |
| フレームワーク | .NET Framework 2.0 | .NET 6-10 |
| プラットフォーム | Windows のみ | Windows、macOS、Linux、iOS、Android |
| API スタイル | 生の COM、手動ピン接続 | 型付き async C# API |
| コーデック | DirectShow フィルターを探してインストール | 内蔵(H.264、H.265、AV1、VP9) |
| メモリ管理 | 手動 `Marshal.ReleaseComObject` | `IAsyncDisposable` |
| デバッグ | 不透明な COM エラー(HRESULT) | 型付き例外、イベント |
| ビデオエフェクト | エフェクトフィルターを探す必要あり | 40+ 内蔵(GPU + CPU) |
| オーディオエフェクト | なし | 40+(EQ、リバーブ、コーラス、3D) |
| ストリーミング | 利用不可 | RTMP、HLS、SRT、NDI |
| 検出 | 利用不可 | 動体(MOG2)、顔(Haar/DNN/DLib)、歩行者(HOG+SVM)、バーコード |
| ハードウェアエンコーディング | エンコーダーフィルターを探す必要あり | NVENC、QSV、AMF、VideoToolbox |
| IP カメラ | 手動フィルターグラフ | RTSP、RTMP、HLS、ONVIF(自動再接続付き) |
| メンテナンス | 放棄(2010年) | 活発な開発 |
Frequently Asked Questions
DirectShow.NET はまだメンテナンスされていますか?
いいえ。DirectShow.NET は2010年2月以降放棄されています。Microsoft も基盤となる DirectShow API を Media Foundation に置き換えて非推奨にしています。
C# ビデオキャプチャに最適な DirectShow.NET の代替は何ですか?
VisioForge Video Capture SDK .Net は DirectShow フィルターグラフを型付き async API に置き換えます。80行以上の COM インターロップが必要だったウェブカメラキャプチャが5行の C# コードになり、内蔵の録画、ハードウェアエンコーディング、クロスプラットフォームサポートを提供します。
VisioForge はカスタム DirectShow フィルターグラフを置き換えられますか?
はい。VisioForge Media Blocks SDK は、カスタムフィルターグラフ構築を置き換える400以上のブロックを持つモジュラーパイプラインを提供します。
VisioForge は .NET 6、.NET 8、.NET 9、.NET 10 をサポートしていますか?
はい。すべての VisioForge .Net SDK パッケージは .NET 6 から .NET 10 をサポートしており、クロスプラットフォームデプロイメントも含まれます。
システムに DirectShow フィルターをインストールする必要はありますか?
いいえ。VisioForge は独自のコーデックとデコーダーをバンドルしています。H.264、H.265、AV1、VP9、AAC などのコーデックがすぐに使えます。
DirectShow.NET から段階的に移行できますか?
はい。VisioForge SDK は同じプロジェクト内で DirectShow.NET と共存できます。フィルターグラフを一つずつ置き換えてください。
