will1971 / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

Add true gapless playback support to Chromecast Audio #745

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago

Chromecast Audio would really benefit of proper gapless audio playback.

By gapless playback, I mean that a gapless album such as "Pink Floyd - Dark 
dide of the moon" plays seamlessly without any gap between tracks.

True gapless support imply no gap nor audible glitch at track transitions, as 
if you played the audio CD.

Chromecast can currently get close to gapless, but there is still (at best) a 
small audible gap, thus it is not gapless.

After some research it seems true gapless support is held back by html5 audio 
capabilities, which makes it either difficult or impossible.

However, Chromecast Audio really deserves true gapless playback, to really be 
best in class and for users listening to gapless albums as they are intended. 

So it would be great that the Google Cast investigate a proper way to do it, 
from which apps could benefit without much more effort than providing to the 
receiver the next track after the current playing track.

Gapless playback should work with inherent gapless formats such as FLAC, WAV, 
AAC in mp4, and ideally with MP3 + lame tag.

Original issue reported on code.google.com by pujos.mi...@gmail.com on 27 Jan 2016 at 2:32

GoogleCodeExporter commented 8 years ago
I tried the Gapless-5 Javascript player, embedded in a Cast receiver 
(https://github.com/regosen/Gapless-5).
This player achieves gapless via a combination of html5 audio and Web Audio, 
mostly a hack.

I was full of hope when it played the 2 Synth short samples (a few seconds 
each) of the demo page. perfectly gapless, with looping. 

Unfortunately when I tried to play 2 real gapless music tracks of several 
minutes each (WAV or FLAC but this doesn't matter), the Chromecast started 
playing the first track...then crashed after 20s or so.

I suppose this is due to the amount of memory needed, that just make it crash 
at some point. I suppose malloc failed during the Web Audio decoding of the 
second track, and then kaboom. And this was a Chromecast 2 model, supposedly 
with more memory.

So if as a developer you had in mind trying Gapless-5 for playing music 
gaplessly, don't, it will not work. It works for small samples though.

So gapless on Chromecast will remain no joy for a while it seems...

Original comment by pujos.mi...@gmail.com on 29 Jan 2016 at 9:41

GoogleCodeExporter commented 8 years ago
True Gapless playback in Chromecast is almost essential when listening to 
classical music where longer pieces of continuous music are often split into 
separate tracks and gaps then become very annoying and make the music 
un-listenable. Gapless should be introduced in a way that makes it easy for 
application writers to support/invoke it

Original comment by martin.b...@gmail.com on 2 Feb 2016 at 6:18

GoogleCodeExporter commented 8 years ago
There is "false" gapless that relies on very short network latencies and that 
is random. 
Real gapless relies on the receiver asking the server for next track before the 
end of current track. This implies playlist handling on the receiver side and 
buffering. 
Same issue for upnp renderers when they do not handle playlists and do not use 
SetNextUri for requesting next track before the current tracks ends. 
You can still have gaps if you have very short tracks of some seconds. But this 
works for a majority of albums.

Kind regards 

Original comment by thierry....@gmail.com on 8 Feb 2016 at 11:52

GoogleCodeExporter commented 8 years ago
Looking at this further - and bearing in mind I am an end user with an IT 
background and not a developer - it appears that the cast API supports creating 
a media queue and for "adaptive streams" the API supports a preloadVideo so for 
Video at least this concept is supported. See 
https://developers.google.com/cast/docs/autoplay. What is needed is to extend 
this to Audio so at least there can be a preLoad of the buffer for the next 
item in the queue and this should be part of the standard receiver logic

Original comment by martin.b...@gmail.com on 10 Feb 2016 at 2:21

GoogleCodeExporter commented 8 years ago
@pujos, could you please let us know which Android app was used for testing 
gapless streaming. Also, could you check casting the same stream from latest 
Google play music app and let us know the result. 

When you reply please give us below information
Chromecast Audio Firmware version, Android apps tested for streaming and Google 
Play Music app version.

Original comment by vinot...@google.com on 11 Feb 2016 at 2:27

GoogleCodeExporter commented 8 years ago
@5  

CCA: 1.17a.49061
Google Play Music: 6.3.2317V.2583329

Proof that Google Play Music is not gapless: play "Code Indigo - From Whom The 
Bell" 
(https://play.google.com/music/listen#/album/Brgdojue3kkw65zkn3u77oourb4//For+Wh
om+The+Bell). There will be short (< 100ms) audible gaps between each tracks .

However, testing gapless with mp3 in Play Music is pointless as mp3 is 
inherently not gapless because of padding, unless having the mp3 decoder making 
use of LAME extra data. 

If you research true gapless playback of WAV and FLAC using html5, it seems to 
have been overlooked by whoever designed html5. The only solution that works in 
desktop web browsers is the Gapless-5 Javascript Library: 
https://github.com/regosen/Gapless-5

Quoting them:

"
PROBLEM: There are 2 modern API's for playing audio through the web, and both 
of them have problems:

    HTML5 Audio: the last chunk of audio gets cut off, making gapless transitions impossible
    WebAudio: can't play a file until it's fully loaded

SOLUTION: Use both!

    If WebAudio hasn't fully loaded yet, it begins playback with HTML5 Audio, then seamlessly switches to WebAudio once loaded.
    NOTE: Most mobile browsers don't fully support HTML5 Audio objects in js, so we're stuck with only WebAudio in that case.
" 

The problem is that this solution requires lot of memory, and it crashes on the 
CCA while it works perfectly fine in desktop web browser. A cool example of 
true gapless working with html5 is this site, using the Gapless-5 library: 
http://relisten.net/gapless

I do not have a ready to use receiver app + Android app featuring Gapless-5, 
but you can make the CCA reboot with a simple receiver autoplaying 2 tracks 
(track1.wav, track2.wav) gaplessly:

<!DOCTYPE HTML>
<html>
<head>
...
<link href="gapless5.css" rel="stylesheet" type="text/css" />
  <script src="//code.jquery.com/jquery-1.10.2.min.js" language="JavaScript" type="text/javascript"></script>
  <script src="gapless5.js" language="JavaScript" type="text/javascript"></script>

</head>
<body>

    <div id="gapless5-block" />
    <script>
...

    player = new Gapless5('gapless5-block',
               { tracks: ["track1.wav", "track2.wav"],
            playOnLoad: true });
...    

    </script>
</body>
</html>

Original comment by pujos.mi...@gmail.com on 11 Feb 2016 at 10:17

GoogleCodeExporter commented 8 years ago
Hi Vinot

I am using BubbnleUPNP as an Android App - this is a very popular
application for playing music and video - it does not provide gapless with
Chromecast but does with DNLA. See the following from the developer
https://hydrogenaud.io/index.php?PHPSESSID=jrummpfhuqs34587lhjenkqat4&topic=1101
58.msg908991#msg908991
.
If Chromecast does support gapless audio for FLAC and WAV files &c it would
be great if there was a clear guide on how to achieve this.

Original comment by martin.b...@gmail.com on 11 Feb 2016 at 5:09

GoogleCodeExporter commented 8 years ago
Bubbleupnp does not and cannot provide gapless to a non gapless dlna renderer. 
Gapless is a question between the audio player and audio server.
Kind regards 

Original comment by thierry....@gmail.com on 11 Feb 2016 at 5:19

GoogleCodeExporter commented 8 years ago
Yes I agree that bubbleupnp cannot play gapless to a non gapless dnla player. 
The question I would like to understand is whether it is possible for 
developers of applications like bubbleupnp to cast gaplessly to Chromecast and 
if so how?

Original comment by martin.b...@gmail.com on 11 Feb 2016 at 6:24

GoogleCodeExporter commented 8 years ago
We are looking in to the request and update here soon.

Original comment by vinot...@google.com on 11 Feb 2016 at 8:41

GoogleCodeExporter commented 8 years ago

Original comment by vinot...@google.com on 12 Feb 2016 at 4:56

GoogleCodeExporter commented 8 years ago
Surprised so few have commented on this. I had high hopes for CCA and have 
played around with a number of servers and control apps and have resigned 
myself to the same conclusion. I would indeed have added a CCA to every music 
player in my house however this really is a dealbreaker and not currently an 
option for me. I look forward to hearing if a solution can be found. 

Original comment by colin9ri...@gmail.com on 12 Feb 2016 at 9:15

GoogleCodeExporter commented 8 years ago
Agreed about this. I have already starred the issue, but want to chime in 
anyway. A music player that introduces a gap is more of a bug than a request 
for enhancement. My chromecast does everything the right way, except for music 
gaps (I'm using the standard 2015 chromecast, not the audio version). I'm 
planning on purchasing half a dozen of these things as soon as gaps are fixed. 
In the meantime I'm stuck with the Raspberry Pi:s. 

Original comment by jonathan...@gmail.com on 13 Feb 2016 at 12:58

GoogleCodeExporter commented 8 years ago
Please, we really need the chromecast to handle correctly the gapless playback

Original comment by olivier....@gmail.com on 18 Feb 2016 at 5:35

GoogleCodeExporter commented 8 years ago
Any update on this issue ?

Original comment by slapau...@gmail.com on 27 Feb 2016 at 12:08

TheCakeGit commented 7 years ago

For the love of god please support gapless in chromecast :) :) :) There seems to be lots of requests all over the internet and just a dead end for FLAC/WAV... Thanks x

dutspark commented 6 years ago

I got the app "Hi-Fi Cast" from the playstore and tested gapless "Pink Floyd - Dark side of the moon" and it works great. In "Settings>Chromecast>Chromecast gapless playback" you can turn on/off this feature. Same feature is available in " Settings>UPnP/DLNA"

I hope BubbleUPnP will also enable this feature because it is my favorite app.