Opened 11 months ago

Closed 11 months ago

Last modified 11 months ago

#7370 closed defect (invalid)

Encoding and subsequent decoding with AptX (or AptX HD) results in incorrect sample rate of output file

Reported by: SergeFF Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: aptx
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Encoding and subsequent decoding with AptX (or AptX HD) results in incorrect sample rate of output file.

Input file: sine1k.wav - 44100 Hz (16 bit), sinusoidal signal 1000 Hz
Decoded file: sine1k-aptx.wav is labeled as 48000 Hz (16 bit) but in fact it is 44100 Hz (16 bit) which can be verified by spectral analysis, it shows 1088 Hz signal instead of 1000 Hz.

How to reproduce:

ffmpeg -loglevel verbose -i sine1k.wav -acodec aptx sine1k.aptx
ffmpeg -loglevel verbose -i sine1k.aptx sine1k-aptx.wav

ffmpeg version 4.0.2

Attachments (1)

sine1k.wav (172.3 KB) - added by SergeFF 11 months ago.
44100 Hz (16 bit), sinusoidal signal 1000 Hz

Download all attachments as: .zip

Change History (8)

Changed 11 months ago by SergeFF

44100 Hz (16 bit), sinusoidal signal 1000 Hz

comment:1 Changed 11 months ago by SergeFF

ffmpeg -loglevel verbose -i sine1k.wav -acodec aptx sine1k.aptx

D:\Projects\SoundExpert\research\_encoders+\Lossy\ffmpeg\FileProcess>ffmpeg -log
level verbose -i sine1k.wav -acodec aptx sine1k.aptx
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[wav @ 0000000000109b80] parser not found for codec pcm_s16le, packets or times
may be invalid.
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'sine1k.wav':
  Duration: 00:00:01.00, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s16
, 1411 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> aptx (native))
Press [q] to stop, [?] for help
[graph_0_in_0_0 @ 000000000012b540] tb:1/44100 samplefmt:s16 samplerate:44100 ch
layout:0x3
[format_out_0_0 @ 000000000012c040] auto-inserting filter 'auto_resampler_0' bet
ween the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[auto_resampler_0 @ 000000000012c4c0] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2
chl:stereo fmt:s32p r:44100Hz
Output #0, aptx, to 'sine1k.aptx':
  Metadata:
    encoder         : Lavf58.12.100
    Stream #0:0: Audio: aptx, 44100 Hz, stereo, s32p, 128 kb/s
    Metadata:
      encoder         : Lavc58.18.100 aptx
No more output streams to write to, finishing.
size=      43kB time=00:00:01.02 bitrate= 345.3kbits/s speed=4.68x
video:0kB audio:43kB subtitle:0kB other streams:0kB global headers:0kB muxing ov
erhead: 0.000000%
Input file #0 (sine1k.wav):
  Input stream #0:0 (audio): 44 packets read (176400 bytes); 44 frames decoded (
44100 samples);
  Total: 44 packets (176400 bytes) demuxed
Output file #0 (sine1k.aptx):
  Output stream #0:0 (audio): 44 frames encoded (44100 samples); 44 packets muxe
d (44100 bytes);
  Total: 44 packets (44100 bytes) muxed

comment:2 Changed 11 months ago by SergeFF

ffmpeg -loglevel verbose -i sine1k.aptx sine1k-aptx.wav

D:\Projects\SoundExpert\research\_encoders+\Lossy\ffmpeg\FileProcess>ffmpeg -log
level verbose -i sine1k.aptx sine1k-aptx.wav
ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.1 (GCC) 20180722
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enab
le-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-li
bvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --en
able-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-
libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enabl
e-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enabl
e-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enab
le-dxva2 --enable-avisynth
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, aptx, from 'sine1k.aptx':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Audio: aptx, 48000 Hz, stereo, s32p
Stream mapping:
  Stream #0:0 -> #0:0 (aptx (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
[graph_0_in_0_0 @ 000000000016ec00] tb:1/48000 samplefmt:s32p samplerate:48000 c
hlayout:0x3
[format_out_0_0 @ 0000000000171700] auto-inserting filter 'auto_resampler_0' bet
ween the filter 'Parsed_anull_0' and the filter 'format_out_0_0'
[auto_resampler_0 @ 0000000000171b80] ch:2 chl:stereo fmt:s32p r:48000Hz -> ch:2
 chl:stereo fmt:s16 r:48000Hz
Output #0, wav, to 'sine1k-aptx.wav':
  Metadata:
    ISFT            : Lavf58.12.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16
, 1536 kb/s
    Metadata:
      encoder         : Lavc58.18.100 pcm_s16le
No more output streams to write to, finishing.
size=     172kB time=00:00:00.91 bitrate=1536.7kbits/s speed=9.82x
video:0kB audio:172kB subtitle:0kB other streams:0kB global headers:0kB muxing o
verhead: 0.044218%
Input file #0 (sine1k.aptx):
  Input stream #0:0 (audio): 44 packets read (44100 bytes); 44 frames decoded (4
4100 samples);
  Total: 44 packets (44100 bytes) demuxed
Output file #0 (sine1k-aptx.wav):
  Output stream #0:0 (audio): 44 frames encoded (44100 samples); 44 packets muxe
d (176400 bytes);
  Total: 44 packets (176400 bytes) muxed

comment:3 Changed 11 months ago by richardpl

  • Resolution set to invalid
  • Status changed from new to closed

aptX format can not store sample rate of input. There is nothing to fix.

comment:4 Changed 11 months ago by SergeFF

ffmpeg --help encoder=aptx

Encoder aptx [aptX (Audio Processing Technology for Bluetooth)]:
    General capabilities: small
    Threading capabilities: none
    Supported sample rates: 8000 16000 24000 32000 44100 48000
    Supported sample formats: s32p
    Supported channel layouts: stereo

comment:5 Changed 11 months ago by richardpl

Try ffmpeg -h demuxer=aptx

comment:6 Changed 11 months ago by cehoyos

  • Keywords aptx_hd removed

comment:7 Changed 11 months ago by SergeFF

Yes, decoding with '-sample_rate 44100' outputs the same audio file but correctly labeled as 44100

ffmpeg -loglevel verbose -sample_rate 44100 -i sine1k.aptx sine1k44-aptx.wav
Note: See TracTickets for help on using tickets.