

    <div class="col-lg-4 col-md-4">
        <h3 class="list-heading">Audio Encoding</h3>
        {# TODO: Add pagination #}
        All media files contain a number of <span class="sbold">streams</span>. If a file contains audio, that audio information is written in on of these streams.
        <br>
        It is also not uncommon for a media file to contain more than one audio stream.
        <br>
        <br>
        This audio information is compressed in a standard format called a <span class="sbold">codec</span>.
        <br>
        Different codecs have different capabilities such as supporting multiple channels (eg. surround sound), how many of those channels it can contain, or how much audio data is lost when it is compressed.
        <br>
        <br>
        You may wish to standardise the audio codec streams of your files to better suit your needs.
        <br>
        <br>
        In order to compress an audio stream into a particular codec, we need to use an audio <span class="sbold">encoder</span>. Unmanic currently does not support advanced audio encoder features, so only one option is available per codec.
        <br>
        <hr/>
        If <span class="sbold">`Enable Audio Encoding`</span> is not selected, all audio streams from the source file will be copied through to the output file without the codec being modified.
        <br>
        <br>
        If you select <span class="sbold">`Enable Audio Encoding`</span>, two configuration sections will be available to you.
        <br>
        <br>
        <span class="bold">TRANSCODE ALL AUDIO STREAMS</span>:
        <br>
        If <span class="sbold">`Enable Audio Stream Transcoding`</span> is not selected, audio streams will be copied through to the output file without the codec being modified.
        <br>
        <br>
        Selecting the <span class="sbold">`Enable Audio Stream Transcoding`</span> checkbox will give you the option to transcode your audio streams to a standard audio codec.
        <br>
        <br>
        Use the <span class="sbold">`Audio Codec`</span> drop-down to choose which codec the audio streams will be encoded into.
        <br>
        <br>
        Once you have selected a <span class="sbold">`Audio Codec`</span> drop-down, you may also select an encoder using the <span class="sbold">`Audio Encoder`</span> drop-down.
        <br>
        <br>
        <span class="bold">CREATE A STEREO CLONE OF STREAMS</span>:
        <br>
        If <span class="sbold">`Enable Audio Stream Cloning`</span> is not selected, no clones of the file's audio streams will be created.
        <br>
        <br>
        Selecting the <span class="sbold">`Enable Audio Stream Cloning`</span> checkbox will give you the option to to create a stereo clone all multi-channel audio streams. This is helpful for playback compatibility on devices that do not support multi-channel audio.
        <br>
        <br>
        Use the <span class="sbold">`Bitrate`</span> drop-down, to select how much audio data should be encoded. A higher value will encode more audio data and better quality audio, but will increase the size of the audio stream.
    </div>
    <div class="col-lg-6 col-md-8">
        <!-- BEGIN FORM PORTLET-->
        <div class="portlet light bordered">
            <div class="portlet-body form">
                <form class="form-horizontal" role="form" method="POST">
                    <div class="form-body">

                        {# Enable/Disable settings on this screen #}
                        <div class="form-group">
                            <label class="col-md-3 control-label">Enable Audio Encoding</label>
                            <div class="col-md-9">
                                <div class="checkbox-list">
                                    <input type="hidden" name="ENABLE_AUDIO_ENCODING" id="ENABLE_AUDIO_ENCODING"
                                           value="{% if config.get_enable_audio_encoding() %}true{% end %}">
                                    <label>
                                        <input type="checkbox" id="audio_encoding_enabled"
                                               onchange="toggleEnableAudioEncoding();"
                                               {% if config.get_enable_audio_encoding() %} checked {% end %} />
                                    </label>
                                </div>
                            </div>
                        </div>
                        <hr/>

                        <div class="audio_encoding_settings_disabled_notice {% if config.get_enable_audio_encoding() %}hidden{% end %}">
                            <div class="note note-info caption">
                                <span class="caption-subject font-dark sbold uppercase">Audio streams will be copied</span>
                                <br>
                                <span class="help-inline">
                                    All audio streams will be copied to the destination file without being modified.
                                </span>
                            </div>
                            <hr/>
                        </div>

                        <div class="audio_encoding_settings {% if not config.get_enable_audio_encoding() %}hidden{% end %}">

                            {# Transcoding audio streams #}
                            <div class="caption">
                                <span class="caption-subject font-dark sbold uppercase">Transcode all audio streams</span>
                                <br>
                                <span class="help-inline">
                                    Modify the audio stream codec. Channel count and bitrate are kept the same as the source.
                                </span>
                            </div>
                            <br>
                            <div class="form-group">
                                <label class="col-md-3 control-label">Enable Audio Stream Transcoding</label>
                                <div class="col-md-9">
                                    <div class="checkbox-list">
                                        <input type="hidden" name="ENABLE_AUDIO_STREAM_TRANSCODING"
                                               id="ENABLE_AUDIO_STREAM_TRANSCODING"
                                               value="{% if config.get_enable_audio_stream_transcoding() %}true{% end %}">
                                        <label>
                                            <input type="checkbox"
                                                   id="audio_stream_transcoding_enabled"
                                                   onchange="toggleEnableAudioStreamTrascoding();"
                                                    {% if config.get_enable_audio_stream_transcoding() %} checked {% end %} />
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <br>
                            <div class="audio_stream_transcoding_settings_disabled_notice {% if config.get_enable_audio_stream_transcoding() %}hidden{% end %}">
                                <div class="note note-info caption">
                                    <span class="caption-subject font-dark sbold uppercase">Audio streams will be copied</span>
                                    <br>
                                    <span class="help-inline">
                                        All audio streams will be copied to the destination file without being modified.
                                    </span>
                                </div>
                            </div>
                            <div class="audio_stream_transcoding_settings {% if not config.get_enable_audio_stream_transcoding() %}hidden{% end %}">
                                <div class="form-group">
                                    <label class="col-md-3 control-label">Audio Codec</label>
                                    <div class="col-md-9">
                                        <select class="form-control"
                                                id="AUDIO_CODEC"
                                                name="AUDIO_CODEC"
                                                onchange="setAudioStreamEncoderListForTranscoding();">
                                            {% set supported_audio_codecs = config.get_supported_audio_codecs() %}
                                            {% for option in supported_audio_codecs %}
                                            <option value="{{ escape(option) }}" {% if option == config.get_config_item('audio_codec') %}
                                                    selected {% end %}>
                                                {{ escape(supported_audio_codecs[option]['description']) }}
                                            </option>
                                            {% end %}
                                        </select>
                                        <span class="help-inline"> Select the output audio codec </span>
                                    </div>
                                </div>
                                <br>
                                {# If there is only one option, disable this field #}
                                <div class="form-group" id="audio_stream_encoder_selection">
                                    {% include "audio_stream_encoder.html" %}
                                </div>
                            </div>

                            <hr/>

                            {# Cloning audio streams #}
                            <div class="caption">
                                <span class="caption-subject font-dark sbold uppercase">Create a stereo clone of streams</span>
                                <br>
                                <span class="help-inline">
                                    Create a stereo clone of all audio streams if the original stream is more than 2 channels.
                                    If the source file already has a stereo stream, this is ignored and no clone is generated.
                                </span>
                            </div>
                            <br>
                            <div class="form-group">
                                <label class="col-md-3 control-label">Enable Audio Stream Cloning</label>
                                <div class="col-md-9">
                                    <div class="checkbox-list">
                                        <input type="hidden" name="ENABLE_AUDIO_STREAM_STEREO_CLONING"
                                               id="ENABLE_AUDIO_STREAM_STEREO_CLONING"
                                               value="{% if config.get_enable_audio_stream_stereo_cloning() %}true{% end %}">
                                        <label>
                                            <input type="checkbox"
                                                   id="audio_stream_stereo_cloning_enabled"
                                                   onchange="toggleEnableAudioStreamStereoCloning();"
                                                    {% if config.get_enable_audio_stream_stereo_cloning() %} checked {% end %} />
                                        </label>
                                    </div>
                                </div>
                            </div>
                            <br>
                            <div class="audio_stream_stereo_cloning_settings_disabled_notice {% if config.get_enable_audio_stream_stereo_cloning() %}hidden{% end %}">
                                <div class="note note-info caption">
                                    <span class="caption-subject font-dark sbold uppercase">Multi-channel audio streams will not be cloned</span>
                                    <br>
                                    <span class="help-inline">
                                        No stereo clones of multi-channel audio streams will be created.
                                    </span>
                                </div>
                            </div>
                            <div class="audio_stream_stereo_cloning_settings {% if not config.get_enable_audio_stream_stereo_cloning() %}hidden{% end %}">
                                <div class="form-group">
                                    <label class="col-md-3 control-label">Audio Codec</label>
                                    <div class="col-md-9">
                                        <select class="form-control"
                                                id="AUDIO_CODEC_CLONING"
                                                name="AUDIO_CODEC_CLONING"
                                                onchange="setAudioStreamEncoderListForCloning();">
                                            {% set supported_audio_codecs = config.get_supported_audio_codecs() %}
                                            {% for option in supported_audio_codecs %}
                                            <option value="{{ escape(option) }}" {% if option == config.get_audio_codec_cloning() %}
                                                    selected {% end %}>
                                                {{ escape(supported_audio_codecs[option]['description']) }}
                                            </option>
                                            {% end %}
                                        </select>
                                        <span class="help-inline"> Select the output audio codec </span>
                                    </div>
                                </div>
                                <br>
                                <div class="form-group" id="audio_stream_encoder_cloning_selection">
                                    {% include "audio_stream_encoder_cloning.html" %}
                                </div>
                                <div class="form-group">
                                    <label class="col-md-3 control-label">Bitrate</label>
                                    <div class="col-md-9">
                                        <select class="form-control" name="AUDIO_STEREO_STREAM_BITRATE">
                                            {# TODO: Move this array to the config class #}
                                            {% for option in ['128k','160k','192k','256k','320k'] %}
                                            <option value="{{ escape(option) }}" {% if option == config.get_audio_stereo_stream_bitrate() %}
                                                    selected {% end %}>
                                                {{ escape(option) }}
                                            </option>
                                            {% end %}
                                        </select>
                                        <span class="help-inline"> Select the bitrate for your stereo stream </span>
                                    </div>
                                </div>
                                {# TODO: Make the audio cloning capibility able to select the number of channels #}
                            </div>

                        </div>

                    </div>
                    <div class="form-actions">
                        <div class="row">
                            <div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn green">Submit</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <!-- END FORM PORTLET-->
    </div>
