Vitaly Zdanevich
2018-Nov-15 12:22 UTC
[ogg-dev] How to concatenate Ogg in the browser JS?
Thank you, ogginfo returned: ----- Note: Stream 1 has serial number 0, which is legal but may cause problems with some tools. New logical stream (#1, serial: 00000000): type vorbis Vorbis headers parsed for stream 1, information follows... Version: 0 Vendor: ffmpeg Channels: 1 Rate: 22050 Nominal bitrate: 35.333000 kb/s Upper bitrate not set Lower bitrate not set Vorbis stream 1: Total data length: 25835 bytes Playback length: 0m:06.338s Average bitrate: 32.606833 kb/s Logical stream 1 ended WARNING: illegally placed page(s) for logical stream 1 This indicates a corrupt Ogg file: Page found for stream after EOS flag. WARNING: sequence number gap in stream 1. Got page 1 when expecting page 27. Indicates missing data. ----- `Playback length` is incorrect here - this is the length of the first concatenated file, this file consists of multiple Oggs. So this is impossible to correctly concat Ogg with simple Javascript? 15.11.2018, 15:13, "Philipp Schafft" <phschafft at de.loewenfelsen.net>:> Good morning, > > On Thu, 2018-11-15 at 14:48 +0300, Vitaly Zdanevich wrote: >> Good day, no answers in Google about that. I asked >> https://stackoverflow.com/questions/53290693/how-to-alter-duration-of-ogg-with-js - in short I have Ogg Vorbis files on the client side (webapp) and I need to concatenate them in one file for downloading. I did concatenation with this line of code: >> >> const blob = new Blob(listOfChunksBlobs, {'type': 'audio/ogg'}); >> >> And I play the final audio in VLC without problem, > > Yes. If the files are valid Ogg (this does not depend on the used > codecs) you can just concatenate them. > >> BUT the length is incorrect, looks like I need to alter some header / >> metadata for that? Can you please guide me, maybe I need to alter some >> bytes as specific position? > > No. > Note that there is a different between the playback time of the file and > that of the tracks contained. Some software is not aware of that and > only display the track playback time OR the file playback time. > > If you want a file with a single track you must splice the data on the > codec level. This requires understanding of the codecs used as well as > completly rewriting the Container (Ogg). > > This will also require that there is no change in parameters (including > metadata). > > You can check your resulting file with e.g. ogginfo(1). It will tell you > the parameters for each track and also if the file has errors on the > container level. > > Generally I suspect that this is just a display problem in VLC. > > With best regards, > > -- > Philipp Schafft (CEO/Geschäftsführer) > Telephon: +49.3535 490 17 92 > > Löwenfelsen UG (haftungsbeschränkt) Registration number: > Bickinger Straße 21 HRB 12308 CB > 04916 Herzberg (Elster) VATIN/USt-ID: > Germany DE305133015
Good afternoon, On Thu, 2018-11-15 at 15:22 +0300, Vitaly Zdanevich wrote:> Thank you, ogginfo returned: > ----- > Note: Stream 1 has serial number 0, which is legal but may cause problems with some tools. > New logical stream (#1, serial: 00000000): type vorbis > Vorbis headers parsed for stream 1, information follows... > Version: 0 > Vendor: ffmpeg > Channels: 1 > Rate: 22050 > > Nominal bitrate: 35.333000 kb/s > Upper bitrate not set > Lower bitrate not set > Vorbis stream 1: > Total data length: 25835 bytes > Playback length: 0m:06.338s > Average bitrate: 32.606833 kb/s > Logical stream 1 ended > WARNING: illegally placed page(s) for logical stream 1 > This indicates a corrupt Ogg file: Page found for stream after EOS flag. > WARNING: sequence number gap in stream 1. Got page 1 when expecting page 27. Indicates missing data. > ----- > > `Playback length` is incorrect here - this is the length of the first concatenated file, this file consists of multiple Oggs. > > So this is impossible to correctly concat Ogg with simple Javascript?It is possible. See the warnings ogginfo returns: There are pages AFTER the EOS flag but not after a new BOS page. So your file looks like this: BOS DATA... EOS Data... However it should like like this: BOS Data... EOS BOS Data... EOS You can try to save your second part only and try to play that back. If it does not work the second part is invalid to begin with (this is what ogginfo indicates). A. With best regards,> 15.11.2018, 15:13, "Philipp Schafft" <phschafft at de.loewenfelsen.net>: > > Good morning, > > > > On Thu, 2018-11-15 at 14:48 +0300, Vitaly Zdanevich wrote: > >> Good day, no answers in Google about that. I asked > >> https://stackoverflow.com/questions/53290693/how-to-alter-duration-of-ogg-with-js - in short I have Ogg Vorbis files on the client side (webapp) and I need to concatenate them in one file for downloading. I did concatenation with this line of code: > >> > >> const blob = new Blob(listOfChunksBlobs, {'type': 'audio/ogg'}); > >> > >> And I play the final audio in VLC without problem, > > > > Yes. If the files are valid Ogg (this does not depend on the used > > codecs) you can just concatenate them. > > > >> BUT the length is incorrect, looks like I need to alter some header / > >> metadata for that? Can you please guide me, maybe I need to alter some > >> bytes as specific position? > > > > No. > > Note that there is a different between the playback time of the file and > > that of the tracks contained. Some software is not aware of that and > > only display the track playback time OR the file playback time. > > > > If you want a file with a single track you must splice the data on the > > codec level. This requires understanding of the codecs used as well as > > completly rewriting the Container (Ogg). > > > > This will also require that there is no change in parameters (including > > metadata). > > > > You can check your resulting file with e.g. ogginfo(1). It will tell you > > the parameters for each track and also if the file has errors on the > > container level. > > > > Generally I suspect that this is just a display problem in VLC. > > > > With best regards, > > > > -- > > Philipp Schafft (CEO/Geschäftsführer) > > Telephon: +49.3535 490 17 92 > > > > Löwenfelsen UG (haftungsbeschränkt) Registration number: > > Bickinger Straße 21 HRB 12308 CB > > 04916 Herzberg (Elster) VATIN/USt-ID: > > Germany DE305133015-- Philipp Schafft (CEO/Geschäftsführer) Telephon: +49.3535 490 17 92 Löwenfelsen UG (haftungsbeschränkt) Registration number: Bickinger Straße 21 HRB 12308 CB 04916 Herzberg (Elster) VATIN/USt-ID: Germany DE305133015 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 490 bytes Desc: This is a digitally signed message part URL: <http://lists.xiph.org/pipermail/ogg-dev/attachments/20181115/a457ad8f/attachment.sig>
Vitaly Zdanevich
2018-Nov-15 13:39 UTC
[ogg-dev] How to concatenate Ogg in the browser JS?
Checked right now - my original Ogg chunks is playable and without warnings on ogginfo. Can I fix headers or something after concat to have correct length in players? Not only VLC - if I open the same concated Ogg in Chrome I see the same length of the first chunk - but I can play full concated file without problem. 15.11.2018, 16:23, "Philipp Schafft" <phschafft at de.loewenfelsen.net>:> Good afternoon, > > On Thu, 2018-11-15 at 15:22 +0300, Vitaly Zdanevich wrote: >> Thank you, ogginfo returned: >> ----- >> Note: Stream 1 has serial number 0, which is legal but may cause problems with some tools. >> New logical stream (#1, serial: 00000000): type vorbis >> Vorbis headers parsed for stream 1, information follows... >> Version: 0 >> Vendor: ffmpeg >> Channels: 1 >> Rate: 22050 >> >> Nominal bitrate: 35.333000 kb/s >> Upper bitrate not set >> Lower bitrate not set >> Vorbis stream 1: >> Total data length: 25835 bytes >> Playback length: 0m:06.338s >> Average bitrate: 32.606833 kb/s >> Logical stream 1 ended >> WARNING: illegally placed page(s) for logical stream 1 >> This indicates a corrupt Ogg file: Page found for stream after EOS flag. >> WARNING: sequence number gap in stream 1. Got page 1 when expecting page 27. Indicates missing data. >> ----- >> >> `Playback length` is incorrect here - this is the length of the first concatenated file, this file consists of multiple Oggs. >> >> So this is impossible to correctly concat Ogg with simple Javascript? > > It is possible. > > See the warnings ogginfo returns: There are pages AFTER the EOS flag but > not after a new BOS page. > > So your file looks like this: > > BOS DATA... EOS Data... > > However it should like like this: > > BOS Data... EOS BOS Data... EOS > > You can try to save your second part only and try to play that back. If > it does not work the second part is invalid to begin with (this is what > ogginfo indicates). > > A. With best regards, > >> 15.11.2018, 15:13, "Philipp Schafft" <phschafft at de.loewenfelsen.net>: >> > Good morning, >> > >> > On Thu, 2018-11-15 at 14:48 +0300, Vitaly Zdanevich wrote: >> >> Good day, no answers in Google about that. I asked >> >> https://stackoverflow.com/questions/53290693/how-to-alter-duration-of-ogg-with-js - in short I have Ogg Vorbis files on the client side (webapp) and I need to concatenate them in one file for downloading. I did concatenation with this line of code: >> >> >> >> const blob = new Blob(listOfChunksBlobs, {'type': 'audio/ogg'}); >> >> >> >> And I play the final audio in VLC without problem, >> > >> > Yes. If the files are valid Ogg (this does not depend on the used >> > codecs) you can just concatenate them. >> > >> >> BUT the length is incorrect, looks like I need to alter some header / >> >> metadata for that? Can you please guide me, maybe I need to alter some >> >> bytes as specific position? >> > >> > No. >> > Note that there is a different between the playback time of the file and >> > that of the tracks contained. Some software is not aware of that and >> > only display the track playback time OR the file playback time. >> > >> > If you want a file with a single track you must splice the data on the >> > codec level. This requires understanding of the codecs used as well as >> > completly rewriting the Container (Ogg). >> > >> > This will also require that there is no change in parameters (including >> > metadata). >> > >> > You can check your resulting file with e.g. ogginfo(1). It will tell you >> > the parameters for each track and also if the file has errors on the >> > container level. >> > >> > Generally I suspect that this is just a display problem in VLC. >> > >> > With best regards, >> > >> > -- >> > Philipp Schafft (CEO/Geschäftsführer) >> > Telephon: +49.3535 490 17 92 >> > >> > Löwenfelsen UG (haftungsbeschränkt) Registration number: >> > Bickinger Straße 21 HRB 12308 CB >> > 04916 Herzberg (Elster) VATIN/USt-ID: >> > Germany DE305133015 > > -- > Philipp Schafft (CEO/Geschäftsführer) > Telephon: +49.3535 490 17 92 > > Löwenfelsen UG (haftungsbeschränkt) Registration number: > Bickinger Straße 21 HRB 12308 CB > 04916 Herzberg (Elster) VATIN/USt-ID: > Germany DE305133015
On 2018-11-15 4:22 a.m., Vitaly Zdanevich wrote:> Note: Stream 1 has serial number 0, which is legal but may cause problems with some tools.Note if *both* files have the same serial number, it's impossible to find the points where they were concatentated by bisection, and most tools will assume they've found all the sections and calculate an incorrect duration. They can still be played individually because there is not concatenation boundary to find in the individual case. If ogginfo shows the same serial (00000000) for both of your input streams, that's likely the problem. Muxers are supposed to use a random serial number to make conflicts unlikely. You can fix them by rewriting the serial number so there's no conflict. Basically, you change the serialno field in each ogg page header and then update the crc. If you want an example, I have a quick script for doing this in https://git.xiph.org/?p=rogg.git;a=blob;f=rogg_serial.c HTH, -r
Vitaly Zdanevich
2018-Nov-15 18:15 UTC
[ogg-dev] How to concatenate Ogg in the browser JS?
Yes, I found that serials of my Oggs is all zeros, thank you, I will try to alter serial. 15.11.2018, 19:39, "Ralph Giles" <giles at thaumas.net>:> On 2018-11-15 4:22 a.m., Vitaly Zdanevich wrote: > >> Note: Stream 1 has serial number 0, which is legal but may cause problems with some tools. > > Note if *both* files have the same serial number, it's impossible to > find the points where they were concatentated by bisection, and most > tools will assume they've found all the sections and calculate an > incorrect duration. They can still be played individually because there > is not concatenation boundary to find in the individual case. > > If ogginfo shows the same serial (00000000) for both of your input > streams, that's likely the problem. Muxers are supposed to use a random > serial number to make conflicts unlikely. You can fix them by rewriting > the serial number so there's no conflict. Basically, you change the > serialno field in each ogg page header and then update the crc. > > If you want an example, I have a quick script for doing this in > https://git.xiph.org/?p=rogg.git;a=blob;f=rogg_serial.c > > HTH, > -r