문제

DirectShow로 미디어 파일 기간을 가져 오려고합니다.나는 다음 코드를 사용합니다 (C #) :

var seekingParser = filter as IMediaSeeking;
if (seekingParser != null)
{
   long duration;
   if (seekingParser.SetTimeFormat(TimeFormat.MediaTime) == 0
       && seekingParser.GetDuration(out duration) == 0)
       track.Duration = duration / 10000000f;
}
.

미디어 파일 기간을 초 단위로 가져 오십시오.그러나 3-4 분 MP3 파일을 열려고 할 때 Track.duration은 11-12 분이됩니다.여러 파일을 시도했고 효과는 항상 동일합니다.그 이유는 무엇일까요?

도움이 되었습니까?

해결책

You normally use IMediaPosition interface (instead of IMediaSeeking) from the application side. Duration is reported always in seconds. However this is unlikely to make a difference, and what might make it is reading duration from ID3 tags instead, using Windows Media API, ID3 Tag Support.

Are there more reliable ways to get exact duration of media file with DirectShow API?

Windows Media Player plays MP3 files through Media Foundation, a non-DirectShow API, so you don't have an option here to expect or do exactly the same from DirectShow.

다른 팁

From the documentation:

Depending on the source format, the duration might not be exact. For example, if the source contains a variable bit-rate (VBR) stream, the method might return an estimated duration.

Are you using a VBR stream, by any chance?

You can try the same on a clean windows installation. It might be possible you have a codec(pack) installed which is buggy.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top