Matthieu Regnauld
2018-Nov-03 12:32 UTC
[Vorbis-dev] Decode ogg file while downloading: what are the good practices?
Thanks for your answer. But as I said, I don't have any problem seeking in a local file. Also, I have full control on the ogg file I play, since I encode it by myself. I first would like to know if the code I provided ( https://gist.github.com/mregnauld/3f7cdc43b02ec3bbd91641b9333ba072) is good practice when it comes to extracting and seeking in a file that is being downloaded. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/vorbis-dev/attachments/20181103/9a0faf18/attachment.html>
Matthieu Regnauld
2018-Nov-03 14:40 UTC
[Vorbis-dev] Decode ogg file while downloading: what are the good practices?
I tried to call ov_open_callbacks(audioFile, &vorbisFile, NULL, 0, OV_CALLBACKS_NOCLOSE) before calling ov_pcm_seek() but the ov_pcm_seek() returns OV_EINVAL every time. The idea behind that was to update vorbisFile. Is there a way I can update vorbisFile so I can seek to the desired position? Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/vorbis-dev/attachments/20181103/e2672e1f/attachment.html>
Ralph Giles
2018-Nov-03 17:20 UTC
[Vorbis-dev] Decode ogg file while downloading: what are the good practices?
On 2018-11-03 05:32 AM, Matthieu Regnauld wrote:> I first would like to know if the code I provided > (https://gist.github.com/mregnauld/3f7cdc43b02ec3bbd91641b9333ba072) is > good practice when it comes to extracting and seeking in a file that is > being downloaded.You didn't share many details of how your code fails, but one idea: libvorbisfile builds a seek table from the available data when you call 'ov_open' so it probably isn't able to find data that is after the section which was available when that call was made. Does it work if you call OggPlayer::release; OggPlayer::open; before OggPlayer::seek? The library uses bisection to efficiently find the target data, so it needs to be able to read the beginning and end of the file to get bracketing timestamps. If you don't need accurate seeking, you could use ov_raw_seek instead, which goes by byte offset in the compressed data. Pass in your own seek/tell callback functions to inform the library about the true file length known from the HTTP header. If you need accurate seeking, I think you're stuck with re-opening the file, or implementing your own seeking layer which accounts for your use case. You said you control both the server and the player. Have you considered using the newer Opus codec? It performs better, especially in constrained network environments, and the opusfile library implements seeking directly over http for network resources. https://mf4.xiph.org/jenkins/view/opus/job/opusfile-unix/ws/doc/html/index.html HTH, -r
Matthieu Regnauld
2018-Nov-03 21:18 UTC
[Vorbis-dev] Decode ogg file while downloading: what are the good practices?
Well, your " OggPlayer::release; OggPlayer::open; before OggPlayer::seek" seems to work! Thank you so much! Also, I'll take a look at the Opus codec, thanks for the advice! For your information, here was the problem in details: let's say I download an audio file whose length is 300 seconds. When, for example, 15 seconds of the file were downloaded, I called OggPlayer::open(). After that moment, even if the file was fully downloaded, I was able to seek in the file, but only between 0 and 15 seconds (whether I use ov_pcm_seek() or even ov_raw_seek()). So yes, that makes sence if libvorbisfile builds a seek table only when opening the file. That said, isn't there any function that allows to rebuild that seek table? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/vorbis-dev/attachments/20181103/23d1763e/attachment.html>
Possibly Parallel Threads
- Decode ogg file while downloading: what are the good practices?
- Decode ogg file while downloading: what are the good practices?
- Decode ogg file while downloading: what are the good practices?
- Decode ogg file while downloading: what are the good practices?
- Decode ogg file while downloading: what are the good practices?