Adding audio filter to a media

This forum is about all development around libVLC.
drich42
New Cone
New Cone
Posts: 3
Joined: 30 Sep 2014 17:12

Adding audio filter to a media

Postby drich42 » 30 Sep 2014 17:17

Hi, I'm simply trying to add an audio filter to a media_t, but it doesn't seem to work.
Here is my code :

Code: Select all

#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <vlc/libvlc.h> #include <vlc/libvlc_media.h> #include <vlc/libvlc_media_player.h> #include <vlc/libvlc_events.h> #include <vlc/libvlc_version.h> int main(int ac, char** av) { const char* args[] = { "--verbose=11111", "--no-plugins-cache", "--audio-filter=dspa", }; libvlc_instance_t* instance = libvlc_new( sizeof(args) / sizeof(*args), args ); libvlc_media_player_t* player = libvlc_media_player_new( instance ); libvlc_media_t* media = libvlc_media_new_path( instance, av[1] ); libvlc_media_add_option_flag(media, ":audio", libvlc_media_option_trusted); libvlc_media_add_option_flag(media, ":audio-filter=dspa", libvlc_media_option_trusted); libvlc_media_player_set_media( player, media ); libvlc_media_player_play( player ); while(1); return 0; }
It just doesn't add the filter, and there's nothing about it in the log

I didn't find anything on the web about this kind of problem, I suppose the solution will be very easy but didn't find it :mrgreen:
Thank you

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

Re: Adding audio filter to a media

Postby Rémi Denis-Courmont » 30 Sep 2014 19:35

There are currently no ways to insert custom audio filters with LibVLC, except for the equalizer.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

drich42
New Cone
New Cone
Posts: 3
Joined: 30 Sep 2014 17:12

Re: Adding audio filter to a media

Postby drich42 » 30 Sep 2014 20:06

How does VLC binary itself do it so ?

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

Re: Adding audio filter to a media

Postby Rémi Denis-Courmont » 30 Sep 2014 20:14

The VLC binary uses libvlccore, not libvlc.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

drich42
New Cone
New Cone
Posts: 3
Joined: 30 Sep 2014 17:12

Re: Adding audio filter to a media

Postby drich42 » 02 Oct 2014 02:27

Thank you I found a workaround using vlccore.

I post the code in the case someone needs it :

Code: Select all

#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <vlc/libvlc.h> #include <vlc/libvlc_media.h> #include <vlc/libvlc_media_player.h> #include <vlc/libvlc_events.h> #include <vlc/libvlc_version.h> #include "dsp.h" void callback(signed short* samples, int nb_channels, int nb_samples) { } int main(int ac, char** av) { char* args[] = { "--verbose=11111", "--no-plugins-cache", "--audio-filter=dsp", "--dsp-callback=0", }; char str_cb[64]; sprintf(str_cb, "--dsp-callback=%16p", &callback); args[3] = str_cb; libvlc_instance_t* instance = libvlc_new( sizeof(args) / sizeof(*args), (const char**)args ); libvlc_media_player_t* player = libvlc_media_player_new( instance ); libvlc_media_t* media = libvlc_media_new_path( instance, av[1] ); libvlc_media_player_set_media( player, media ); if ( player->input.p_resource != 0 ) { audio_output_t *aout = input_resource_GetAout( player->input.p_resource ); if ( aout != 0 ) { var_Create( (vlc_object_t*)aout, "audio-filter", 0x0040 /*VLC_VAR_STRING*/ ); vlc_value_t val; val.psz_string = (char*)"dsp"; var_SetChecked( (vlc_object_t*)aout, "audio-filter", 0x0040 /*VLC_VAR_STRING*/, val ); aout->event.restart_request( aout, 1 /*AOUT_RESTART_FILTERS*/ ); input_resource_PutAout( player->input.p_resource, aout ); } } libvlc_media_player_play( player ); while(1); return 0; }

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: Adding audio filter to a media

Postby MidnightCoder » 30 Nov 2014 10:39

@Rémi Denis-Courmont,

Was there any reason to disable libvlc clients from using any audio filter beside the Equalizer? Is it possible to open up new DLL entries similar to libvlc_media_player_set_equalizer so that other filters can be used w/ libvlc?

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

Re: Adding audio filter to a media

Postby Rémi Denis-Courmont » 30 Nov 2014 10:46

Not possible so far.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

ppcat
Blank Cone
Blank Cone
Posts: 13
Joined: 12 Feb 2015 11:16
VLC version: 2.1.5
Operating System: Windows 7
Contact:

Re: Adding audio filter to a media

Postby ppcat » 13 Nov 2015 10:33

Great!
Can I add 2 filters using this method?

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: Adding audio filter to a media

Postby Jean-Baptiste Kempf » 25 Nov 2015 17:36

Yes, using ","
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.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 28 guests