\input texinfo   @c -*-texinfo-*-
@afourpaper
@setfilename bino.info
@documentlanguage en
@documentencoding UTF-8
@include version.texi
@settitle Bino @value{VERSION}

@copying
This manual was last updated @value{UPDATED} for version
@value{VERSION} of Bino.

Copyright @copyright{} 2011, 2012
Martin Lambers (@email{marlam@@marlam.de}),
Stefan Eilemann (@email{eile@@eyescale.ch}),
Frédéric Devernay (@email{Frederic.Devernay@@inrialpes.fr})

@quotation
Copying and distribution of this file and the referenced media files, with or
without modification, are permitted in any medium without royalty provided the
copyright notice and this notice are preserved. These files are offered as-is,
without any warranty.
@end quotation
@end copying

@dircategory Individual utilities
@direntry
* bino: (bino).         A 3D video player with multi-display support.
@end direntry

@finalout
@titlepage
@title Bino
@subtitle A 3D video player with multi-display support.
@subtitle Version @value{VERSION}, @value{UPDATED}
@author The Bino developers
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage

@ifnothtml
@contents
@end ifnothtml

@ifnottex
@node Top
@top Bino
@insertcopying
@end ifnottex

@ifhtml
Short Contents:
@end ifhtml
@menu
* Introduction::
* Invocation::
* Input Layouts::
* Output Techniques::
* Interactive Control::
* Scripting::
* Camera Devices::
* Audio/Video Synchronization::
* Performance Tweaking::
@end menu
@ifhtml
@contents
@end ifhtml

@node Introduction
@chapter Introduction

Bino is a 3D video player with multi-display support.

3D videos are more accurately called stereoscopic videos. Such videos have
separate views for the left and right eye and thus allow depth perception
through stereopsis.

The left and right view of a stereoscopic video can be stored using different
layouts. Sometimes the two views are stored as two separate video streams, but
most often both views are packed into a single video stream and need to be
unpacked by the video player. Bino supports all commonly used layouts.
@xref{Input Layouts}.

To display a stereoscopic video, the left and right view have to be prepared in
a special way so that the left eye sees the left view and the right eye sees
the right view. Different display techniques use different approaches to
achieve this separation of the two views. Bino supports a wide variety of such
techniques. @xref{Output Techniques}.

@node Invocation
@chapter Invocation

This section describes the command line interface of Bino.

Synopsis:
@code{bino [@var{option}@dots{}] [@var{file}@dots{}]}

