k-lite mega codec packをインストールして、 directshowlib-2005を使用してみました。mp4 ファイルまたは f4v ファイル (avi、wmv、および flv は問題ありません) の長さを見つけることができません。directshowlib-2005 のImediaSeekingインターフェイスを使用して期間を見つけます。ただし、mp4 と f4v の場合、GetDuration メソッドはゼロを返します。
コーデックの問題であることはわかっていますが、mp4 ファイルと f4v ファイルの再生時間を取得するためにどのコーデックをインストールすればよいかわかりません。
私が使用しているコードを以下に示します。
static public bool GetVideoLength(string fileName, out long length)
{
DirectShowLib.FilterGraph graphFilter = new DirectShowLib.FilterGraph();
DirectShowLib.IGraphBuilder graphBuilder;
//DirectShowLib.IMediaPosition mediaPos=null;
DirectShowLib.IMediaSeeking mediaPos;
length = 4294967296;
try
{
graphBuilder = (DirectShowLib.IGraphBuilder)graphFilter;
graphBuilder.RenderFile(fileName, null);
//mediaPos = (DirectShowLib.IMediaPosition)graphBuilder;
mediaPos = (DirectShowLib.IMediaSeeking)graphBuilder;
// mediaPos.get_Duration(out length);
mediaPos.GetDuration(out length);
return true;
}
catch
{
return false;
}
finally
{
mediaPos = null;
graphBuilder = null;
graphFilter = null;
}
}
上記の期間を見つけるためにインストールする必要がある正確なコーデックを教えてください。