2

Is there a way I can make vlc play all videos at 50% volume by default? I looked at the online documentation but it didn't say if there is a configuration file I could tweak.

Is there any way, by editing a configuration file or any other method, to set vlc's default volume to 50%?

  • I changed your question since you're not really interested in a yes/no answer about whether vlc has a configuration file, you seem to be asking about setting the default volume. By the way, yes, it does: ~/.config/vlc/vlcrc. – terdon Oct 21 '15 at 21:03
1

First, let's be lazy: this can be done using the GUI. Which GUI to use however depends on the audio output system you're using. Open VLC, and go to Tools > Preferences > Audio. The Output module setting will tell you what you're using.

  • If you're using Pulse, then your default volume level is handled by Pulse itself. The easiest way to configure that is to use pavucontrol. Install it using your package manager, start VLC (with audio), and open pavucontrol. Get to the Playback tab, and set VLC's new value (in your case, 50%).

  • If you're using ALSA, you can set your value in VLC directly. Just above the Output module option, check the Always reset audio start level to box, and select 50% in the slider next to it.


If you want to configure the volume level without using VLC/pavucontrol, then again, the method depends on your audio output. Let's have a look at VLC's code:

static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout)
{
    if (!strcmp(aout, "pulse"))
        return -1;
    else if (!strcmp(aout, "alsa") && module_exists("alsa"))
        return cbrtf(config_GetFloat(obj, "alsa-gain")) * 100.f + .5f;
    else if (!strcmp(aout, "sndio"))
        return -1;
    return -1;
}

I've simplified it a bit, but basically:

If you're using Pulse, VLC's configuration has no impact. You'll need to configure Pulse itself. Have a look at pactl (or maybe pacmd for an interactive interface). Here's a "little" one-liner to set VLC's default level:

$ pactl set-sink-input-volume $(pactl list short sink-inputs | grep $(pactl list short clients | grep vlc | cut -f1) | cut -f1) 50%

And yes, that's ugly. Basically, I'm getting VLC's index (as a client), and finding the associated sink input's index. Then I inject that index into set-sink-input-volume, and set the value to 50%. Have a look at pactl(1) for more information about these pactl commands. Remember that you can also use pavucontrol to configure Pulse in a GUI :)

If you're using ALSA, your default volume level is determined using the alsa-gain setting in ~/.config/vlc/vlcrc. For a default volume of x, you should set this value to ((x - 0.5) / 100) ^ 3, since cbrtf is a cube root. In your case, that means alsa-gain = (49.5 / 100) ^ 3 = 0.121287375. You'll also need to set the volume-save setting to 0 (false) in order to apply your new default value every time, regardless of the volume level you were at the last time you closed VLC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.