Getting an audio activity flag from LibVLC

This forum is about all development around libVLC.
Nothsa
New Cone
New Cone
Posts: 2
Joined: 25 Jul 2020 18:54
Operating System: Windows/Linux
Location: UK

Getting an audio activity flag from LibVLC

Postby Nothsa » 26 Jul 2020 16:25

I am writing a LibVLCSharp based Windows application for listening to multiple voice audio streams simultaneously. Each stream will carry a single 2-way radio or intercom channel, and may be silent for minutes or hours at a time. The application can monitor a dozen or more channels, and I would like to visually indicate which channels are currently active.

Ideally I would like to poll the audio level of each stream, so that I may detect audio activity, (100-500ms intervals should be sufficient). The maximum amplitude of the last audio frame, or a simple flag indicating amplitude above a threshold is all that I require.

There doesn't appear to be a way to achieve this using vanilla LibVLC, and my initial thought was to write a custom audio filter to do this. After some research, it's not clear to me whether this approach would work.

There are two areas which I'm hoping someone with more VLC experience can help me with:

  • Enabling a custom audio filter
    I've had no success enabling any of the supplied audio filters using LibVLC, either by passing an argument to libvlc_new(), or via libvlc_media_add_option(); however, I can successfully use both methods with VLC. I have recently found this comment by Rémi Denis-Courmon, which may indicate why:
    https://forum.videolan.org/viewtopic.php?t=143056
    "This is explicitly not supported by the libvlc_new() documentation. LibVLC controls audio filters (and many other things) internally."

    Can anyone tell me how I control LibVLC audio filter selection, and if there is any way for me to specify a custom filter?
  • Passing data between the application and the custom filter
    Is there a way for an application to access data within a custom module via LibVLC, (e.g. read the value of my custom filter's audio activity flag)?
    If this is not possible, then I may be able to use IPC to send the activity flag from the filter to my application; however, with multiple instances of the filter running, I would need a way for each filter to uniquely identify itself to the application. To this end:
    Has the filter got access to the MRL, or is there a way to pass data from the application to the audio filter, (e.g. a UUID)?
Of course, I may well be going about this in completely the wrong way. If you know of a better way for my application to discover audio stream activity, please let me know.

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: Getting an audio activity flag from LibVLC

Postby mfkl » 27 Jul 2020 09:30

Hi,

Not sure about the exact libvlc string syntax for audio filters but it's certainly doable. Can you share the code you tried?

Have you seen https://code.videolan.org/mfkl/libvlcsh ... Program.cs?
https://mfkl.github.io

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Getting an audio activity flag from LibVLC

Postby Jean-Baptiste Kempf » 29 Jul 2020 15:33

You can use a custom filter, but it might break when updating VLC. So it is at your own risk.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

silentbrown
New Cone
New Cone
Posts: 2
Joined: 21 Sep 2020 10:47

Re: Getting an audio activity flag from LibVLC

Postby silentbrown » 21 Sep 2020 11:03

I've been trying to do something very similar, and keep running into walls.
I'm playing media with audio and video normally output to the regular windows display/sound device. Here's what I've tried so far.

#1: Using libvlc_audio_set_callbacks to read and process the audio data.
BUT, this stops the audio actually playing :(

#2: Using smem and duplicate modules to get a copy of the audio data.
Audio now keeps playing, BUT audio muting with libvlc_audio_set_mute now stops working. :(

#3: Using smem and duplicate, but setting/clearing the callback as a way of muting the audio
Audio still doesn't mute. I think changing the callback when media is already playing has no effect.

I think my only option now is to use #1, but manually play the audio out using WAVEOUT. A/V sync is likely to be a problem....

Any other suggestions?

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: Getting an audio activity flag from LibVLC

Postby mfkl » 21 Sep 2020 15:42

#1: Using libvlc_audio_set_callbacks to read and process the audio data.
BUT, this stops the audio actually playing
It stops playing because it is on you to forward the decoded audio data to a device, as the documentation states.
https://mfkl.github.io

silentbrown
New Cone
New Cone
Posts: 2
Joined: 21 Sep 2020 10:47

Re: Getting an audio activity flag from LibVLC

Postby silentbrown » 21 Sep 2020 15:52

Sure, I know that now. What about libvlc_audio_set_mute with smem and duplicate, though?

There's no log message or error return - but the audio keeps on coming out.

Rémi Denis-Courmont
Developer
Developer
Posts: 15267
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Getting an audio activity flag from LibVLC

Postby Rémi Denis-Courmont » 21 Sep 2020 19:43

You can't have the cake and eat it. If you use stream output, then the normal VLC audio decoding and output are no longer used. So yeah, audio controls won't work.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 15 guests