Author Topic: How to save TAGs to a ongoing encoding file (vorbis comment)  (Read 64 times)

mkllc

  • Posts: 44
Hi, I'm encoding a file using BASS_Encode_OGG_Start and writing some tags using the command line options --title --artist... and process it thru a special ENCODERPROC opening output file by hand. Everything works as expected. But prior to stopping the recording and closing the file I want to update or add some tags. For example a vorbis comment with the final date time recording or a string with a list of all songs played during the recording. I don't see any facility on the BASS lib to write this tags on the vorbis comment data. There is any way to append it? Even if it ends at the end of the file (while not interfere with the audio data). I don't mind if I need to read that data in a special way, but I want to save it along with the same file as audio data.

Can someone give me some pointers? I checked the TAGS helper library but seems it's only for reading. I'm in C++ btw.

Thanks!

Ian @ un4seen

  • Administrator
  • Posts: 23980
The tags need to be at the start of the OGG file, so it isn't possible to set/change them once the encoding has started. You would need to add them after the encoding is finished. BASS/BASSenc don't include tag modification features but you could use the vorbiscomment tool (part of the vorbis-tools package) to do it, or this other tagging library:

   www.un4seen.com/forum/?topic=15754

mkllc

  • Posts: 44
Maybe the best way then is to finish the encoding, close the file, open again and copy the first vorbis packet, modify the second one with the new comments and copying the third an ongoing packets of the stream. Should be easier and more portable than messing with external libraries and also I can reuse existing logic to deal with special file access features (like special block devices or network mounted ones in *nix) as I do in ENCODERPROC. Maybe this can sound a bit drastic and not super efficient but seems an start.

Thanks for the tips, and don't forget to add tag editing feature in the future! ;)

Ian @ un4seen

  • Administrator
  • Posts: 23980
Yes, if you're familiar with the OGG file structure then you could indeed add the tags yourself (you could check the vorbiscomment source code for ideas). Note that because OGG doesn't have support for reserving space (like some tag formats do), you will need to shift the rest of the file to make space for the new tags. That means writing a new file rather than just modifying the existing file. Or loading the entire file to memory, and rewriting it with modifications.