wavesurfer.js icon indicating copy to clipboard operation
wavesurfer.js copied to clipboard

`getDuration()` takes a deviation from the actual time

Open zh-lx opened this issue 2 years ago • 8 comments

Wavesurfer.js version(s):

5.0.2

Browser and operating system version(s):

Chrome. version is : 98.0.4758.109

Use behaviour needed to reproduce the issue:

When I user ws.getDuration() to get the duration of the audio, the result takes a deviation from the actual time. As shown in the figure below: image

zh-lx avatar Mar 04 '22 08:03 zh-lx

Can you use ffprobe (part of ffmpeg) to scan the audio file and paste output here?

thijstriemstra avatar Mar 05 '22 13:03 thijstriemstra

Can you use ffprobe (part of ffmpeg) to scan the audio file and paste output here?

The result is as follow:

ffprobe version 5.0 Copyright (c) 2007-2022 the FFmpeg developers
  built with Apple clang version 12.0.5 (clang-1205.0.22.11)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/5.0-with-options_1 --enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libaom --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-libsnappy --enable-libtheora --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-demuxer=dash --enable-opencl --enable-videotoolbox --disable-htmlpages
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, mp3, from '下载.mp3':
  Metadata:
    date            : 2011
    artist          : Walter Isaacson
    title           : Steve Jobs
    album           : Steve Jobs (Unabridged)
    WOAS            : http://www.audible.com/pd/B005V0QI82
    track           : 1/46
    comment         : Based on more than 40 interviews with Jobs conducted over two years—as well as interviews with more than a hundred family members, friends, adversaries, competitors, and colleagues—Walter Isaacson has written a riveting story of the roller-coaster lif
    composer        : Dylan Baker
    UFID            : BK_SANS_005704
    NARRATEDBY      : Dylan Baker
    encoder         : Lavf58.20.100
  Duration: 00:12:36.30, start: 0.185756, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 22050 Hz, stereo, fltp, 128 kb/s
  Stream #0:1: Video: mjpeg (Baseline), yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn (attached pic)
    Metadata:
      comment         : Other

zh-lx avatar Mar 06 '22 09:03 zh-lx

Wavesurfer.js version(s): 5.0.2

Always test with latest version(s).

thijstriemstra avatar Mar 06 '22 14:03 thijstriemstra

Wavesurfer.js version(s): 5.0.2

Always test with latest version(s).

Sorry, I have upgraded it to version 6.0.2, but the problem is still present.

zh-lx avatar Mar 10 '22 03:03 zh-lx

can you convert it to wav using ffmpeg and see if that makes a difference.

thijstriemstra avatar Mar 10 '22 10:03 thijstriemstra

can you convert it to wav using ffmpeg and see if that makes a difference.

Yes, it is normal when converting it to .wav file, according to my observation, some .mp3 files will have problems.

zh-lx avatar Mar 11 '22 02:03 zh-lx

Ok, so it's a browser issue, not sure how wavesurfer.js can be improved here.

thijstriemstra avatar Mar 11 '22 12:03 thijstriemstra

Ok, so it's a browser issue, not sure how wavesurfer.js can be improved here.

But if I get the duration of the audio through the <audio /> tag of the browser, the obtained value is normal.

zh-lx avatar Mar 11 '22 16:03 zh-lx