dmrschmidt / DSWaveformImage

Generate waveform images from audio files on iOS, macOS & visionOS in Swift. Native SwiftUI & UIKit views.
MIT License
978 stars 109 forks source link

mp3 File not support #76

Closed jigneshchovatiya closed 8 months ago

jigneshchovatiya commented 9 months ago

striped(.init(color: .white,width: 5.0,spacing: 8.0,lineCap: .round)

Last Stripe Round cap not showing and also not support mp3 file

Screenshot 2023-09-22 at 3 39 47 PM
dmrschmidt commented 9 months ago

This sounds like an issue with the mp3 file itself.

see https://github.com/dmrschmidt/DSWaveformImage/issues/52#issuecomment-1329550520

there’s a lot of audio tools out there that create invalid audio data.

If you can confirm that opening the file with a different audio tool shows different behavior, I can investigate further if you upload the mp3 somewhere.

jigneshchovatiya commented 9 months ago

@dmrschmidt and What's about Last Stripe Round cap not showing

i will share mp3 file link letter Here

dmrschmidt commented 9 months ago

Ah I didn’t notice that at first. That surely is not how it’s supposed to be. And it’s a separate issue from the mp3 file.

I’ll have a look. Is this SwiftUI? What phone / simulator / device are you running this on?

jigneshchovatiya commented 9 months ago

Ah I didn’t notice that at first. That surely is not how it’s supposed to be. And it’s a separate issue from the mp3 file.

I’ll have a look. Is this SwiftUI? What phone / simulator / device are you running this on?

It's .m4a file not mp3 , it's swift not SwiftUI , iphone13 Pro , Simulator iPhone 14

dmrschmidt commented 9 months ago

i will share mp3 file link letter Here

Any update on this?

jigneshchovatiya commented 8 months ago

6361f60195c97c3373483a47.mp3.zip @dmrschmidt Can you check this audio File it's not working

dmrschmidt commented 8 months ago

A look at the file header reveals that this is, in fact, not an mp3 file.

Screenshot 2023-10-04 at 15 46 49

Not exactly sure what format it is, but definitely not an mp3 file.

iOS uses a rather simplistic approach when loading a file. It simply looks at the file ending - in your case mp3. When it then tries to load that file, but it does not adhere to the actual mp3 file format, it fails to load.

That's what you are observing.

To fix the issue, please ensure to either

dmrschmidt commented 8 months ago

One more addition. I've run the file through MediaInfo and it appears to be in AMR format. Possibly from an online tool called SoundHandle or from an Android Device. The built-in iOS audio libraries do not appear to support that format out of the box. macOS can play it back when the ending is changed to .mp4, but they may be using some other means which are not supported in the same way.

I won't be able to support all different kinds of existing audio formats, so the solution remains the same. Ensure that the files you import are converted to a natively supported file format, which could be valid mp3 or aac among others.

Screenshot 2023-10-05 at 08 50 40