<div>
    <h5>FFMPEG Settings
        
        <button class="pull-right btn btn-sm btn-success" style="margin-left: 5px;" ng-click="updateSettings(settings)">
            Update
        </button>
        <button class="pull-right btn btn-sm btn-warning" ng-click="resetSettings(settings)">
            Reset Options
        </button>
    </h5>
    <h6>FFMPEG Executable Path (eg: C:\ffmpeg\bin\ffmpeg.exe || /usr/bin/ffmpeg)</h6>
    <input type="text" class="form-control form-control-sm" ria-describedby="ffmpegHelp" ng-model="settings.ffmpegPath"></input>
    <small id="ffmpegHelp" class="form-text text-muted">FFMPEG version 4.2+ required. Check by opening the version tab</small>
    <hr></hr>
    <h6>Miscellaneous Options</h6>
    <div class="row">
        <div class="col-sm-4">
            <div class="form-group">
                <div class="form-group">
                    <label>Threads</label>
                    <input type="number" class="form-control form-control-sm" ng-model="settings.threads"></input>
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label>Logging</label>
                <br>
                <input id="logFfmpeg" type="checkbox" ng-model="settings.logFfmpeg"></input>
                <label for="logFfmpeg">Log FFMPEG to console</label>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-6">
            <div class="form-group">
                <label>Video Buffer</label>
                <select ng-model="settings.concatMuxDelay" ria-describedby="concatMuxDelayHelp"
                    ng-options="o.id as o.description for o in muxDelayOptions" ></select>
                <small id="concatMuxDelayHelp" class="form-text text-muted">Note: If you experience playback issues upon stream start, try increasing this.</small>
            </div>
        </div>
    </div>
    <hr></hr>
    <h6>Transcoding Features</h6>
    <div class="row">
        <div class="col-sm-9">
            <input id=enableFFMPEGTranscoding" type="checkbox" ng-model="settings.enableFFMPEGTranscoding"  ></input>
            <label for="enableFFMPEGTranscoding">Enable FFMPEG Transcoding</label>
            <small class="form-text text-muted">Transcoding is required for some features like channel overlay and measures to prevent issues when switching episodes. The trade-off is quality loss and additional computing resource requirements.
            </small>
        </div>
    </div>
    <br ></br>

    <div class="form-group" ng-hide="isTranscodingNotNeeded()" >

        <div class="row">
            <div class="col-sm-9">
                <label>Preferred Resolution</label>
                <select ng-model="settings.targetResolution" ria-describedby="concatMuxDelayHelp" ng-options="o.id as o.description for o in resolutionOptions" ></select>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-4">
                <label>Video Encoder</label>
                <input type="text" class="form-control form-control-sm" ng-model="settings.videoEncoder" ria-describedby="videoEncoderHelp"></input>
                <small id="videoEncoderHelp" class="form-text text-muted">Some possible values are:</small>
                <small id="videoEncoderHelp" class="form-text text-muted">h264 with Intel Quick Sync: h264_qsv</small>
                <small id="videoEncoderHelp" class="form-text text-muted">MPEG2 with Intel Quick Sync: mpeg2_qsv</small>
                <small id="videoEncoderHelp" class="form-text text-muted">NVIDIA: h264_nvenc</small>
                <small id="videoEncoderHelp" class="form-text text-muted">MPEG2: mpeg2video (default)</small>
                <small id="videoEncoderHelp" class="form-text text-muted">H264: libx264</small>
                <small id="videoEncoderHelp" class="form-text text-muted">MacOS: h264_videotoolbox</small>
            </div>
            <div class="col-sm-1" ></div>
            <div class="col-sm-4">
                <label>Audio Encoder</label>
                <input type="text" class="form-control form-control-sm" ng-model="settings.audioEncoder" ria-describedby="audioEncoderHelp"></input>
                <small id="audioEncoderHelp" class="form-text text-muted">Some possible values are:</small>
                <small id="audioEncoderHelp" class="form-text text-muted">aac</small>
                <small id="audioEncoderHelp" class="form-text text-muted">ac3 (default), ac3_fixed</small>
                <small id="audioEncoderHelp" class="form-text text-muted">flac</small>
                <small id="audioEncoderHelp" class="form-text text-muted">libmp3lame</small>
            </div>
        </div>
        <br ></br>
        <div class="form-group">
            <label>Video Bitrate (k)</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.videoBitrate"></input>
            <br ></br>
            <label>Video Buffer Size (k)</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.videoBufSize"></input>
            <br ></br>
            <label>Max Frame Rate</label>
            <select class='form-control custom-select'  ng-model="settings.maxFPS" ria-describedby="fpsHelp"
            ng-options="o.id as o.description for o in fpsOptions" ></select>
            <small id='fpsHelp' class='form-text text-muted'>Will transcode videos that have FPS higher than this.</small>

            <br ></br>
            <label>Scaling Algorithm</label>
            <select class='form-control custom-select'  ng-model="settings.scalingAlgorithm" ria-describedby="scalingHelp"
            ng-options="o.id as o.description for o in scalingOptions" ></select>
            <small id='scalingHelp' class='form-text text-muted'>Scaling algorithm to use when the transcoder needs to change the video size.</small>

            <br ></br>
            <label>Deinterlace Filter</label>
            <select class='form-control custom-select'  ng-model="settings.deinterlaceFilter" ria-describedby="deinterlaceHelp"
            ng-options="o.value as o.description for o in deinterlaceOptions" ></select>
            <small id='deinterlaceHelp' class='form-text text-muted'>Deinterlace filter to use when video is interlaced. This is only needed when Plex transcoding is not used.</small>
        </div>

        <div class="form-group">
            <label>Audio Bitrate (k)</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.audioBitrate"></input>
            <br ></br>
            <label>Audio Buffer Size (k)</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.audioBufSize"></input>
            <br ></br>
            <label>Audio Volume (%)</label>
            <input type="number" ria-describedby="volumeHelp" class="form-control form-control-sm" ng-model="settings.audioVolumePercent"></input>
            <small id="volumeHelp" class="form-text text-muted">Values higher than 100 will boost the audio.</small>
            <br ></br>
            <label>Audio Channels</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.audioChannels"></input>
            <br ></br>
            <label>Audio Sample Rate (k)</label>
            <input type="number" class="form-control form-control-sm" ng-model="settings.audioSampleRate"></input>
        </div>


        <div class="form-group">
            <div>
                <label>Error Screen:</label>
                <select ng-model="settings.errorScreen" ria-describedby="errorHelp"
                    ng-options="o.value as o.description for o in errorScreens" ></select>
                <label>Audio:</label>
                <select ng-model="settings.errorAudio" ria-describedby="errorHelp"
                    ng-options="o.value as o.description for o in errorAudios" ></select>
            </div>

            <small id="errorHelp" class="form-text text-muted">If there are issues playing a video, dizqueTV will try to use an error screen as a placeholder while retrying loading the video every 60 seconds.</small>
        </div>


        <div class="row">
            <div class="col-sm-9">
                <div class="form-group">
                    <input id="enableNormalizeResolution" type="checkbox" ng-model="settings.normalizeResolution" ng-disabled="isTranscodingNotNeeded()" ></input>
                    <label for="enableNormalizeResolution">Normalize Resolution</label>
                    <small class="form-text text-muted">Some clients experience issues when the video stream changes resolution. This option will make dizqueTV convert all videos to the preferred resolution selected above. Otherwise, the preferred resolution will be used as a maximum resolution for transcoding.
                    </small>
                </div>
            </div>
        </div>

        <br ></br>
        <div class="row">
            <div class="col-sm-9">
                <div class="form-group row">
                    <div class="col-sm-4">
                        <input id="enableNormalizeVideoCodec" type="checkbox" ng-model="settings.normalizeVideoCodec" ng-disabled="isTranscodingNotNeeded()" ></input>
                        <label for="enableNormalizeVideoCodec">Normalize Video Codec</label>
                    </div>
                    <div class="col-sm-4">
                        <input id="enableNormalizeAudioCodec" type="checkbox" ng-model="settings.normalizeAudioCodec" ng-disabled="isTranscodingNotNeeded()" ></input>
                        <label for="enableNormalizeAudioCodec">Normalize Audio Codec</label>
                    </div>
                </div>
                <small class="form-text text-muted">Some clients experience issues when the stream's codecs change.  Enable these so that any videos with different codecs than the ones specified above are forcefully transcoded.
                </small>
            </div>
        </div>

        <br ></br>
        <div class="row">
            <div class="col-sm-9">
                <div class="form-group">
                    <input id="enableAlignAudio" type="checkbox" ng-model="settings.normalizeAudio" ng-disabled="isTranscodingNotNeeded()" ></input>
                    <label for="enableAlignAudio">Normalize Audio</label>
                    <small class="form-text text-muted">This will force the preferred number of audio channels and sample rate, in addition it will align the lengths of the audio and video channels. This will prevent audio-related episode transition issues in many clients. Audio will always be transcoded.
                    </small>
                </div>
            </div>
        </div>

        <br ></br>
        <div class="row">
            <div class="col-sm-9">
                <div class="form-group">
                    <input id="disableOverlay" type="checkbox" ng-model="settings.disableChannelOverlay" ng-disabled="isTranscodingNotNeeded()" ></input>
                    <label for="disableOverlay">Disable Channel Watermark Globally</label>
                    <small class="form-text text-muted">Toggling this option will disable channel watermarks regardless of channel settings.
                    </small>
                </div>
            </div>
        </div>

    </div>



</div>
