Decode ogg file while downloading: what are the good practices?
Matthieu Regnauld <[email protected]> Sat, 3 Nov 2018 12:55:24 +0100
| Newsgroups | gmane.comp.multimedia.ogg.vorbis.devel |
|---|---|
| Message-ID | <CADjM6tAshc-QqYCWHqpP8sWLtiX4KjABz0ERPbc3F5upz3tuEQ@mail.gmail.com> |
--===============1986084368647641794== Content-Type: multipart/alternative; boundary="0000000000006a1b870579c15461" --0000000000006a1b870579c15461 Content-Type: text/plain; charset="UTF-8" Hello, In my Android app, I implemented the libogg and libvorbis libraries, so I can extract audio samples from an ogg file on the fly. It works well when I extract samples from a local file, but my goal is to be able to extract audio samples and seek in a file that is downloading (so I can stream an audio file and process audio samples on the fly, from anywhere in the file). So here is the code I use, to extract audio samples from a downloading ogg file (I keep it simple so it's easy to read): https://gist.github.com/mregnauld/3f7cdc43b02ec3bbd91641b9333ba072 In that code, the oggFile is the file that I download (using Java code). So I start the download, and when there is some data available, I open the file, seek in the file, and extract audio samples from the desired position. And here is the problem: the ov_pcm_seek() function doesn't work properly most of the time, when I seek in a file that is currently downloading, even if I want to seek to a position that is already available (there is already data in that position). So, my question is: is it good practice or not? If not, how can I properly manage samples extraction and seeking in a downloading file? Thanks you very much for your help. --0000000000006a1b870579c15461 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Hello,<= div><br></div><div>In my Android app, I implemented the libogg and libvorbi= s libraries, so I can extract audio samples from an ogg file on the fly.</d= iv><div><br></div><div>It works well when I extract samples from a local fi= le, but my goal is to be able to extract audio samples and seek in a file t= hat is downloading (so I can stream an audio file and process audio samples= on the fly, from anywhere in the file).</div><div><br></div><div>So here i= s the code I use, to extract audio samples from a downloading ogg file (I k= eep it simple so it's easy to read):=C2=A0<a href=3D"https://gist.githu= b.com/mregnauld/3f7cdc43b02ec3bbd91641b9333ba072">https://gist.github.com/m= regnauld/3f7cdc43b02ec3bbd91641b9333ba072</a></div><div>In that code, the= =C2=A0<font face=3D"monospace, monospace">oggFile</font>=C2=A0 is the file = that I download (using Java code). So I start the download, and when there = is some data available, I open the file, seek in the file, and extract audi= o samples from the desired position.</div><div><br></div><div><div>And here= is the problem: the=C2=A0<font face=3D"monospace, monospace">ov_pcm_seek()= </font>=C2=A0function doesn't work properly most of the time, when I se= ek in a file that is currently downloading, even if I want to seek to a pos= ition that is already available (there is already data in that position).<b= r></div><br class=3D"gmail-Apple-interchange-newline"></div><div>So, my que= stion is: is it good practice or not? If not, how can I properly manage sam= ples extraction and seeking in a downloading file?</div><div><br></div><div= >Thanks you very much for your help.</div><div><br></div></div></div></div>= </div> --0000000000006a1b870579c15461-- --===============1986084368647641794== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVm9yYmlzLWRl diBtYWlsaW5nIGxpc3QKVm9yYmlzLWRldkB4aXBoLm9yZwpodHRwOi8vbGlzdHMueGlwaC5vcmcv bWFpbG1hbi9saXN0aW5mby92b3JiaXMtZGV2Cg== --===============1986084368647641794==--