2

As my normal user, this works:

ffmpeg -f pulse -i default -acodec aac foo.aac

but run with sudo is fails with:

default: No such process

How can I run ffmpeg as a privileged user (CAP_SYS_ADMIN), since I am keen to use the kmsgrab option and still get access to sound in order to record it too?

hendry
  • 9,725
  • 18
  • 81
  • 139

1 Answers1

0

There are two steps to connecting to the Pulse Audio server:

  1. Server path. By default, the PulseAudio server makes itself accessible to clients by creating a UNIX socket under $XDG_RUNTIME_DIR. Running commands via sudo will reset the environment, thus making PulseAudio clients unable to find the server to connect to.

  2. Authentication. By default, the PulseAudio server creates an authentication cookie in ~/.pulse-cookie, which clients must relay to the server upon connecting. If $HOME or $PULSE_COOKIE are not set to the cookie's location, clients will be unable to authenticate.

The complete command of thus running ffmpeg via sudo is as follows:

sudo env \
    PULSE_COOKIE=$HOME/.pulse-cookie \
    PULSE_SERVER=$XDG_RUNTIME_DIR/pulse/native \
    ffmpeg -y -f pulse -i default -acodec aac foo.aac 

You can probably substitute PULSE_SERVER with the -server ffmpeg device option.

Vladimir Panteleev
  • 24,651
  • 6
  • 70
  • 114