1

I use jack to route audio between multiple sound cards in my pc. To record the audio i use a very convenient FFmpeg command which creates a writable jack client: ffmpeg -f jack -i <client_name> -strict -2 -y <output_file_name>. so far this works very well.

The problem starts here:

I also have an nginx docker which records my data and makes it available for streaming. when trying to use the same command inside the docker i get the following error:"Unable to register as a JACK client".

I started to look in to the FFmpeg code and found out that the FFmpeg command calls the jack_client_open command from the jack API, which fails.

Seems like there is some kind of a problem in the connection between the FFmpeg request from inside the docker to the jackd server running on the host.

Is there a simple way to create a connection between the two [exposing ports]?

(I saw some solutions like netjack2, but before creating a more complex server-client architecture i'd like to find a more elegant solution).

Thanks for the help!

Fangming
  • 24,551
  • 6
  • 100
  • 90
unameuname
  • 621
  • 5
  • 9
  • if it is possible to use Unix socket to run `jack` server and use that for communication with `ffmpeg`, then you can mount the socket file into the container and use that for communication. Another thing you can do is use docker in `host` network mode and use your host machines IP inside docker to communicate. – vedarthk Jul 16 '17 at 20:44
  • solution 1: i dug in to the jack code and found that all sockets are located in /dev/shm. i shared this volume with docker and ran the FFmpeg command, but it wouldn't connect. any ideas why? solution 2: thought about using ssh, but it's a bit crooked - https://stackoverflow.com/questions/31720935/execute-host-commands-from-within-a-docker-container – unameuname Jul 18 '17 at 07:50
  • it would be helpful if you can add what commands you are executing to run the container and share the output when you tried to mount the sockets inside the container. – vedarthk Jul 18 '17 at 17:52

1 Answers1

5

I've just got this working, and I required the following in my docker run commands:

--volume=/dev/shm:/dev/shm:rw
--user=1000

So that the container is running a user which can access files in /dev/shm from a jackd spawned from my host user account. This wouldn't be required if your jackd and the container are both running as user root.

You can confirm its working by running jack_simple_client in the container, you should get a beep.

Hamid Rouhani
  • 2,309
  • 2
  • 31
  • 45
Steve Baker
  • 51
  • 1
  • 2