cybercase / webminidisc

Upload your Music to NetMD MiniDisc devices thanks to WebUSB and WASM
GNU General Public License v2.0
310 stars 90 forks source link

[Solved] Audio plays at super-fast speed #36

Closed 5833tP2 closed 3 years ago

5833tP2 commented 3 years ago

I've struck a weird problem with an MP3 file where it plays at super-fast speed on the MD.

The source file is a 60 minute (19MB) spoken-word MP3 file with the following characteristics: Audio file with ID3 version 2.3.0, contains:MPEG ADTS, layer III, v2, 64 kbps, 22.05 kHz, Monaural

Using webminidisc, conversion to WAV seems to work file, and the file downloads to MD fine too but playback is hilariously super-fast (think Chipmunks talking).

I've repeated this using a WAV source (used ffmpeg to convert the MP3 to WAV) and the same thing happens.

I'm clueless about what to do.

cybercase commented 3 years ago

@5833tP2 I fear this could be a bug on my end. The cause it's likely the sampling rate of 22.05 hz; I should make sure to resample the audio file to 44100hz before uploading to MD.

I'll try to fix it as soon as possible. Meanwhile you could try to convert your file to 44100hz before uploading; this should do the trick.

5833tP2 commented 3 years ago

Thanks, @cybercase, for your quick reply! I wondered if the low sample rate of the source might be a problem.

I resampled the source audio file to 44100hz with ffmpeg -i source.mp3 -vn -ar 44100 -b:a 192k newfile.wav but I get the same super-fast playback speed. I've tried this with and without the fixed bitrate option -b:a 192k but the result is the same.

I'm sorry I don't have better news. Thanks for adding this to your To Do list.

cybercase commented 3 years ago

@5833tP2 to help me reproduce the issue, would it be a problem for you to share that file with me? Even a similar file who gives you the same issue would it be fine. Thanks

5833tP2 commented 3 years ago

Here's the file, @cybercase ... a lecture from the 1960s by Buddhist philosopher Alan Watts. Thanks!

cybercase commented 3 years ago

@5833tP2 After doing some research it looks like that the -ar 44100 option might not work correctly in some cases if the number of desired output channel -ac 2 is not specified. see: https://trac.ffmpeg.org/ticket/6638

I should be able to fix the problem, meanwhile you could try to add the -ac 2 option to your ffmpeg command.

5833tP2 commented 3 years ago

If I add -ac 2 the file fails to upload to the MD recorder with the message Error uploading to device. File is 803MB large.

As a test, I created two 30 sec audio extracts from the source file, then converted to wav.

ffmpeg -i source.mp3 -vn -ar 44100 -b:a 192k newfile.wav - audio duration = 15 sec ffmpeg -i source.mp3 -vn -ar 44100 -b:a 192k -ac 2 newfile-with-ac2.wav - audio duration = 30 sec

So, adding the -ac 2 option fixes the playback speed problem, but I now cannot upload the full file to MD.

Thanks, @cybercase for your help in troubleshooting this.

cybercase commented 3 years ago

@5833tP2 No problem at all!

I've had the same issue because there wasn't enough space left in my 74 mins MiniDisc (your mp3 is 79 mins long). However, I've been able to successfully upload the file by using an empty 80mins MD. Could this be the issue?

5833tP2 commented 3 years ago

Ah, good point! Digital audio files have made me lazy and to think more about file size, not audio duration. I need to remember what it was like making mixtapes with cassettes back in the day :smile:

The full audio duration is 1:19:32 (79 min, 32 sec) so I definitely need an 80 minute MD disc. All my Minidiscs are 74 minute ... eBay search coming up.

Thanks so much for your help with this, @cybercase . :+1: