Sharukh Mohammed
Sharukh Mohammed

Reputation: 354

How to download a part of mp3 from server?

Use Case

My use case is roughly equal to, adding a 15-second mp3 file to a ~1 min video. All transcoding merging part will be done by FFmpeg-android so that's not the concern right now.

The flow is as follows

Tried solutions

So above two solutions have not been fruitful and currently, I am downloading the whole file and trimming it locally, which is definitely a bad UX. I wonder how Instagram's music addition to story feature works because that's close to what I wanted to implement.

Upvotes: 3

Views: 313

Answers (1)

szatmary
szatmary

Reputation: 31101

Its is not possible the way you want to do it. mp3 files do not have timestamps. If you just jump to the middle of an mp3, (and look for the frame start marker), then start decoding, You have no idea at what time this frame is for, because frames are variable size. The only way to know, is to count the number of frames before the current position. Which means you need the whole file.

Upvotes: 3

Related Questions