ac3jack is a tool for creating an AC-3 (Dolby Digital) multichannel
stream from its JACK input ports. Using this tool, an AC-3 stream (up
to 5.1 channels) is created in real time and either written to a file or
streamed to standard output.
When streamed to stdout and piped
through the ALSA tool ac3dec -C, the AC-3 stream can be passed out
the SPDIF port on your audio interface for connection to a
multichannel surround receiver. In this way, you can achieve full 5.1
surround mixing and monitoring of your JACK applications with a
single digital cable, and no need for hardware supporting discrete
outputs and inputs.
AC-3 is a compressed audio stream, so quality will suffer
somewhat, but it is the price you pay for easy surround sound. After
all, if it is good enough for DVD and film soundtracks, it must be OK.
The AC-3 encoder used here comes from the FFMPEG project, and I have not
done any quality comparisons with commercial encoders.
News
|
Version 0.1.2 released --
12 February 2004
*** fixed compilation bug (the code should be pure C now, honest :)
|
Version 0.1.1 released --
1 January 2004
*** Right and Center channels were swapped,
fixed. *** Initial channel port connections can
now be specified on command line. *** warning
added if streaming to stdout and not using 48kHz
sample rate.
|
Version 0.1.0 released --
29 December 2003
|
Download
|
ac3jack written by Jesse Chappell. It is licensed under the GPL and comes with NO WARRANTY of any kind.
Get the source code to the latest release and build it yourself --
ac3jack-0.1.2.tar.gz
|
Requirements
|
- JACK -- version >= 0.80.0
providing
real-time low-latency audio interconnection and
delivery. If you haven't used JACK before
please study the Linux
Audio User Guide and make sure to read the
section on JACK.
- FFMPEG --
version >= 0.4.6
Note that you'll need to make sure the header files are installed,
some packages do not install the headers for some reason. A make
install from the source code will do this.
|
Usage
|
ac3jack -o <str> [options...] [portname ...]
|
Options:
|
-o , --output=<str> | specify file to write output AC-3 stream, 'stdout' will write to standard output |
-c <num> , --channels=<num> | number of AC-3 output channels (2-6). default is 6 (5.1) |
-b <num> , --bitrate=<num> | bitrate of AC-3 stream (kbits/s). default is 448 |
-d <num> , --duration=<num> | duration of output stream (secs). default is 0 (forever) |
-t , --jack-transport | use jack transport state (rolling/stopped) to control stream output | |
-j <str> , --jack-name=<str> | jack client name, default is ac3jack |
-B <num> , --bufsize=<num> | internal buffer size (samples), if overrun problems occur try a large value |
-q , --quiet | do not output status to stderr |
-h , --help | this usage output |
-V , --version | show version only |
If portname arguments are added, they are initially connected in channel order, if possible. |
|
Notes
|
The allowable bitrates for AC-3 encoding are nominally variable from
32-640 kbits/s, but there are common conventions and recommendations
for bitrate based on channel count. Only certain bitrates are likely
to be accepted by the codec as well.
2 ch | 192 |
5.1 (6 channel) | 448 |
The sample rates allowable are 32, 44.1, and 48kHz. Note that for use
as part of DVD soundtracks multiplexed with MPEG2 files, only 48kHz is
allowed. Currently the sample rate is selected by the native rate of
the active JACK server.
The channels options will make the following input ports with each
given channel count:
1 - | Left |
2 - | Left, Right |
3 - | Left, Center, Right |
4 - | Left, Right, LeftSurround, RightSurround |
5 - | Left, Center, Right, LeftSurround, RightSurround |
6 - | Left, Center, Right, LeftSurround, RightSurround, LFE |
If the -t (--jack-transport) option is used, ac3jack will only write
to the output when the JACK Transport state is Rolling. This is useful
in order to do port connection before the streaming
begins, or to synchronize AC-3 stream capture to disk.
If extra arguments are added to the end of the command
line, they are treated as JACK ports to connect to the
inputs (in channel orders shown above).
OUTPUT TO FILE
ac3jack -o file.ac3
This will create the ac3jack client with 6 inputs, (L,R,C,LS,RS,and
LFE) to which you can connect with your favorite JACK patchbay
(eg. qjackctl). It will create an AC-3 stream and the output will be
written to the file specified. As mentioned above, the -t option can
be useful here.
REAL-TIME OUTPUT TO SURROUND RECIEVER VIA SPDIF
It appears that SPDIF AC-3 passthrough
is only done at a 48kHz sample rate.
Therefore, you currently must run JACK at 48kHz in order
to maintain an uninterrupted audio stream.
The following command line can be used to send the AC-3 stream through
your audio interface (sound card) SPDIF output. You must have the
tool 'ac3dec' installed from the alsa-tools package available from
http://alsa-project.org. Chances are you have it already if you are using
ALSA.
ac3jack -o stdout | ac3dec -C
This will create the ac3jack client with 6 inputs, (L,R,C,LS,RS,and
LFE) to which you can connect with your favorite JACK patchbay
(eg. qjackctl). It will create an AC-3 stream and the output will be
piped to the ac3dec command. The -C option to ac3dec causes it to try
to open the SPDIF portion of your sound card for raw output and send
the stream through it. You should see something like the following
on the terminal when successful:
ac3jack encoding with 6 channels, 48kHz, 448 kbit/s bitrate, output to stdout
Using PCM device 'plug:iec958:{AES0 0x2 AES1 0x82 AES2 0x0 AES3 0x2}'
AC3 Stream 48 KHz 448 kbps
Some sound cards may not allow the SPDIF to be accessed when JACK is
using it. If you get no output from the SPDIF, or you never see the
line including something like "AC3 Stream 48 KHz 448 kbps" you are one
of the unlucky ones. In this case, to do real-time streaming you must
have two sound cards, with JACK running on one, and the -c (lowercase)
option used with ac3dec to choose the other card for the SPDIF output (clock drift
is likely going to be a problem here).
At some point in the future, JACK may provide a capability to stream
raw SPDIF internally.
|
Copyright 2004 Jesse Chappell <jesse at essej dot net>
Last modified: Thu Jan 1 23:47:53 EST 2004
|