Page 1 of 1

Adding audio filter to a media

Posted: 30 Sep 2014 17:17
by drich42
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

Re: Adding audio filter to a media

Posted: 30 Sep 2014 19:35
by Rémi Denis-Courmont
There are currently no ways to insert custom audio filters with LibVLC, except for the equalizer.

Re: Adding audio filter to a media

Posted: 30 Sep 2014 20:06
by drich42
How does VLC binary itself do it so ?

Re: Adding audio filter to a media

Posted: 30 Sep 2014 20:14
by Rémi Denis-Courmont
The VLC binary uses libvlccore, not libvlc.

Re: Adding audio filter to a media

Posted: 02 Oct 2014 02:27
by drich42
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; }

Re: Adding audio filter to a media

Posted: 30 Nov 2014 10:39
by MidnightCoder
@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?

Re: Adding audio filter to a media

Posted: 30 Nov 2014 10:46
by Rémi Denis-Courmont
Not possible so far.

Re: Adding audio filter to a media

Posted: 13 Nov 2015 10:33
by ppcat
Great!
Can I add 2 filters using this method?

Re: Adding audio filter to a media

Posted: 25 Nov 2015 17:36
by Jean-Baptiste Kempf
Yes, using ","