I am currently recording a live stream and writing it to a file in flutter using bytearray and reading it as a stream and then writing it to a file using File.openWrite
and all is going well however I just realized I need to write some metadata to the file and I have no idea how to even go about that. I have done this once in Android using the ID3Tag library but I cannot seem to find anything similar to that in Flutter. Any help is appreciated. Thank you in advance as usual! I have tried using https://pub.dev/packages/audiotagger/
However, I keep running into this error and have no idea how to fix this. Checking further because the ID3 Tag ends at 0x00 but the mp3 audio doesn't start until 0x129
This is also part of the error:
W/System.err(20398): java.lang.NullPointerException: Attempt to invoke interface method 'void org.jaudiotagger.tag.Tag.setField(org.jaudiotagger.tag.FieldKey, java.lang.String[])' on a null object reference
W/System.err(20398): at com.nicolorebaioli.audiotagger.AudiotaggerPlugin$Util.setFieldIfExist(AudiotaggerPlugin.java:222)
W/System.err(20398): at com.nicolorebaioli.audiotagger.AudiotaggerPlugin.writeTags(AudiotaggerPlugin.java:92)
W/System.err(20398): at com.nicolorebaioli.audiotagger.AudiotaggerPlugin.onMethodCall(AudiotaggerPlugin.java:64)
W/System.err(20398): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
W/System.err(20398): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
W/System.err(20398): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
W/System.err(20398): at android.os.MessageQueue.nativePollOnce(Native Method)
W/System.err(20398): at android.os.MessageQueue.next(MessageQueue.java:326)
W/System.err(20398): at android.os.Looper.loop(Looper.java:160)
You will be able to do this by using the flutter ffmpeg library.
https://pub.dev/packages/flutter_ffmpeg/
Once you add this to your file use the code below to add the metadata to the file.
void ffmpegFileUpdate(fileName) {
var abs = absolutePath + "/temp.mp3";
var newP = absolutePath + "/" + fileName;
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
var arguments = ["-i", abs, "-c:v", "mp3", newP];
_flutterFFmpeg.executeWithArguments(arguments).then((rc) {
File(abs).delete();
});
}