最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Audio playback haltsstops on Chrome 64 - Stack Overflow

programmeradmin2浏览0评论

Google just changed how Chrome preloads audio and video; see:

It's my understanding that simply setting preload attribute to auto should fix the problem, however, I have been unable to do so:

  • /

let mp3 = '/audio/5a745d88483d86.76121223.mp3';
let audio = new Audio(mp3);
audio.preload = 'auto';

audio.play();

Google just changed how Chrome preloads audio and video; see: https://googlechrome.github.io/samples/media/preload-metadata

It's my understanding that simply setting preload attribute to auto should fix the problem, however, I have been unable to do so:

  • https://jsfiddle/NinoSkopac/f4zscrdy/1/

let mp3 = 'https://s3-staging.read2me.online/audio/5a745d88483d86.76121223.mp3';
let audio = new Audio(mp3);
audio.preload = 'auto';

audio.play();

  • https://jsfiddle/NinoSkopac/rst8aspm/

<audio src="https://s3-staging.read2me.online/audio/5a745d88483d86.76121223.mp3" preload="auto" autoplay></audio>

Both of these will stop playing within a minute on Chrome 64 and Chrome 65-dev (other browsers and older Chromes are unaffected). I have replicated this issue on Mac, Windows and Android.

During my debug process, I have attached all possible media events to the JS object (i.e. audio.addEventListener('timeupdate', () => { console.log('timeupdate') })) and at first the events were firing like this:

progress timeupdate progress timeupdate [...]

Later like this: timeupdate timeupdate timeupdate [...]

When the audio playback stopped, I got a handful of error events, and dumping audio.error returns: PIPELINE_ERROR_DECODE: Failed to send audio packet for decoding: timestamp=81763265 duration=26122 size=201 side_data_size=0 is_key_frame=1 encrypted=0 discard_padding (ms)=(0, 0)

How do I fix this? Is this a Chrome bug?

UPDATE:

  • OGG plays fine: https://jsfiddle/NinoSkopac/2hktqcqt/1/
  • This does seem to be a Chrome bug: https://bugs.chromium/p/chromium/issues/detail?id=794782
  • A similar error on Github: https://github./video-dev/hls.js/issues/1529

UPDATE 2:

chrome://media-internals/ reveals this:

UPDATE 3:

This issue has been fixed in Chrome 65.

Share Improve this question edited Mar 22, 2018 at 9:28 onin asked Feb 2, 2018 at 13:48 oninonin 5,7603 gold badges41 silver badges57 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 6

After a couple of days of trial and error and research, I have confirmed what doesn't and does work.

Doesn't work

mp3wrap

mp3wrap output.mp3 *.mp3 the output file is still corrupted and halts

ffmpeg

ffmpeg -i "concat:0.mp3|1.mp3" -acodec copy output.mp3 the output file is still corrupted and halts

Does work

mp3val with -f argument

Simply concatenate/implode your audio binaries (in PHP I do implode('', $audioBinaries) and then run mp3val -f concatenated-audio-file.mp3. The -f argument is essential and it means "try to fix errors".

How to install mp3val?

On MacOS: brew install mp3val On Deb/Ubu: apt-get install mp3val

Same issue I am facing with concatenating technique. With ffmpeg, it works fine. Try ffmpeg with this mand.

ffmpeg -f concat -i "{textfile}" -c:v copy -ab 48k -y "{output}"

textfile will have a list of files written per line.

发布评论

评论列表(0)

  1. 暂无评论