robinst / taglib-ruby

Ruby interface for the TagLib C++ library, for reading and writing meta-data (tags) of many audio formats
https://robinst.github.io/taglib-ruby/
MIT License
256 stars 26 forks source link

Saving corrupts some Ogg Vorbis files #82

Open jangler opened 6 years ago

jangler commented 6 years ago

This doesn't happen with all Ogg Vorbis files, but it does with these two that someone else provided: https://github.com/jangler/taffy/files/1844917/files.zip

In irb:

require 'taglib'
=> true
TagLib::FileRef.open('filename.ogg') do |fileref|
  fileref.save
end
=> true

Afterward, ffprobe says filename.ogg: End of file, soxi says soxi FAIL formats: can't open input file 'filename.ogg': Input not an Ogg Vorbis audio stream, and mpv says Failed to recognize file format..

jacobvosmaer commented 6 years ago

This looks like a taglib problem, I can reproduce it at that level.

#include <iostream>
#include <taglib/fileref.h>

int main(int argc, char **argv) {
  if (argc != 2) {
    std::cout << "usage: " << argv[0] << " file.ogg" << std::endl;
    exit(1);
  }

  const char *filename = argv[1];

  TagLib::FileRef file(filename);

  std::cerr << "saving " << filename << " with taglib." << std::endl;

  if (!file.save()) {
    std::cerr << "file save failed" << std::endl;
    exit(1);
  }
}

@jangler I don't think this has anything to do with taglib-ruby. I can reproduce your error by compiling the file above with TagLib 1.11 (MacPorts) and running it on one of your OGG files.

jangler commented 6 years ago

I suspected that might be the case, but I've never used TagLib itself so I reported the issue here. But I would say that this does have a good deal to do with taglib-ruby, since taglib-ruby currently propogates this serious bug and does not in any way document it. There's no telling when the bug will be fixed in TagLib itself (which has not been updated in four months despite many open PRs) or when the fixed version of TagLib will become available in various package manager repos, so it's possible for taglib-ruby to intervene in the interim, if the developers so desire.

jangler commented 6 years ago

I will open an issue for this in the TagLib issue tracker, since it doesn't look like one currently exists.

Edit: Here it is: https://github.com/taglib/taglib/issues/864

jacobvosmaer commented 6 years ago

Thanks for posting an issue upstream @jangler.

robinst commented 6 years ago

so it's possible for taglib-ruby to intervene in the interim, if the developers so desire

I don't think we have a good way to do that, except for not allowing to save ogg files at all.. Open for ideas though.

robinst commented 5 months ago

Looks like the upstream issue has been resolved, I think we can close this now?