17

The problem

I made a receiver application that is just showing a video in loop on the Chromecast. The problem is that the Chromecast doesn't seems to be caching the video in it's cache. So the video keeps getting downloaded every time it finishes a loop and it takes a lot of bandwidth. The video will be hosted on external server so the Chromecast will have to download it from internet every time (I cannot change that spec).

Just for you know, when debugging the receiver application on a desktop chrome application, the video is cached by the browser, so the problem doesn't seems to come from http responses for the caching behaviour.

A solution I explored

I tried to download the video file in ajax and play it. The problem is the Chromecast seems to crash when my Javascript tries to read the responseText field of the xhr when the result has more than 28MB (I tried with a 50MB file (it crashed) and a 28MB file (it didn't crash), the limit could actually be 32MB).

EDIT: I also tried this example and it also makes the chromecast crash...

The question

Is it possible to cache a video of 50-100MB on the Chromecast and prevent it from downloading it every time or is there a memory trick I could be doing to store that video in the Chromecast memory? Loading the video once per application use would be my target result to reduce bandwidth usage.

  • why can't you stream it in a loop from your phone..? why does the file has to be on the internet? – vsync Aug 03 '14 at 00:01
  • Does anyone know the device storage size limit and memory size of Chromecast? I tried looking up some details to answer this but couldn't find any concrete info. – Steve Aug 07 '14 at 12:22
  • You might want to go a different direction. Its like you need to add the external source, via a queue, to a local media stream device or some type of proxy. Then Chromecast reads it from your local stream device. I found https://play.google.com/store/apps/details?id=com.bubblesoft.android.bubbleupnp which looks pretty interesting. – Steve Aug 07 '14 at 12:31
  • @vsync I could download the file from local source, but this solution "add" a constraint to my solution (having a local server serving the file). I would like to know if I can avoid this type of constraint. – Pierre-Luc Champigny Aug 07 '14 at 15:23
  • @Steve I also tried to find information about the Chromecast specs, and most of the information is for end users... For your other comment, it's one solution, but like I said to vsync, it add a constraint to my system and I would like to avoid that, if possible of course :P – Pierre-Luc Champigny Aug 07 '14 at 15:27
  • Just so you know, you can analyze the logs from your crash. See http://stackoverflow.com/q/22491574/2479481 – Luke Willis Aug 07 '14 at 16:49
  • @Steve According to [IFixit's Teardown](https://www.ifixit.com/Teardown/Chromecast+Teardown/16069), the chromecast has 2 GB of flash memory and 512 MB of RAM. I don't know how much of this is available for developers to utilize. – Luke Willis Aug 07 '14 at 17:07
  • I'm sure this won't be any new information, but take a look at [Google's video looping demo app](https://github.com/googlecast/CastVideoLooping-receiver). – Luke Willis Aug 07 '14 at 17:39

3 Answers3

4

I'm a bit unsure about this answer because I find it a bit too obvious. But I'll give it a try:

You said you had no trouble with a setup where you download 28MB via ajax. Why don't you cut it down even further? You could for example go with 4MB. I'm suggesting this because it may alleviate problems arising from "bursts" of computation as you for example mentioned with reading the responseText field of the xhr object.

After you decided on an appropriate chunk size you could use https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-p5-range-22#section-3 to download your video in parts and then concatenate it in javascript according to your needs. See also Download file in chunks in Chrome Javascript API?

If you have access to the server you could also split the file on the server side such that you can send requests from the client like so:

example.com/movies/my_movie.mp4?chunk=1
Community
  • 1
  • 1
ben
  • 5,671
  • 4
  • 27
  • 55
  • 1
    I've already tried this approach (I downloaded twice the file just to see if it was a "burst" problem) and it still exploded on the second 28MB file. So the problem seems to be related to the global memory and not to a single file memory usage, thanks anyway for the idea :D – Pierre-Luc Champigny Aug 07 '14 at 15:16
2

Try using an Application Cache manifest file to ensure that the file is only downloaded once:

<html manifest="some.manifest">

where some.manifest has the contents:

CACHE MANIFEST
# version 1.0
the_video_to_cache.webm

This will ensure that future HTTP requests for the resource will not cause download. The video will only re-download when the manifest file changes (so you can change the #-prefixed comment string to cause a re-download). Note that the new version will be shown on first page load after the download completes. After an update, the user will see an out-of-date video one time (while the new version downloads) and then see the new version on the next visit.

Note that this may not work if your video is larger that the permitted size of the app cache.

apsillers
  • 112,806
  • 17
  • 235
  • 239
0

I'm don't have chromecast, and not sure. Is it possible to use experimental features, like Quota Management API? This API, could add some extra memory for you stored data, may be you should try to use it.

DAiMor
  • 3,185
  • 16
  • 24