just_waveform icon indicating copy to clipboard operation
just_waveform copied to clipboard

[Android] JustWaveform.extract loses last ~50 ms compared to iOS and FFprobe

Open hkm5558 opened this issue 3 weeks ago • 1 comments

https://github.com/user-attachments/assets/862990a5-48ac-48a4-8c02-eb174c0b98c1

This video file was processed with FFmpeg to extract its audio track. FFmpeg reports the exact audio duration as 5039 ms (consistent on both platforms). However, when using the just_waveform plugin to generate the waveform from this extracted audio track:

On iOS: the resulting waveform duration is 5039 ms (perfectly matches the real duration) On Android: the resulting waveform duration is only 4990 ms (49 ms shorter, about 1% loss)

This confirms that the issue lies in just_waveform’s waveform extraction logic on Android (slight truncation occurs), not in the original video, the FFmpeg-extracted audio, or FFmpeg’s duration reading itself.

hkm5558 avatar Dec 02 '25 08:12 hkm5558

The implementation is relying on what the platform reports as the duration, and the difference may come down to slightly different duration being reported.

I will be in hospital and in recovery for a bit, but in the meantime, you might try experimenting with the source code. One thing that the source code currently does is pre-allocate a buffer for the waveform based on the reported duration. What you can do is ignore that limit and keep reading from the decoder stream until you get to the end of the stream. If the stream turns out to be longer than the reported duration, you would need to reallocate the buffer.

ryanheise avatar Dec 02 '25 12:12 ryanheise