bbc / peaks.js

JavaScript UI component for interacting with audio waveforms
https://waveform.prototyping.bbc.co.uk
GNU Lesser General Public License v3.0
3.2k stars 278 forks source link

Time calculated is twice the waveform length #103

Open mbordash opened 9 years ago

mbordash commented 9 years ago

Hello sirs, I was hesitant posting this issue as I can't determine whether this issue is related to mp3 encoding or something in the calculation of the waveform time length. But if you have a look at this member's upload: http://www.internetdj.com/song/109702 you'll see the waveform time is about 12 minutes, when in fact the song is actually about 6 minutes. You can seek successfully to about the 6 minute mark, but if you click anywhere beyond that, the song stops and you have to reload the page to listen again. It's only this particular member's tracks so I suspect it's something up with the generated waveform data. Any tips you could provide would be appreciated.

thom4parisot commented 9 years ago

Hello and sorry about the delay! Do you still have the issue? From what I have seen, the display is correct on the aforementioned hyperlink.

mbordash commented 9 years ago

No worries whatsoever... loving this project. Yes, the problem persists. Let me explain a bit better. The waveform looks perfect, but the duration on the link above states ~ "12:06", when in fact the song is precisely half that duration. To experience, play the song, and then seek to anywhere within latter half of the waveform. You'll notice that the song will cease and the bar will move to the middle of the waveform.

image

chrisn commented 9 years ago

Hello Michael,

I've had a look into the issue, and not been able to reproduce it.

The audio and waveform data used in this page are http://www.internetdj.com/mp3/109702.mp3 and http://www.internetdj.com/mp3Json/109702. The JSON data has samples_per_pixel 768 and length 42064. I ran the MP3 file through audiowaveform using these options:

audiowaveform -i 109702.mp3 -o 109702.json -b 8 -z 768

and here's the output:

Input file: 109702.mp3
Format: Audio MPEG layer III stream
Bit rate: 320000 kbit/s
CRC: no
Mode: normal LR stereo
Emphasis: no
Sample rate: 44100 Hz
Generating waveform data...
Samples per pixel: 768
Input channels: 2
Done: 100%
Recoverable frame level error: lost synchronization

Frames decoded: 14021 (6:06.262)
Generated 21032 points
Writing output file: 109702.json

This looks OK, and reports the correct length of the audio (6:06), and the output JSON file has length 21032. Here's an image I generated from that MP3 using audiowaveform:

test

I'm not sure why your JSON file is exactly twice as long as it should be. How are you invoking audiowaveform, what version is it, and what options are you using?

Chris

mbordash commented 9 years ago

Thank you very much for the detailed feedback, and apologies for the delay. I'm invoking audiowave form like this: audiowaveform -i -o -z 768 -b 8

$ ./audiowaveform -v AudioWaveform v1.0.6

mbordash commented 9 years ago

Right, I don't think it's audiowaveform. I manually executed with this mp3 and looks good, yet peaks still thinks the file is ~11:28 instead of 5:44.

Recoverable frame level error: lost synchronization << this repeats throughout the execution

Done: 100% Frames decoded: 13198 (5:44.746) Generated 39592 points Writing output file: 109007.json

Will dig deeper. Thanks again.

thom4parisot commented 9 years ago

What is the duration reported by an HTML5 <audio /> player with this file?

If you use Peaks without providing a metadata file, do you still encounter the issue?

In any case, feel free to send me privately a URL so as I can investigate this more in depth.

jonata commented 7 years ago

I can see this behaviour in some MP3 I was trying to use. I have the original aiff files, reconverted them to different bitrates and sample rates, and the problem persists in all of this new generated MP3 files. Strange...

chrisn commented 7 years ago

Hi @jonata, I'd really like to be able to track down the cause of this issue. Would you mind sharing the files (the MP3 as well as the .dat or .json from audiowaveform)?

jonata commented 7 years ago

Sure. I was working with the portuguese mp3 files from this book: https://www.jw.org/download/?output=html&pub=cl&fileformat=MP3%2CAAC&alllangs=0&langwritten=T&txtCMSLang=T&isBible=0

As an example, you could test the first one: cl_T_01.mp3.zip

It have 112 seconds. So, I want to generate a waveform with 15 pixels per second = 1680

audiowaveform -i cl_T_01.mp3 --no-axis-labels --pixels-per-second 15 -h 180 -w 1680 -o test.png

cl_T_01_json_and_dat.zip

I don't know, maybe am I missing something? Other MP3 files generated from the same source used to run just fine.

Thanks for your attention!

thom4parisot commented 7 years ago

This bug has been partly addressed by bbc/audiowaveform#48, isn't it @chrisn?

I guess it should be enough as audiowaveform would then be able to determine the file is mono channel?