sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.75k stars 566 forks source link

MP3TrackImpl #353

Closed fsappz78 closed 5 years ago

fsappz78 commented 5 years ago

Hi! I have a problem using MP3TrackImpl: java.io.IOException: Expected Start Word 0x7ff 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readMP3Header(MP3TrackImpl.java:183) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.readSamples(MP3TrackImpl.java:154) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.<init>(MP3TrackImpl.java:60) 01-05 11:05:19.754 11731-11870/de.fsappz.musicvideomaker W/System.err: at com.googlecode.mp4parser.authoring.tracks.MP3TrackImpl.<init>(MP3TrackImpl.java:53)

Im using MP3TrackImpl like this: MP3TrackImpl mp3Track = new MP3TrackImpl(new FileDataSourceImpl(audio); (Exception is thrown in this line)

Thank you very much!

GirishBhutiya commented 5 years ago

Do you get any solution for this?

fsappz78 commented 5 years ago

Do you get any solution for this?

Yes. The exception is thrown because the Mp3 file has an ID3 Tag. I fixed it by removing the Tag(s). I used mp3agic(https://github.com/mpatric/mp3agic#removing-id3-and-custom-tags-from-an-mp3-file) for that.

GirishBhutiya commented 5 years ago

Thanks @fsappz78 for your reply but mp3agic not working on android. Is there any solution for that?

fsappz78 commented 5 years ago

Thanks @fsappz78 for your reply but mp3agic not working on android. Is there any solution for that? I'm using it on Android and it works perfectly -The only problem is that it can't write to that paths managed through Android Access Framework.

GirishBhutiya commented 5 years ago

Thanks but when I try to create object like below.

Mp3File mp3file = new Mp3File(SDPathToFile("MyFilm", "a.mp3").getPath());

It give cannot access Path class file for java.nio.file.Path not found

If you can provide sample code for remove tag that it will be great.

Thanks

fsappz78 commented 5 years ago

Hi again @GirishBhutiya ! This is because mp3agic uses new Java classes, which are not available below Android API version 26. The solution is to downgrade the mp3agic version in your app-level build.gradle file: dependencies{ implementation 'com.mpatric:mp3agic:0.9.0' }

-Click Sync now -If you get build error Program type already present, just go to Build > Rebuild project and everything should be fine 👍.

GirishBhutiya commented 5 years ago

yes It work fine now Thanks a lot for your Great Help! :)

fsappz78 commented 5 years ago

You're welcome :)