erikas-taroza / audiotags

Read and write audio metadata in Flutter. Supports multiple formats.
https://pub.dev/packages/audiotags
MIT License
11 stars 7 forks source link

Mpeg: File contains an invalid frame #17

Open IwanPWK opened 6 months ago

IwanPWK commented 6 months ago

When I try to read MP3 files, there are some files that cause errors when reading and writing metadata.

E/flutter ( 3182): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: AudioTagsError.openFile(message: Mpeg: File contains an invalid frame)
E/flutter ( 3182): #0      FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:126:9)
E/flutter ( 3182): #1      FlutterRustBridgeBase.executeNormal.<anonymous closure> (package:flutter_rust_bridge/src/basic.dart:70:51)
E/flutter ( 3182): <asynchronous suspension>
E/flutter ( 3182): #2      AudioTags.write (package:audiotags/src/audiotags.dart:36:12)
E/flutter ( 3182): <asynchronous suspension>
erikas-taroza commented 6 months ago

Hello.

What version are you on? Could you also send the file so I can debug?

Thank you.

IwanPWK commented 6 months ago

Sorry for the late reply.

  1. I am using the latest version.
  2. Here are the files in question.

https://drive.google.com/file/d/1gctXakHorNaBHn2vGTFmltSv4vv-kQ9O/view?usp=drivesdk https://drive.google.com/file/d/1gZHmC0o7JX-5j5AVO9P5yuQfltvJBuO8/view?usp=drivesdk

thank you in advance

xenSlayer commented 4 months ago

any update?

erikas-taroza commented 4 months ago

Hello. Sorry, I got busy and forgot about this problem. I have tested both of these files in the example project and they can be read and written to fine. Can you please provide the code you used so I can try to replicate?

joec05 commented 4 months ago

I'm also getting the same error in some of my audio files. I'm getting this error AudioTagsError.openFile(message: Mpeg: File contains an invalid frame).

I tried testing the audio in the example project and I'm getting this instead. File path:[com.mr.flutter.plugin.filepicker.FileInfo@c9defd7] E/flutter ( 3548): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: AudioTagsError.openFile(message: No format could be determined from the provided file) E/flutter ( 3548): #0 FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:126:9) E/flutter ( 3548): #1 FlutterRustBridgeBase.executeNormal.<anonymous closure> (package:flutter_rust_bridge/src/basic.dart:70:51)

Here is my code:

Future<AudioMetadataInfoClass?> fetchAudioMetadata(String audioUrl) async{
    Tag? tag = await AudioTags.read(audioUrl);
    if(tag == null) {
      return null;
    }

    return AudioMetadataInfoClass(
      audioUrl.split('/').last, 
      tag.title,
      tag.trackArtist,
      tag.album,
      tag.albumArtist,
      tag.pictures.isEmpty ? null : tag.pictures.first.bytes
    );
  }

And here are the files in question: https://filebin.net/ae5jcrg3ducoei7s/Nocturne.mp3 https://filebin.net/ae5jcrg3ducoei7s/Photograph.mp3

Could you try to reproduce it and see what is exactly the issue? Thank you in advance.

erikas-taroza commented 4 months ago

@joec05 I have tried both files and I didn't get an error. Could you try downloading the audio from the url you sent and try reading that file?

joec05 commented 4 months ago

I've tried that. Unfortunately it returns the same error message. This is what is shown on the console:

I/flutter ( 7519): /storage/emulated/0/Music/Nocturne.mp3 AudioTagsError.openFile(message: Mpeg: File contains an invalid frame)
I/flutter ( 7519): /storage/emulated/0/Music/Photograph.mp3 AudioTagsError.openFile(message: Mpeg: File contains an invalid frame)

The code I used was just as simple as this Tag? tag = await AudioTags.read(path);, but it shouldn't be the issue I guess since it worked for some audio files. I tried using a music player app and both of these files' metadata were successfully read.

Could you show me what was displayed in your console when you extracted their metadata? Also, are you still using the example project to test these audio files?

erikas-taroza commented 4 months ago

Yes I tested in the example project. When reading the fresh file, all the metadata was printed as null (empty tag). I wrote metadata and reread the file and it printed the correct metadata. Are you on v1.9.0 as well?

joec05 commented 4 months ago

Indeed the tags are empty in these audio files. I wrapped the read metadata code with a try-catch and unfortunately the error above was printed. It didn't even return null. Does the version 1.9.0 even exist? I checked the pub.dev site and the latest version is 1.4.0.

erikas-taroza commented 4 months ago

Sorry, I meant v1.4.0, 1.9.0 was from a different project. I am not sure what is causing you to have the error and not me. Can you try building the Rust binary yourself and seeing if that would work? You should be able to build it by running python plugin_tool.py -b platform in the root directory of the project.