#----------------------------------------------------------------------------
# Profile for Google Chromecast.
# See DefaultRenderer.conf for descriptions of all the available options.
# https://www.universalmediaserver.com/forum/viewtopic.php?f=5&t=1454
# Version 1.3
#
# Authors: DeFlanko, digitalhigh, Tripollite, Einzeln
#
# Known Issues:
# - Seeking support is limited.
# - This profile will override all generic android devices so it's disabled by default.
#   Setting LoadingPriority=1 will activate it (see below).
# Prerequisites
# - FFmpeg needs to be the primary (top) transcoder.
#

RendererName = Chromecast
RendererIcon = chromecast.png

# ============================================================================
# This renderer has sent the following string/s:
#
# User-Agent: Mozilla/5.0 (CrKey armv7l 1.3.14651) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.0 Safari/537.36, Referer: http://receiver.aviatheapp.com/
# User-Agent: Android/4.2.1 UPnP/1.0 Cling/2.0
# User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)
# ============================================================================
# https://developers.google.com/cast/docs/media

UserAgentSearch = Android|CrKey

# Note: Set loading priority to 1 to activate this configuration and override Android.conf
LoadingPriority = 1

SeekByTime = exclusive
TranscodeVideo = MPEGTS-H264-AC3
TranscodeAudio = MP3
MaxVideoBitrateMbps = 20
MimeTypesChanges = video/mpeg=video/mp4
CustomFFmpegOptions = -async 1 -fflags +genpts -c:a libmp3lame -ac 2 -b:v 35000k -bufsize 35000k -f matroska

# Supported video formats:
Supported = f:mp4    v:mp4|h264    a:aac-lc|he-aac|mp3                 n:2       m:video/mp4
Supported = f:mkv    v:mp4|h264    a:aac-lc|he-aac|mp3|opus|vorbis     n:2       m:video/webm

# Supported audio formats:
Supported = f:flac        n:2      m:audio/x-flac                                s:96000
Supported = f:mp3|mpa     n:2      m:audio/mp3
Supported = f:m4a         n:2      m:audio/mp4       a:aac-lc|he-aac|mp3
Supported = f:oga         n:2      m:audio/ogg       a:flac|opus|vorbis
Supported = f:wav         n:2      m:audio/x-wav     a:lpcm
Supported = f:weba        n:2      m:audio/webm      a:opus|vorbis

# Supported images formats:
Supported = f:bmp         m:image/bmp        w:1280     h:720
Supported = f:gif         m:image/gif        w:1280     h:720
Supported = f:jpg         m:image/jpeg       w:1280     h:720
Supported = f:png         m:image/png        w:1280     h:720
#Supported = f:webp        m:image/webp       w:1280     h:720

# Supported subtitles formats:
SupportedExternalSubtitlesFormats = WEBVTT

# Supported Media Type: https://developers.google.com/cast/docs/media
#	All Google Cast devices at a minimum support the following media types:
#		Video codecs: H.264 High Profile Level 4.1, 4.2 and 5, VP8
#		Audio decoding: HE-AAC, AAC-LC, CELT/Opus, MP3, Vorbis
#		Containers: MP4/CENC, WebM, MPEG-DASH, SmoothStreaming
#		Level 1 DRM support: Widevine, PlayReady

# This is the important part (thanks Einzeln):
#   (Make audio work)
#      -c:a = codec in this case we use libmp3lame for MP3 | libvo-aacenc for AAC-LC and -ac is limiting audio channels for casting.
#   (Prevent stutter due to slow connection)
#      -b:v and -bufsize should ensure the encoded video does not exceed a bitrate that can fit through a wifi connection.
#      These sometimes seem to be ignored in the same way MaxVideoBitrateMBPS does.
#   (output)
#      -f matroska, I know chromecast doesn't support mkv. But webm is basically a dumbed down mkv so this works.
#      Using mp4 has given me problems for some reason.