audio peak from video

Dec 15, 2011 at 12:22 AM

Hi,
Your work is incredible!
I want to make a vu meter and wanted to know if it's possible to poll audio peak at regular interval for the playing video?
I found directshow examples to do it for the device output but not for a singular source.

Thank you!
Michael

Jan 11, 2012 at 11:07 AM

anyone?

I think I have to add a samplegrabber filter but I have no idea where to put that.. and I'm a very newbie to directx

please help!

thank you!

Feb 22, 2012 at 10:43 AM

up!

Mar 19, 2012 at 10:12 PM

Is someone going to reply me?

I'm willing to pay someone to get it done

Mar 20, 2012 at 1:33 PM
Edited Mar 20, 2012 at 1:33 PM

You'll need to write a very simple transform filter for audio that samples the peak volume, with an interface with a method call, say, GetPeakVolume(), that you can call from your own program.

Then you'll need to modify the graph building to add your filter.  It is not something that is simple for novices to DirectShow.

Mar 27, 2012 at 10:44 AM

Hey thank you for your reply!
I'll try to do what you suggested, however my directx knowledge is very limited.

Can you just point me where the graph building is done?
Thank you!

Mar 28, 2012 at 1:46 AM

Give me your email address and I'll see if I can send you something.

May 3, 2012 at 4:17 PM

So I tried to do it myself with the code from codeproject http://www.codeproject.com/Articles/34663/DirectShow-Examples-for-Using-SampleGrabber-for-Gr and I am not able to connect properly the filter to the graph. When I call GetConnectedMediaType, I always get -2147220983. I think the problem is in the render part but I don't know why.

Here is the code that I use. It is called right after  InsertAudioRenderer(AudioRenderer)  in OpenSource of MediaUriPlayer.
I also moved the helper methods of the BaseClasses to be in a public class instead of an abstract.

Please help!
Thank you!

 

        public void InsertAudioGrabberRenderer(IGraphBuilder graph, string audioDevice)
        {
            Guid cat;
            Guid med;
            int hr;
           
            // Special scenario because normally no audio rendering is needed, however the
            // SampleGrabber must be inserted. So audio rendering is needed for this specific
            // scenario. In addition the null renderer will be added.
            cat = PinCategory.Preview;
            med = MediaType.Audio;

            if (this.InitAudioGrabber(graph))
            {
                this.nullRendererAudioFlt = (IBaseFilter)new NullRenderer();
                hr = graph.AddFilter(this.nullRendererAudioFlt, "Null Renderer");
                if (hr < 0)
                {
                    Marshal.ThrowExceptionForHR(hr);
                }
                Helper.AddFilterByName(graph, DsGuid.FromGuid(cat), audioDevice);
            }
               
            SetMediaAudioSampleGrabber();
        }

May 5, 2012 at 11:06 AM

-2147220983 is VFW_E_NOT_CONNECTED (VFW, or Video-For-Windows, is what DirectShow was very originally derived from).

So obviously DirectShow is telling you that your graph (and so your filters) have not yet been connected.  Therefore, it is not possible to get the connected media type because, obvious, the media type is only available when it is "connected".  Otherwise the API would have simply been called GetMediaType.

Inserting a filter into a graph does not automatically connect it.  You have to wait for the call to Render for the filters to be connected.

Jul 31, 2012 at 12:11 PM

Hi, sorry for the latereply, I've been busy with another project.

I don't understand when you say "You have to wait...".  To my knowledge, the existing filters are added without some kind of waiting..?
Can you point me how do I have to wait?

Thank you