1

我有一个 HTML5 音频元素:

<audio id="mp3_audio_player" preload="auto">
    <source src="./Sound/recording.mp3" type="audio/mpeg">
</audio>

我需要能够播放 mp3 录音的最后 4 秒。我的 JavaScript 是:

audio.currentTime = audio.duration-4;
audio.play();

在 IE10 和 Firefox 中运行正常,但 Chrome 从错误的位置开始播放。报告的 audio.currentTime 与实际播放位置之间的差异约为 20 秒。recording.mp3 是用 ffmpeg 创建的:

ffmpeg -i recording.wav -ab 32k recording.mp3

当我从recording.mp3 中剥离ID3v2 标头时(在音频数据之前删除文件中的前几个字节),它可以工作。

当我压缩到 ogg 时它也可以工作。有人可以指出我正确的方向(ffmpeg 开关、音频元素属性或其他)以使其在 chrome 中也能正常工作吗?

提前致谢

编辑:ffmpeg 输出:

ffmpeg version N-53528-g160ea26 Copyright (c) 2000-2013 the FFmpeg developers
  built on May 27 2013 15:20:09 with gcc 4.7.3 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-
amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --
enable-libxvid --enable-zlib
  libavutil      52. 34.100 / 52. 34.100
  libavcodec     55. 12.100 / 55. 12.100
  libavformat    55.  7.100 / 55.  7.100
  libavdevice    55.  1.101 / 55.  1.101
  libavfilter     3. 72.100 /  3. 72.100
  libswscale      2.  3.100 /  2.  3.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[wav @ 0433e840] max_analyze_duration 5000000 reached at 5015510 microseconds
Guessed Channel Layout for  Input Stream #0.0 : mono
Input #0, wav, from 'recording.wav':
  Duration: 02:30:07.86, bitrate: 176 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, mono, s16, 176 kb/s
Output #0, mp3, to 'recording.mp3':
  Metadata:
    TSSE            : Lavf55.7.100
    Stream #0:0: Audio: mp3 (libmp3lame), 11025 Hz, mono, s16p, 32 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le -> libmp3lame)
Press [q] to stop, [?] for help
size=   35188kB time=02:30:07.86 bitrate=  32.0kbits/s
video:0kB audio:35187kB subtitle:0 global headers:0kB muxing overhead 0.000672%
4

0 回答 0