Bino combines all input files into one media source which is then played. This
means you can have video, audio, and subtitle streams in separate files. The
files are decoded with the @url{http://ffmpeg.org/,FFmpeg} libraries, so URLs
and other special constructs are supported.

@table @samp
@item --help
Print help.
@item --version
Print version.
@item -n
@itemx --no-gui
Do not use the GUI, just play the given input in a plain window using the
parameters given on the command line.
@itemx --log-file=@var{FILE}
Append all log messages to the given file.
@item -L
@itemx --log-level=@var{LEVEL}
Select log level: @var{debug}, @var{info}, @var{warning}, @var{error}, or
@var{quiet}.
@item --list-audio-devices
Print a list of known audio devices and exit.
@item -A
@itemx --audio-device=@var{N}
Use audio device number @var{N}. @var{N}=0 is the default device.
@item D
@itemx --audio-delay=@var{D}
Delay audio by D milliseconds. Default is 0.
@item -V
@itemx --audio-volume=@var{V}
Set audio volume (0 to 1). Default is 1.
@item -m
@itemx --audio-mute
Mute audio.
@item --device-type=@var{TYPE}
Type of input device: @var{default}, @var{firewire}, or @var{x11}.
@item --device-frame-size=@var{W}x@var{H}
If the input is a device, request the given frame size, e.g. 640x480.
@item --device-frame-rate=@var{N}/@var{D}
If the input is a device, request the given frame rate, e.g. 25/1.
@item --device-format=@var{FORMAT}
Request format @var{default} or @var{mjpeg} from device.
@item --read-commands=@var{FILE}
Read commands from file. @xref{Scripting}.
@item --lirc-config=@var{FILE}
Use the given LIRC configuration file. This option can be used more than once.
@item --quality=@var{Q}"
Set rendering quality, from 0 (fastest) to 4 (best, default).
@item -v
@itemx --video=@var{STREAM}
Select video stream (1-n, depending on the input).
@item -a
@itemx --audio=@var{STREAM}
Select audio stream (1-n, depending on the input).
@item -s
@itemx --subtitle=@var{STREAM}
Select subtitle stream (1-n, depending on the input).
@item -i
@itemx --input=@var{TYPE}
Select input layout. @xref{Input Layouts}.
@item -o
@itemx --output=@var{TYPE}
Select output technique. @xref{Output Techniques}.
@item -S
@itemx --swap-eyes
Swap left/right view.
@item -f
@itemx --fullscreen
Fullscreen.
@item --fullscreen-screens=[@var{S0}[,@var{S1}[,@dots{}]]]
Use the listed screens @var{S0}, @dots{}, @var{Sn} in fullscreen mode. Screen
numbers start with 1. If the list is empty, the primary screen will be used
(this is the default).
@item --fullscreen-flip-left
Flip left view vertically when in fullscreen mode.
@item --fullscreen-flop-left
Flop left view horizontally when in fullscreen mode.
@item --fullscreen-flip-right
Flip right view vertically when in fullscreen mode.
@item --fullscreen-flop-right
Flop right view horizontally when in fullscreen mode.
@item --fullscreen-3dr-sync
Use DLP@registeredsymbol{} 3-D Ready Sync when in fullscreen mode.
@item -z
@itemx --zoom=@var{Z}
Set zoom for videos that are wider than the screen, from 0 (off; show full
video width) to 1 (full; use full screen height). The default is 0.
@item -C
@itemx --crop=@var{W:H}
Crop the video to the given aspect ratio, to remove borders. 0:0 disables cropping.
@item -c
@itemx --center
Center window on screen.
@item --subtitle-encoding=@var{ENC}
Set subtitle encoding.
@item --subtitle-font=@var{FONT}
Set subtitle font name.
@item --subtitle-size=@var{N}
Set subtitle font size.
@item --subtitle-scale=@var{S}
Set subtitle scale factor.
@item --subtitle-color=@var{COLOR}
Set subtitle color, in [AA]RRGGBB format.
@item --subtitle-shadow=@var{-1|0|1}
Set subtitle shadow, -1=default, 0=off, 1=on.
@item --subtitle-parallax=@var{VAL}
Subtitle parallax adjustment (-1 to +1).
@item -P
@itemx --parallax=@var{VAL}
Parallax adjustment (-1 to +1).
@item --crosstalk=@var{VAL}
Crosstalk leak level (0 to 1). Comma-separated values for the R,G,B channels.
@item --ghostbust=@var{VAL}
Amount of crosstalk ghostbusting to apply (0 to 1).
@item -b
@itemx --benchmark
Benchmark mode: no audio, no time synchronization, output of frames-per-second
measurements.
@item --swap-interval=@var{D}
Frame rate divisor relative to display refresh rate. The default is 0 for
benchmark mode and 1 otherwise.
@item -l
@itemx --loop
Loop the input media.
@end table

@node Input Layouts
@chapter Input Layouts

@section Overview

The left and right view of a stereoscopic video can be stored using different
layouts. Sometimes they are stored in separate files, sometimes in separate
streams inside the same file, and often they are packed into a single video on
top of each other or next to each other, with or without a reduction of
resolution.

By default, Bino autodetects the input layout from meta data stored in the file
(for example, the Matroska and WebM formats have a @code{StereoMode} field for
that purpose).
If no meta data is available, Bino tries to autodetect the input layout based on
the file name. @xref{File Name Conventions}. If that fails, too, Bino guesses
based on the resolution of the input.

@section Supported Input Layouts
@anchor{Supported Input Layouts}

@table @var
@item mono
Single view (2D conventional video).@*
@image{input-layout-mono,,,,png}
@item separate-left-right
Separate streams: left view first, right view second.@*
@image{input-layout-separate-left-right,,,,png}
@item separate-right-left
Separate streams: right view first, left view second.@*
@image{input-layout-separate-right-left,,,,png}
@item alternating-left-right
Alternating frames: left view first, right view second.@*
@image{input-layout-alternating-left-right,,,,png}
@item alternating-right-left
Alternating frames: right view first, left view second.@*
@image{input-layout-alternating-right-left,,,,png}
@item top-bottom
Single stream: left view top, right view bottom.@*
@image{input-layout-top-bottom,,,,png}
@item top-bottom-half
Single stream: left view top, right view bottom, both with half height.@*
@image{input-layout-top-bottom-half,,,,png}
@item bottom-top
Single stream: right view top, left view bottom.@*
@image{input-layout-bottom-top,,,,png}
@item bottom-top-half
Single stream: right view top, left view bottom, both with half height.@*
@image{input-layout-bottom-top-half,,,,png}
@item left-right
Single stream: left view left, right view right.@*
@image{input-layout-left-right,,,,png}
@item left-right-half
Single stream: left view left, right view right, both with half width.@*
@image{input-layout-left-right-half,,,,png}
@item right-left
Single stream: right view left, left view right.@*
@image{input-layout-right-left,,,,png}
@item right-left-half
Single stream: right view left, left view right, both with half width.@*
@image{input-layout-right-left-half,,,,png}
@item even-odd-rows
Single stream: left view in even rows, right view in odd rows.@*
@image{input-layout-even-odd-rows,,,,png}
@item odd-even-rows
Single stream: right view in even rows, left view in odd rows.@*
@image{input-layout-odd-even-rows,,,,png}
@end table

@section File Name Conventions
@anchor{File Name Conventions}

If the meta data stored in a file does not indicate the input layout, Bino
tries to guess it by looking at the last part of the file name before the file
name extension (@file{.ext}).

The following file name forms are recognized:
@table @file
@item *-lr.ext
Input layout @var{left-right}.
@item *-lrh.ext
@itemx *-lrq.ext
Input layout @var{left-right-half}.
@item *-rl.ext
Input layout @var{right-left}.
@item *-rlh.ext
@itemx *-rlq.ext
Input layout @var{right-left-half}.
@item *-tb.ext
@itemx *-ab.ext
Input layout @var{top-bottom}.
@item *-tbh.ext
@itemx *-abq.ext
Input layout @var{top-bottom-half}.
@item *-bt.ext
@itemx *-ba.ext
Input layout @var{bottom-top}.
@item *-bth.ext
@itemx *-baq.ext
Input layout @var{bottom-top-half}.
@item *-eo.ext
@itemx *-eoq.ext
@itemx *-3dir.ext
Input layout @var{even-odd-rows}.
@item *-oe.ext
@itemx *-oeq.ext
@itemx *-3di.ext
Input layout @var{odd-even-rows}.
@item *-2d.ext
Input layout @var{mono}.
@end table


@node Output Techniques
@chapter Output Techniques

@section Overview

The left and right view of a stereoscopic video need to be displayed in a way
that ensures that the left view is only seen by the left eye of the user and
the right view is only seen by the right eye. There are many different
techniques to achieve this separation of left and right view, and Bino supports
most of them.

With some display techniques, some part of the right view may also seen by the
left eye and vice versa. This is called crosstalk and leads to ghosting
artefacts that reduce image quality. For some display types, Bino can reduce
such artefacts. @xref{Crosstalk Ghostbusting}.

One of the simplest output techniques is anaglyph glasses. Such glasses use
color filters to separate the left and right view. Anaglyph glasses are cheap
and work with every display, but the view separation and color reproduction are
of relatively low quality. Still, depending on the video material, Bino can
achieve high quality results using the
@url{http://www.site.uottawa.ca/~edubois/anaglyph/,Dubois method} to produce
video output for anaglyph glasses.

With OpenGL, the default method to display stereoscopic 3D content is OpenGL
quad buffered stereo, often used with active shutter glasses. However, graphics
card manufacturers tend to enable this output technique only on expensive high
end hardware.

Many 3D computer displays use polarized glasses to separate left and right
view, and some autostereoscopic displays do not require any glasses at all.
Most of these 3D computer displays expect left and right view packed in a
single video frame, e.g. on top of each other or next to each other or
partitioned into even and odd pixel lines or columns. Bino supports all
variants of such modes; refer to the manual of your display to find out which
mode is required.

Another common way to display 3D stereoscopic content is to use two
conventional 2D displays or projectors for the left and right view and combine
both views either using a half-transparent mirror, or a single screen with
polarized glasses. This is supported in Bino using multiscreen output.
@xref{Basic Multi Display Support}.

For more complex setups, such as powerwalls or virtual reality installations
driven by render clusters, Bino supports distributed video rendering via
Equalizer. @xref{Advanced Multi Display Support}.

The default output technique for stereoscopic 3D input is OpenGL quad buffered
stereo if the graphics card supports it, otherwise red/cyan anaglyph glasses.

@section Supported Output Techniques
@anchor{Supported Output Techniques}

@table @var
@item stereo
OpenGL quad-buffer stereo.@*
@image{output-type-stereo,,,,png}
@item alternating
Left and right view alternating. This can be used for shutter glasses on systems that do not support
OpenGL quad-buffer stereo, but note that this mode may be unreliable and may swap left/right eyes occasionally,
depending on your system. In case of problems, disabling the fullscreen mode screensaver inhibition may help.
@*
@image{output-type-alternating,,,,png}
@item mono-left
Left view only.@*
@image{output-type-mono-left,,,,png}
@item mono-right
Right view only.@*
@image{output-type-mono-right,,,,png}
@item top-bottom
Left view top, right view bottom.@*
@image{output-type-top-bottom,,,,png}
@item top-bottom-half
Left view top, right view bottom, both with half height.@*
@image{output-type-top-bottom-half,,,,png}
@item left-right
Left view left, right view right.@*
@image{output-type-left-right,,,,png}
@item left-right-half
Left view left, right view right, both with half width.@*
@image{output-type-left-right-half,,,,png}
@item even-odd-rows
Left view in even rows, right view in odd rows.@*
@image{output-type-even-odd-rows,,,,png}
@item even-odd-columns
Left view in even columns, right view in odd columns.@*
@image{output-type-even-odd-columns,,,,png}
@item checkerboard
Left and right view in a checkerboard pattern.@*
@image{output-type-checkerboard,,,,png}
@item hdmi-frame-pack
HDMI frame packing mode (left top, right bottom, plus extra blank lines
separating the two views). This mode is only necessary if you are forcing your
display into the corresponding HDMI 3D mode. A description how to do this on
GNU/Linux can be found in
@url{http://lists.nongnu.org/archive/html/bino-list/2011-03/msg00033.html,this post to the Bino mailing list}.@*
@image{output-type-hdmi-frame-pack,,,,png}
@item red-cyan-monochrome
Red/cyan anaglyph glasses, monochrome method.@*
@image{output-type-red-cyan,,,,png}
@item red-cyan-half-color
Red/cyan anaglyph glasses, half color method.@*
@image{output-type-red-cyan,,,,png}
@item red-cyan-full-color
Red/cyan anaglyph glasses, full color method.@*
@image{output-type-red-cyan,,,,png}
@item red-cyan-dubois
Red/cyan anaglyph glasses, high-quality Dubois method.@*
@image{output-type-red-cyan,,,,png}
@item green-magenta-monochrome
Green/magenta anaglyph glasses, monochrome method.@*
@image{output-type-green-magenta,,,,png}
@item green-magenta-half-color
Green/magenta anaglyph glasses, half color method.@*
@image{output-type-green-magenta,,,,png}
@item green-magenta-full-color
Green/magenta anaglyph glasses, full color method.@*
@image{output-type-green-magenta,,,,png}
@item green-magenta-dubois
Green/magenta anaglyph glasses, high-quality Dubois method.@*
@image{output-type-green-magenta,,,,png}
@item amber-blue-monochrome
Amber/blue anaglyph glasses, monochrome method.@*
@image{output-type-amber-blue,,,,png}
@item amber-blue-half-color
Amber/blue anaglyph glasses, half color method.@*
@image{output-type-amber-blue,,,,png}
@item amber-blue-full-color
Amber/blue anaglyph glasses, full color method.@*
@image{output-type-amber-blue,,,,png}
@item amber-blue-dubois
Amber/blue anaglyph glasses, high-quality Dubois method.@*
@image{output-type-amber-blue,,,,png}
@item red-green-monochrome
Red/green anaglyph glasses, monochrome method.@*
@image{output-type-red-green,,,,png}
@item red-blue-monochrome
Red/blue anaglyph glasses, monochrome method.@*
@image{output-type-red-blue,,,,png}
@item equalizer
Multi-display OpenGL via Equalizer with a 2D canvas setup.@*
@item equalizer-3d
Multi-display OpenGL via Equalizer with a 3D screen setup.@*
@end table

@section Crosstalk Ghostbusting
@anchor{Crosstalk Ghostbusting}

Many stereoscopic display devices suffer from crosstalk between the left and
right view. This results in ghosting artifacts that can degrade the viewing
quality, depending on the video content.

Bino can optionally reduce the ghosting artifacts. For this, it needs two know
@enumerate
@item the amount of crosstalk of your display device and
@item the amount of ghostbusting that is adequate for the video you want to
watch.
@end enumerate

Please note that ghostbusting does not work with anaglyph glasses.

To measure the display crosstalk, do the following:

@enumerate
@item Display the @uref{gamma-pattern-tb.png,@code{gamma-pattern-tb.png}} image
and correct the display gamma settings according to the included instructions.
You need to have correct gamma settings before measuring crosstalk.
@item Display the
@uref{crosstalk-pattern-tb.png,@code{crosstalk-pattern-tb.png}} image and
determine the crosstalk levels using the included instructions.
@end enumerate

You now have three crosstalk values for the red, green, and blue channels. You
can now tell Bino about this using the @option{--crosstalk} option. For example,
if you have measured 8% of crosstalk for red, 12% for green, and 10% for blue,
use
@example
$ bino --crosstalk 0.08,0.12,0.10
@end example

Once you know the crosstalk levels of your display device, you can set the
amount of ghostbusting that Bino should apply using the @option{--ghostbust}
option. This will vary depending on the content you want to watch. Movies with
very dark scenes should be viewed with at least 50% ghostbusting
(@option{--ghostbust 0.5}), whereas overall bright movies, where crosstalk is
less disturbing, could be viewed with a lower level (e.g.
@option{--ghostbust 0.1}).

To check if you crosstalk calibration is correct, display the crosstalk patterns
with full ghostbusting, like this:
@example
$ bino --crosstalk 0.08,0.12,0.10 --ghostbust 1.0 crosstalk-pattern-tb.png
@end example
The remaining crosstalk should optimally be 0%.

@section Basic Multi Display Support
@anchor{Basic Multi Display Support}

For basic multi display support, Bino requires that all displays are connected
to a single computer and are configured to display one large desktop.  For such
a setup, you can configure which screens Bino should use in fullscreen mode.

For example, if you have two projectors L and R that project onto a single
screen with polarization filters, and you have configured your desktop to cover
both projectors next to each other (LR), then you can configure fullscreen mode
to use both projectors and select the @code{left-right} output technique.

For similar setups, it is sometimes useful to mirror either the left or the
right view horizontally or vertically. This, too, can be configured in Bino's
fullscreen settings.

Of course, you can also combine multiple monitors to form one large display and
use this with some other output technique, e.g. anaglyph glasses.

For more advanced setups, e.g. involving multiple computers and/or graphics
cards or non-planar projection surfaces, you can use Bino's advanced multi
display support via Equalizer.

@section Advanced Multi Display Support
@anchor{Advanced Multi Display Support}

Bino supports distributed multi-display output via the Equalizer framework.

This is how it works:

@subsection Building Bino with Equalizer Support

First, install Equalizer 1.0 or later. See
@url{http://www.equalizergraphics.com/}.  Verify that it works by running the
included @code{eqHello} example.

Then, build Bino with Equalizer support. The output of configure should contain
the following line:
@example
Equalizer: yes
@end example

Now you need an Equalizer configuration file for your display setup.

@subsection Configuring Equalizer and Starting Bino

Bino needs a two-dimensional Equalizer canvas (= combined screen area),
subdivided into segments (= single display areas). For example, if you have
two projectors that project onto a 2m x 1m screen side-by-side, then your
canvas is 2m x 1m large, and you have two segments: the first segment fills
the left half of the canvas, and the second segment fills the right half.

Next, Equalizer needs to know how to render into each segment. For this
purpose, you define several hierarchical objects: nodes (= processes, possibly
on different systems), pipes (= graphics cards), windows (= output windows
with OpenGL contexts), and channels (= parts of windows). The video output
happens at the channel level: each channel is assigned to one segment of the
canvas. Most probably you just have one fullscreen window per pipe, and a
single output channel per window.

Note that one node is special: the application node, which is the node that
you initially start (the other nodes are started automatically by Equalizer).
The application node is called 'appNode' in the Equalizer configuration, and
Bino will play audio only on the application node. All video output is then
synchronized to this audio output.

Once you have your configuration file (examples are given below), you can
check if it works correctly using the @command{eqHello} example:
@example
$ eqHello --eq-config configuration.eqc
@end example

Once you made sure that this works, you can start Bino using this command:
@example
$ bino -o equalizer --eq-config configuration.eqc video.mp4
@end example

Note that all your nodes need access to the video file using the same name, so
a shared filesystem is helpful if you use multiple systems.

To play live video from a webcam or TV card, you can set up a streaming server
using ffserver (part of FFmpeg) or vlc, and then give the appropriate URL to
Bino. You can use multicast to stream the video to multiple systems
efficiently.

The output mode @option{-o equalizer-3d} allows to configure non-planar projections.
Bino projects the video onto a virtual screen in 3D space. The screen is
located in the distance of the biggest front-facing segment, and sized to fill
the wall optimally. By configuring the output segments accordingly, various
advanced display configurations can be used, e.g. displays rotated around the
Z axis by an arbitrary angle or non-planar screens.

@subsection Example Configurations

@subheading Simple 2D video output

In this example, you have a 2m x 1m screen and two projectors: one for the
left half of the screen, and one for the right half. The two projectors are
connected to two graphics cards on the same system.

In this situation, you have one node with two pipes, and each pipe has a
fullscreen window with a single output channel. The first output channel is
assigned to the left segment, and the second output channel is assigned to the
right channel. The resulting configuration looks like this:

@example
@verbatim
server
{
    config
    {
        appNode
        {
            pipe { device 0 window { attributes { hint_fullscreen ON } channel { name "left" }}}
            pipe { device 1 window { attributes { hint_fullscreen ON } channel { name "right" }}}
        }
        observer {}
        layout { view { observer 0 }}
        canvas
        {
            layout 0
            wall
            {
                bottom_left  [ 0.0  0.0 -1 ]
                bottom_right [ 2.0  0.0 -1 ]
                top_left     [ 0.0  1.0 -1 ]
            }
            segment { channel "left" viewport [ 0.0 0.0 0.5 1.0 ] }
            segment { channel "right" viewport [ 0.5 0.0 0.5 1.0 ] }
        }
        compound
        {
            compound { channel ( view 0 segment 0 ) swapbarrier {} }
            compound { channel ( view 0 segment 1 ) swapbarrier {} }
        }
    }
}
@end verbatim
@end example

@subheading 3D video output across multiple systems

In the following example, you have a 4m x 3m screen for 3D projection via
passive stereo (e.g. polarization). You have two systems, "render1" and
"render2", each equipped with two graphics cards. The two cards on "render1"
generate two images for the left half of the screen: one for the left eye view
and one for the right eye view. The two cards on "render2" generate left and
right view for the right half of the screen. Additionally, you have a system
called "master" which has a sound card and should display a small control
window.

This setup is very similar to the situation shown in
@uref{multi-display-vrlab.jpg,@code{multi-display-vrlab.jpg}}.

The configuration looks like this:

@example
@verbatim
server
{
    connection { hostname "master" }
    config
    {
        appNode
        {
            connection { hostname "master" }
            pipe { window { viewport [ 100 100 400 300 ] channel { name "control" }}}
        }
        node
        {
            connection { hostname "render1" }
            pipe { device 0 window { attributes { hint_fullscreen ON } channel { name "render1left" }}}
            pipe { device 1 window { attributes { hint_fullscreen ON } channel { name "render1right" }}}
        }
        node
        {
            connection { hostname "render2" }
            pipe { device 0 window { attributes { hint_fullscreen ON } channel { name "render2left" }}}
            pipe { device 1 window { attributes { hint_fullscreen ON } channel { name "render2right" }}}
        }
        observer {}
        layout { view { observer 0 }}
        canvas
        {
            layout 0
            wall
            {
                bottom_left  [ 0.0 0.0 -1 ]
                bottom_right [ 4.0 0.0 -1 ]
                top_left     [ 0.0 3.0 -1 ]
            }
            segment { channel "render1left"  viewport [ 0.0 0.0 0.5 1.0 ] }
            segment { channel "render1right" viewport [ 0.0 0.0 0.5 1.0 ] }
            segment { channel "render2left"  viewport [ 0.5 0.0 0.5 1.0 ] }
            segment { channel "render2right" viewport [ 0.5 0.0 0.5 1.0 ] }
            segment { channel "control"      viewport [ 0.0 0.0 1.0 1.0 ] }
        }
        compound
        {
            compound { eye [ LEFT  ] channel ( view 0 segment 0 ) swapbarrier {} }
            compound { eye [ RIGHT ] channel ( view 0 segment 1 ) swapbarrier {} }
            compound { eye [ LEFT  ] channel ( view 0 segment 2 ) swapbarrier {} }
            compound { eye [ RIGHT ] channel ( view 0 segment 3 ) swapbarrier {} }
            compound {               channel ( view 0 segment 4 ) swapbarrier {} }
        }
    }
}
@end verbatim
@end example

@subheading Non-planar Displays

The @option{-o equalizer-3d} mode allows to set up arbitrary-oriented screens
using either the wall-based or projection-based 3D frustum descriptions.

In this example we set up two 16:10 displays side-by-side which have been
rotated around their Z axis by 1.3 degrees radians (~74 degrees).  The image
@uref{multi-display-rotated.jpg,@code{multi-display-rotated.jpg}} illustrates
this setup. Other setups include distortion-correct projection for curved
screens, or arbitrarily-placed screens in a 3D space.

First, we rotate a normally-aligned screen by 1.3 degrees and output the
result:

@example
eq::Matrix4f matrix(eq::Matrix4f::IDENTITY);
matrix.rotate(1.3f, eq::Vector3f::FORWARD);
wall.bottomLeft = matrix * wall.bottomLeft;
wall.bottomRight = matrix * wall.bottomRight;
wall.topLeft = matrix * wall.topLeft;
std::cout << wall << std::endl;
@end example

yields a rotated screen centered on the origin:

@example
bottom_left  [   -0.69578     0.6371         -1 ]
bottom_right [   -0.26778    -0.9046         -1 ]
top_left     [    0.26778     0.9046         -1 ]
@end example

This screen has to be moved along the X-axis for the left and right screen by
0.5195m, which places the edges of the screen on the origin. The resulting
wall descriptions are used for the left and right segment, as shown in the
configuration below.

The configuration references two GPUs full-screen output. By changing the node
resource section, the outputs may be mapped to two computers. When disabling
the fullscreen mode and setting 'device 0' for the second pipe, two windows
simulate this setup on a single machine.

@example
@verbatim
global
{
    EQ_WINDOW_IATTR_HINT_FULLSCREEN ON
}

server
{
    config
    {
        appNode
        {
            pipe
            {
                device 0
                window
                {
                    viewport [ .215 .5 .4 .4 ]
                    channel { name "channel1" }
                }
            }
            pipe
            {
                device 1
                window
                {
                    viewport [ .285 .1 .4 .4 ]
                    attributes{ hint_drawable window }
                    channel { name "channel2" }
                }
            }
        }

        layout { view{ }}
        canvas
        {
            layout   0

            segment
            {
                channel  "channel1"
                wall
                {
                    bottom_left  [   -1.21528     0.6371         -1 ]
                    bottom_right [   -0.78728    -0.9046         -1 ]
                    top_left     [   -0.25172     0.9046         -1 ]
                }
            }
            segment
            {
                channel  "channel2"
                wall
                {
                    bottom_left  [   -0.17628     0.6371         -1 ]
                    bottom_right [    0.25172    -0.9046         -1 ]
                    top_left     [    0.78728     0.9046         -1 ]
                }
            }
        }

        compound
        {
            compound
            {
                channel ( segment 0 )
                swapbarrier{}
            }
            compound
            {
                channel ( segment 1 )
                swapbarrier{}
            }
        }
    }
}
@end verbatim
@end example


@node Interactive Control
@chapter Interactive Control

@section Keyboard Shortcuts

Bino reacts on a number of keyboard shortcuts during playback.

The following shortcuts are recognized:
@table @kbd
@item ESC
Leave fullscreen mode, or quit when in window mode.
@item q
Quit.
@item p
@item SPACE
Pause / unpause.
@item f
Toggle fullscreen.
@item c
Center window.
@item e
@item F7
Swap left/right eye.
@item v
Cycle through available video streams.
@item a
Cycle through available audio streams.
@item s
Cycle through available subtitle streams.
@item 1, 2
Adjust contrast.
@item 3, 4
Adjust brightness.
@item 5, 6
Adjust hue.
@item 7, 8
Adjust saturation.
@item [, ]
Adjust parallax.
@item (, )
Adjust ghostbusting.
@item <, >
Adjust zoom for videos that are wider than the screen.
@item /, *
Adjust audio volume.
@item m
Toggle audio mute.
@item .
Step a single video frame forward.
@item LEFT, RIGHT
Seek 10 seconds backward / forward.
@item DOWN, UP
Seek 1 minute backward / forward.
@item PAGE DOWN, PAGE UP
Seek 10 minutes backward / forward.
@item Mouse click
Seek according to the horizontal click position.
@item "Media Keys"
Media keys (if available) should work as expected.
@end table

@section Remote Controls

Bino supports remote controls via @url{http://www.lirc.org/,LIRC}.

Use the client name @samp{bino} in your LIRC configuration. The default LIRC
configuration file usually is @code{~/.lircrc}. You can use the
@samp{--lirc-config} option to use one or more custom LIRC configuration files
instead.

The available commands are the same commands that are available for scripting.
@xref{Script Commands}.

Example LIRC configuration file excerpt:
@example
begin
  remote = ...
  button = ...
  prog   = bino
  config = adjust-brightness +0.05
end
@end example


@node Scripting
@chapter Scripting

Bino can read commands from one or multiple script files. Use the @samp{--read-commands}
option to specify script files.

Available script commands are listed below. @xref{Script Commands}.

A script file can be a standard text file, but it can also be a named pipe,
which allows other programs or scripts to submit commands to Bino as they see
fit.

@example
$ mkfifo ~/bino-command-fifo
$ bino --read-commands ~/bino-command-fifo &

$ echo 'set-contrast 0.1' > ~/bino-command-fifo
$ ...
@end example

Using the @samp{netcat} utility, this also works over the network.

@example
$ mkfifo ~/bino-command-fifo
$ bino --read-commands ~/bino-command-fifo &

$ nc -l 1234 > ~/bino-command-fifo &
$ telnet localhost 1234
set-contrast 0.1
...
@end example

Here is a simple example script file:
@example
# Play all videos in fullscreen mode.
toggle-fullscreen
# Open the first video.
open /path/to/video.webm
# Start playing.
play
# Wait until the video finishes before continuing this script.
wait stop
# Open a second video. This one has a space in its file name.
open /path/to/video%20file.webm
# Start playing.
play
# Immediately increase brightness.
adjust-brightness +0.1
# Immediately seek to 60 seconds within the video.
seek 60.0
# Let the video play for 30.0 seconds before continuing with this script.
wait 30.0
# Open a third video. This one has left and right view in separate files.
open /path/to/left.webm /path/to/right.webm
# Start playing.
play
@end example

This script is executed with the following command. The @samp{--no-gui} option
is not necessary, but prevents the GUI to remember the changed brightness
setting in future sessions.
@example
$ bino --read-commands /path/to/script.txt --no-gui
@end example

@section Script Commands
@anchor{Script Commands}

One script line defines exactly one script command.  Empty lines or lines
starting with the @samp{#} character are comment lines and define the
@samp{noop} command, which has no effect.

@table @samp
@item noop
This command has no effect.
@item quit
Quit the application.
@item wait @var{stop}|@var{seconds}
Wait until the currently playing video stops, or wait for the given number of seconds,
before processing more commands from this file, script, or FIFO.@*
(This command is not available for LIRC remote controls.)
@item open [@var{option}@dots{}] @var{file}@dots{}
Open the given files.@*
You can use percent-encoding to encode special characters.
See @url{http://en.wikipedia.org/wiki/Percent_encoding}.
Use this if the file names contain whitespace.@*
To open devices, the following options are available, analogous to the command
line options with the same name:
	@table @samp
	@item --device-type=@var{none}|@var{default}|@var{firewire}|@var{x11}
	@item --device-frame-size=@var{W}x@var{H}
	@item --device-frame-rate=@var{N}/@var{D}
	@item --device-format=@var{default}|@var{mjpeg}
	@end table
@item close
Close the currently opened input.
@item toggle-play
Toggle playback.
@item play
Start playback, or exit pause mode.
@item stop
Stop playback.
@item toggle-pause
Toggle pause mode.
@item pause
When playing, go into pause mode.
@item step
Single-step to the next video frame.
@item seek @var{delta}
Seek by the given number of seconds relative to the current position.  For
example -60.0 seeks backwards one minute, and +600.0 seeks forward ten minutes.
@item set-pos @var{pos}
Seek by setting an absolute position in the stream, with @var{pos} between 0 and
1. For example, to seek to the middle of the video, use 0.5.
@item set-audio-device @var{dev}
Set the audio device to the one with the given index.
@item set-quality @var{q}
Set rendering quality, from 0 (fastest) to 4 (best, default).
@item set-stereo-mode @var{mode}
Set the stereo mode. @xref{Supported Output Techniques}.
@item set-stereo-mode-swap @var{swap}
Set stereo mode left/right swap (on or off).
@item toggle-stereo-mode-swap
Toggle stereo mode left/right swap.
@item set-crosstalk @var{cr} @var{cg} @var{cb}
Set display crosstalk levels for red, green, and blue. Each value must be between 0 and 1.
@item set-fullscreen-screens @var{screens}
Set screens to use in fullscreen mode. The value is an integer in which bits
are set for each screen that should be used (screen 1 = lowest bit). The value
0 means the default screen.
@item set-fullscreen-flip-left @var{b}
Set fullscreen flip left (on or off).
@item set-fullscreen-flop-left@var{b}
Set fullscreen flop left (on or off).
@item set-fullscreen-flip-right @var{b}
Set fullscreen flip right (on or off).
@item set-fullscreen-flop-right @var{b}
Set fullscreen flop right (on or off).
@item set-fullscreen-inhibit-screensaver @var{b}
Set fullscreen inhibit screensaver (on or off).
@item set-fullscreen-3dr-sync @var{b}
Set fullscreen DLP@registeredsymbol{} 3-D Ready Sync (on or off).
@item set-contrast @var{value}
Set contrast to the given @var{value}, from -1 to +1.
@item adjust-contrast @var{delta}
Adjust contrast by adding @var{delta}, e.g. -0.05 or +0.05.
@item set-brightness @var{value}
Set brightness to the given @var{value}, from -1 to +1.
@item adjust-brightness @var{delta}
Adjust brightness by adding @var{delta}, e.g. -0.05 or +0.05.
@item set-hue @var{value}
Set hue to the given @var{value}, from -1 to +1.
@item adjust-hue @var{delta}
Adjust hue by adding @var{delta}, e.g. -0.05 or +0.05.
@item set-saturation @var{value}
Set saturation to the given @var{value}, from -1 to +1.
@item adjust-saturation @var{delta}
Adjust saturation by adding @var{delta}, e.g. -0.05 or +0.05.
@item set-zoom @var{value}
Set zoom to the given @var{value}, from 0 to 1.
@item adjust-zoom @var{delta}
Adjust zoom by adding @var{delta}, e.g. -0.05 or +0.05.
@item set-loop-mode @var{mode}
Set loop mode to @samp{off} or @samp{current}.
@item set-audio-delay @var{seconds}
Set audio delay.
@item set-subtitle-encoding @var{enc}
Set subtitle encoding. An empty value means to use the default.
@item set-subtitle-font @var{font}
Set subtitle font. An empty value means to use the default.
@item set-subtitle-size @var{size}
Set the subtitle font size. The value is an integer, e.g. 12.
Use -1 to keep the default size.
@item set-subtitle-color @var{color}
Set the subtitle color as an integer that represents an RGB color.
Use a value larger than UINT32_MAX to keep the default color.
@item set-subtitle-shadow @var{mode}
Set subtitle shadow to force-on (1), force-off (0), or default (-1).
@item set-video-stream @var{stream}
Set video stream. Stream numbers start with 0.
@item cycle-video-stream
Cycle through available video streams.
@item set-audio-stream @var{stream}
Set audio stream. Stream numbers start with 0.
@item cycle-audio-stream
Cycle through available audio streams.
@item set-subtitle-stream @var{stream}
Set subtitle stream. Stream numbers start with 0. Using -1 disables subtitles.
@item cycle-subtitle-stream
Cycle through available subtitle streams.
@item set-stereo-layout @var{layout}
Set stereo layout. @xref{Supported Input Layouts}. Note that here only the
left first, right second modes are supported. To get the right first, left second
modes, use @samp{set-stereo-layout-swap}.
@item set-stereo-layout-swap @var{b}
Set stereo layout swap (on or off).
@item set-crop-aspect-ratio @var{ar}
Set crop aspect ratio, either as a floating point number (e.g. 1.78), or as a
ratio (e.g. 16:9).
@item set-parallax @var{value}
Set parallax, from -1 to +1.
@item adjust-parallax @var{delta}
Adjust parallax by adding @var{delta}, e.g. -0.05 or + 0.05.
@item set-ghostbust @var{value}
Set ghostbust, from -1 to +1.
@item adjust-ghostbust @var{delta}
Adjust ghostbust by adding @var{delta}, e.g. -0.05 or + 0.05.
@item set-subtitle-parallax @var{value}
Set subtitle parallax, from -1 to +1.
@item adjust-subtitle-parallax @var{delta}
Adjust subtitle parallax by adding @var{delta}, e.g. -0.05 or + 0.05.
@item toggle-fullscreen
Toggle fullscreen.
@item center
Center window.
@item set-audio-volume @var{value}
Set audio volume, from 0 to 1.
@item adjust-audio-volume @var{delta}
Adjust audio volume by adding @var{delta}, e.g. -0.05 or +0.05.
@item toggle-audio-mute
Toggle audio mute.
@end table


@node Camera Devices
@chapter Camera Devices

Bino supports the following types of camera devices:
@itemize
@item @var{default}: the system-specific default device type.@*
This is video4linux2 on GNU/Linux, bktr on BSD and Mac OS, and VfW on Windows.
This should work for all webcams and similar camera devices.
@item @var{firewire}: Firewire devices.
@item @var{x11}: X11-grabber pseudo devices.@*
This device type allows to capture part of an X11 screen as a video. It
requires the user to select a specific frame size and frame rate. The device
name is of the form
@code{[@var{hostname}]:@var{display}.@var{screen}[+@var{x},@var{y}]}. For example,
@code{smith:0.0+160,120} would capture from X11 display @code{:0.0} on host
@code{smith}, starting at position @code{160,120}.
@end itemize

Note: for @var{firewire} and @var{x11} devices to work, your FFmpeg libraries
must have @var{libdc1394} and @var{x11grab} support enabled.


@node Audio/Video Synchronization
@chapter Audio/Video Synchronization

Bino uses OpenGL to display video, and OpenGL unfortunately does not provide a
way to determine exactly when a frame will be visible on screen. On most systems,
a frame is displayed almost immediately, but some systems introduce a delay, and
this can cause notable audio/video synchronization errors.
This effect may be aggravated by compositing window managers. See
@url{http://savannah.nongnu.org/bugs/?35103,bug 35103} for more information.

You can check the audio/video synchronization on your system using the file
@uref{audio-video-sync.mp4,@code{audio-video-sync.mp4}} (created 
on 12/18/2011 by @url{http://www.schristiancollins.com,S. Christian Collins}).
It contains a few bright flashes accompanied by "tick" sounds. The flashes and
the sounds should be exactly in sync.

If they are not, you can adjust an audio delay that compensates for the video
delay. Increase audio delay (e.g. in steps of 50 milliseconds) and replay the
test video until audio and video are synchronized.


@node Performance Tweaking
@chapter Performance Tweaking

Bino should be able to play most video files on a computer with reasonable CPU and graphics power.

If Bino cannot play a video fast enough, it drops frames. Audio continues to
play, but video begins to stutter or even to stop completely.

This can have to two causes: either your CPU cannot decode the video fast
enough, or your graphics card cannot render the video fast enough.

In the first case, there is currently not much you can do.

In the second case, try the following to improve performance:
@enumerate
@item Reduce the quality setting as far as necessary.
@item Use a lower-quality anaglyph mode instead of the high-quality Dubois mode.
@item Avoid color adjustments: set the contrast, brightness, hue, and saturation adjustments to 0.
@item Avoid ghostbusting: set the ghostbusting parameter to 0.
@item Disable subtitles.
@end enumerate

@bye
