Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"undefined" error when attempting to seek #8

Open
kjantzer opened this issue May 20, 2013 · 24 comments
Open

"undefined" error when attempting to seek #8

kjantzer opened this issue May 20, 2013 · 24 comments

Comments

@kjantzer
Copy link

I have a flac player working using: AV.Player.fromURL
But, when I try to seek:
AV.Player.seek(0)

The console throws this error:
TypeError: Cannot read property 'offset' of undefined

Any ideas?

@devongovett
Copy link
Member

Yup, pretty sure seeking was never implemented for the FLAC demuxer.

@kjantzer
Copy link
Author

Ok, thanks.

@mattberkowitz
Copy link
Contributor

Hey @kjantzer, I added some limited SEEKTABLE support which might help you out a bit. You can find it in the SEEKTABLE branch of my fork (https://github.com/mattberkowitz/flac.js/tree/SEEKTABLE)

@osmestad
Copy link

Hi, I tried the fork from @mattberkowitz, but when I seek, playback starts about 10 seconds after the specified seek point. Has anyone had this problem?

Example:

  • Start playing Flac file
  • Seek: player.seek(10000); (Should seek to 10 seconds, but starts playback at about 20 seconds)

Or

  • Seek: player.seek(60000); (Should seek to 1 minute, but starts at 1:10)

@mattberkowitz
Copy link
Contributor

Hey @osmestad I just did a quick test on a file of mine where I tried to seek to the 2:00 mark of a track in both aurora and vlc and it matched up pretty well. The seeking is based on the SEEKTABLE stored in the flac file, which is basically a collection of times and associated frames, rather than real time calculation of the frame to seek to. When you execute a seek it will go to the nearest seekpoint, which depending on the frequency of points could be several seconds off. Does this sound like what might be causing your problem? You can both view the seekpoints stored in a given file, as well generate new ones using metaflac. Try generating one every 1s and see if that makes things better

@osmestad
Copy link

Thanks @mattberkowitz, if I add a seekpoint each second that seems to make it work properly. I guess I was unlucky with the sample Flac files I tested, I used the 16-bit ones from the bottom of this page: http://www.eclassical.com/pages/24-bit-faq.html , and some from http://www.bowers-wilkins.com/Downloads/downloads.html (requires registration).

@devongovett
Copy link
Member

@mattberkowitz can you send a pull request for your seek table support? I'd like to merge it in.

Also, I'd like to add sample accurate seeking to aurora.js at some point to avoid bad seek table issues. There should be a way to specify a range of accuracy within which to seek.

@master255
Copy link

Seeking work perfect, but if seek to near end of track (in this track and other) "player.player.seek (180352)" return TypeError: Cannot read property 'offset' of undefined

http://master255.no-ip.org/?file=/res/Музыка/B/Benny Benassi/Benny Benassi - Cinema (featuring Gary Go).flac

where get max seek time? And how to fix this problem???

@master255
Copy link

I try to correct aurora.js because it return wrong big index = 19:
index = this.searchTimestamp(timestamp);
if (index>=this.seekPoints.length) {index=this.seekPoints.length-1;}
return this.seekPoints[index];
and this correct error, but problem with end of this track not solved. Try open link to view problem.

@master255
Copy link

last seek point dont want play and player stoping at this moment.

@master255
Copy link

I win the problem, but my code not pretty very well. I add duration and buffered in asset.demuxer and add
index = this.searchTimestamp(timestamp);
do {if (index>0) {index=index-1;}} while ((((this.duration*(this.buffered/100))-(this.seekPoints[index].timestamp/this.format.sampleRate * 1000)) min 6000) && (index>0));
return this.seekPoints[index];
in seek function. Why 6000? I don't know...may be this will be a variable...
But this work perfect on many tracks of my collection.

@master255
Copy link

Final dirty code ))
do {if (index>0) {index=index-1;}} while ((((this.duration*(this.buffered/100))-(this.seekPoints[index].timestamp/this.format.sampleRate * 1000))<((this.buffered==100)?6000:10000)) && (index>0));

@enjikaka
Copy link

@osmestad @mattberkowitz

Is it possible to add seekpoints at every second with the AV.Demuxer? I've been trying to modify the SEEKTABLE-case but after each change the whole thing breaks...

@mattberkowitz
Copy link
Contributor

@enjikaka The seektable is processed after the header is available, generally at that point the entire file hasn't been loaded. In normal flac frame length can't be determined without decoding (see https://xiph.org/flac/faq.html#api__frame_length). It may be possible that you could decode each packet as it is retrieved and create seekpoints at that point, but I assume it would be pretty intensive. Also, it's been awhile since I've looked at the code and can't give much more direction without digging in. You can take a look at the metaflac (https://www.xiph.org/flac/documentation_tools_metaflac.html) source for the --add-seekpoint=#s option to see how they generate them

@enjikaka
Copy link

The new music service Tidal uses Aurora and Flac.js to play lossless audio. I wonder how they solved the seeking... :/ Seeking takes about 10 seconds so... maybe it's doing something serverside?

Tidal: http://listen.tidalhifi.com

@osmestad
Copy link

Actually we ended up using PNaCl and C code for our Flac decoding on Tidal :)

@enjikaka
Copy link

@osmestad Oh, so you are not using Aurora and FLAC.js at all then? (It's still in the source-code on the client anyway). Also, off topic now, any chance you guys could remove the "window.chrome"-detection for lossless streaming? It'd be nice if I could put Tidal in a <webview> in NW.js/electron-shell and have a desktop app for streaming losslessly. Or would that not work with the PNaCl-decoder solution?

Also, I found this. May I ask what it is? :)
http://i.imgur.com/5KwjKwH.png

@osmestad
Copy link

No we are not using Aurora any more, but there is still a reference to the files yes. For desktop usage it would require more than removing the window.chrome detection, but we are working on it :)

The screenshot shows integration with another product that we offer for professional users: http://pro.wimpmusic.com/

@enjikaka
Copy link

@osmestad Okay! Cool. Why did you choose not to use FLAC.js in the end? Was it because of the lack of support for seeking?

ChromeOS have native support for FLAC, just so you know. It can play FLACs in the <audio> element. :) Weird that the Chrome browser have not yet integrated support for FLAC-files too...

@osmestad
Copy link

We ended up with PNaCl to get the audio decoding in a separate process, that helped avoid audio glitches when a lot happens in the browser :)

@devongovett
Copy link
Member

Interesting feedback. We should revisit worker decoding in Aurora.js. See audiocogs/aurora.js#105.

@rsoltanzadeh
Copy link

I see that @mattberkowitz's seektable was merged, but I am still getting the same Uncaught TypeError: Cannot read property 'offset' of undefined when seeking. Am I missing something or was this never actually implemented?

@enjikaka
Copy link

enjikaka commented Feb 18, 2019 via email

@master255
Copy link

All major browsers support FLAC now so there is no need to use FLAC.js. :)

not. The built-in html5 player in browsers cannot play some tracks. Aurora can.
For example: http://master255.org/res/%d0%9c%d1%83%d0%b7%d1%8b%d0%ba%d0%b0/0-9/30%20Seconds%20to%20Mars/30%20Seconds%20to%20Mars%20-%20A%20Beautiful%20Lie.flac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants