0
votes

I am building an iOS app to cast video content from DLNA/UPnP media server to Chromecast. The problem appears when I add media track data for the captions. The following works:

### Media Manager - LOAD: {
"type":"load",
"I":false,
"defaultPrevented":false,
"kb":true,
"data":
{
    "currentTime":0,
    "requestId":3,
    "autoplay":true,
    "media":
    {
        "metadata":
        {
            "title":"movie.mp4",
            "subtitle":"Unknown",
            "images":
            [{
                "url":"http://192.168.1.15:8895/resource/625/COVER_IMAGE",
                "width":200,
                "height":100
            }],
            "metadataType":0
        },
        "textTrackStyle":
        {
            "windowRoundedCornerRadius":8,
            "windowType":"ROUNDED_CORNERS",
            "foregroundColor":"#FFFFFFFF",
            "fontFamily":"Helvetica",
            "fontGenericFamily":"SANS_SERIF",
            "fontStyle":"BOLD",
            "fontScale":1,
            "windowColor":"#000000FF",
            "backgroundColor":"#000000FF"
        },
        "contentId":"http://192.168.1.15:8895/resource/338/MEDIA_ITEM/AVC_MP4_MP_SD_AAC_MULT5-0/ORIGINAL",
        "contentType":"video/mp4",
        "streamType":"NONE",
        "duration":0
    }
},
"senderId":"33:3EA56D16-D18E-4D13-87A0-717DC188F8AF"}

but when I add captions either my own or for instance from CastVideos sample app (so to make sure it is CORS enabled), it won't work with:

### Media Manager - LOAD: {
"type":"load",
"I":false,
"defaultPrevented":false,
"kb":true,
"data":
{
    "currentTime":0,
    "requestId":4,
    "autoplay":true,
    "media":
    {
        "tracks":
        [{
            "trackId":1,
            "trackContentId":"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/GoogleIO-2014-CastingToTheFuture2-en.vtt",
            "language":"en-US",
            "subtype":"CAPTIONS",
            "type":"TEXT",
            "trackContentType":"text/vtt",
            "name":"English Subtitle"
        }],
        "contentId":"http://192.168.1.15:8895/resource/338/MEDIA_ITEM/AVC_MP4_MP_SD_AAC_MULT5-0/ORIGINAL",
        "streamType":"NONE",
        "contentType":"video/mp4",
        "duration":0,
        "metadata":
        {
            "title":"movie.mp4",
            "subtitle":"Unknown",
            "images":
            [{
                "url":"http://192.168.1.15:8895/resource/625/COVER_IMAGE",
                "width":200,
                "height":100
            }],
            "metadataType":0
        },
        "textTrackStyle":
        {
            "windowRoundedCornerRadius":8,
            "windowType":"ROUNDED_CORNERS",
            "foregroundColor":"#FFFFFFFF",
            "fontFamily":"Helvetica",
            "fontGenericFamily":
            "SANS_SERIF",
            "fontStyle":"BOLD",
            "fontScale":1,
            "windowColor":
            "#000000FF",
            "backgroundColor":"#000000FF"
        }
    }
},
"senderId":"11:9D7D43C2-CD85-4143-82AA-2D0056AA62FC" }

I get:

[cast.receiver.MediaManager] Load metadata error cast_receiver.js:18 

However the Sample app works with captions in my custom receiver without any problems and I don't find much of a difference (except for the video/image http URL, I'm just getting warnings for those):

### Media Manager - LOAD: {
"type":"load",
"I":false,
"defaultPrevented":false,
"kb":true,
"data":
{
    "currentTime":0,
    "requestId":3,
    "autoplay":true,
    "media":
    {
        "tracks":
        [{
            "trackId":1,
            "trackContentId":"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/DesigningForGoogleCast-en.vtt",
            "language":"en-US",
            "subtype":"CAPTIONS",
            "type":"TEXT",
            "trackContentType":"text/vtt",
            "name":"English Subtitle"
        }],
        "contentId":"https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/DesigningForGoogleCast.mp4",
        "streamType":"NONE",
        "contentType":"video/mp4",
        "duration":0,
        "metadata":
        {
            "title":"Designing For Google Cast",
            "subtitle":"Google IO - 2014",
            "images":
            [{
                "url":"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images_480x270/DesigningForGoogleCast2-480x270.jpg",
                "width":200,
                "height":100
            }],
            "metadataType":0
        },
        "textTrackStyle":
        {
            "windowRoundedCornerRadius":8,
            "windowType":"ROUNDED_CORNERS",
            "foregroundColor":"#FFFFFFFF",
            "fontFamily":"Helvetica",
            "fontGenericFamily":"SANS_SERIF",
            "fontStyle":"BOLD",
            "fontScale":1,
            "windowColor":"#000000FF",
            "backgroundColor":"#000000FF"
        }
    }
},
"senderId":"46:F162E34A-1A6D-4C0C-A0A3-DB584C92CDF5" }

any idea?

thanks in advance.

1
When you say it doesn't work, what does that mean? Note that when you add captions, CORS becomes a requirement not only for the caption but also for your video stream (even if it is non-adaptive, like mp4). You need to explain the issue you are seeing and the log from console, etc.Ali Naddaf
It doesn't work means it can not load and the cast is interrupted. It is most probably because the video stream is not CORS enabled. How can I get a more detailed error on media load? Currently "Load metadata error" from the JS lib is just too brief. The video stream (mp4) is hosted or available in the network from the media server, e.g. Serviio. Is there a workaround for this? Since i want to translate the subtitles and hang them on another server, so it will be cross server. I cannot add the subtitles to the media server. When having captions/subtitles CORS is always required?videlov
If you turn on logging on receiver, you should be able to see CORS error and more info on errors. I think you mentioned that the same setup (i.e. your receiver + your captions) work if you point your video stream to the ones from our sample (since that has CORS headers), am I correct? You can also verify whether your stream has CORS or not (say, use curl -v ...)Ali Naddaf
Thanks for the help so far. Ok the problem is identified. The media server (e.g. Serviio) providing the video doesn't support CORS. Using the a sample-app video and my translated subtitles on another server (having CORS) work together. Is there any workaround I can use for video from http server that doesn't support CORS and having captions in Chromecast or there is nothing I can do?videlov
If you have the capability to run a local server inside your LAN, you may consider running a proxy server so everything goes through your proxy server and in there, you can add the CORS headers. Outside of that, there is not much you can do.Ali Naddaf

1 Answers

1
votes

When using captions with Chromecast, CORS is required not only for the captions but for the video stream as well. In my case the video HTTP server (e.g. Serviio) doesn't support it.