Opened 6 years ago

Closed 2 years ago

Last modified 20 months ago

#7473 closed defect (fixed)

WMA decoder: gapless playback

Reported by: bnnm Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: wmav2
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

FFmpeg's WMA doesn't properly skip encoder delay (as big as 4096 samples), and is missing last frame samples after EOF, so final output is off.

This can be tested comparing the output of any player or program using Microsoft's codec API (Windows Media Foundation) vs ffmpeg.exe. With skip+last frame output is correct compared to those.
Noticeable in old videogames using WMA, that need gapless to loop properly (ex.- Castlevania: Symphony of the Night Xbox).

Skip value in WMA seems fixed, I don't think it's specified in the container (ASF/XWMA) or the bitstream.

I'll provide a patch and leave some samples here that show FFmpeg vs Microsoft decoding.

How to reproduce:

$ ffmpeg.exe -i wma_2ch_44100_48khz.wma wma_2ch_44100_48khz_ffmpeg.wav

ffmpeg version N-92112-g03123e4053 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20180813
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 19.101 / 56. 19.101
  libavcodec     58. 32.100 / 58. 32.100
  libavformat    58. 18.104 / 58. 18.104
  libavdevice    58.  4.105 / 58.  4.105
  libavfilter     7. 33.100 /  7. 33.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, asf, from 'wma_2ch_44100_48khz.wma':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: L2
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 0
  Duration: 00:00:02.04, start: 0.000000, bitrate: 72 kb/s
    Stream #0:0(spa): Audio: wmav2 (a[1][0][0] / 0x0161), 44100 Hz, stereo, fltp, 48 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (wmav2 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'wma_2ch_44100_48khz_ffmpeg.wav':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: L2
    WMFSDKVersion   : 12.0.7601.17514
    IsVBR           : 0
    ISFT            : Lavf58.18.104
    Stream #0:0(spa): Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc58.32.100 pcm_s16le
size=     360kB time=00:00:02.04 bitrate=1443.7kbits/s speed= 511x    
video:0kB audio:360kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.021159%

Attachments (3)

wma_2ch_44100_48khz.wma (18.1 KB ) - added by bnnm 6 years ago.
wma_2ch_44100_48khz_ffmpeg.wav (360.1 KB ) - added by bnnm 6 years ago.
wma_2ch_44100_48khz_microsoft.wav (352.0 KB ) - added by bnnm 6 years ago.

Download all attachments as: .zip

Change History (6)

by bnnm, 6 years ago

Attachment: wma_2ch_44100_48khz.wma added

by bnnm, 6 years ago

comment:1 by t.rapp, 2 years ago

I think this ticket can be closed as the requested changes seem to be implemented by commit 19802d170a304f5853d92e01d0513b9e06897d61.

comment:2 by Elon Musk, 2 years ago

Resolution: fixed
Status: newclosed

comment:3 by Carl Eugen Hoyos, 20 months ago

Keywords: wmav2 added
Note: See TracTickets for help on using tickets.