سؤال

أحاول الحصول على مدة ملفات الوسائط مع directshow.يمكنني استخدام التعليمات البرمجية التالية (C #): giveacodicetagpre.

للحصول على مدة ملف الوسائط في ثوان.ومع ذلك، عندما أحاول فتح ملفات MP3 3-4 دقائق، يصبح 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