Opened 7 years ago

Last modified 7 years ago

#6330 new defect

Strange behavior with native FFmpeg AAC encoder, when converting audio to mono

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


Summary of the bug:

When converting stereo to mono, even it seems to really convert to mono, it's been reported as stereo and with a strange bitrate (not CBR??) by MediaInfo and VLC.

How to reproduce:

% ffmpeg -i input -c:v libx264 -b:v 750k -profile:v baseline -level 3.0 -pix_fmt yuv420p -c:a aac -b:a 64k -ac 1 output

ffmpeg version FFmpeg version: 20170330-ad7aff0

MediaInfo and VLC report stereo audio.

MediaInfo also reports a strange 64.5 kbps bitrate (when I wrote 64k), with 2 channels, 1 original channel and Front C position:

ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 1min.
Duration_LastFrame                       : -11ms
Bit rate mode                            : Constante
Bit rate                                 : 64,5Kbps
Channel(s)                               : 2canales
Channel(s)_Original                      : 1canal
Channel positions                        : Front: C
Sampling rate                            : 48,0KHz
Stream size                              : 472Kib (8%)
Language                                 : Español

Testing other bitrates:
48k -> 48Kbps (Constant)
64k -> 64,5Kbps (Constant)
96k -> 96,0Kbps (Constant)
112k -> 114Kbps (Constant)
128k -> 129Kbps (Constant)
192k -> 159Kbps and Variable (with a max bitrate of 192Kbps)

So, it makes me think maybe it's not really CBR?

And althought "-b:a" is supossed to make CBR, when compressing only audio, MediaInfo always reports Variable Bitrate, so no bitrate is visible with it.

ffmpeg -i "1min stereo.wav" -c:a aac -b:a 64k -ac 1 "1min 64kb mono.aac"
Formato                                  : AAC
Formato/Info                             : Advanced Audio Codec
Formato de la versión                    : Version 4
Formato del perfil                       : LC
Tipo de tasa de bits                     : Variable
Canal(es)                                : 1canal
Posiciones del canal                     : Front: C
Velocidad de muestreo                    : 48,0KHz
Tamaño de pista                          : 491Kib (100%)

Change History (2)

comment:1 by Carl Eugen Hoyos, 7 years ago

Keywords: aac added

Please provide the command line that allows to reproduce the issue together with the complete, uncut console output and an input sample to make this a valid ticket.

comment:2 by edumj, 7 years ago


You can try with any video, also with this 2:

Command line:

ffmpeg -i "starwarssub2.vob" -c:v libx264 -preset medium -b:v 750k -profile:v baseline -level 3.0 -pix_fmt yuv420p	  -c:a aac -b:a 64k -ac 1	"starwarssub2 64k mono.mp4"

Full output:

ffmpeg version N-85091-g23ae3cc Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-cuda --enable-cuvid --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-zlib
  libavutil      55. 57.100 / 55. 57.100
  libavcodec     57. 88.100 / 57. 88.100
  libavformat    57. 70.100 / 57. 70.100
  libavdevice    57.  5.100 / 57.  5.100
  libavfilter     6. 81.100 /  6. 81.100
  libswscale      4.  5.100 /  4.  5.100
  libswresample   2.  6.100 /  2.  6.100
  libpostproc    54.  4.100 / 54.  4.100
Input #0, mpeg, from 'starwarssub2.vob':
  Duration: 00:00:38.31, start: 2891.089167, bitrate: 7911 kb/s
    Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bt470bg, top first), 720x576 [SAR 64:45 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
    Stream #0:1[0x28]: Subtitle: dvd_subtitle
    Stream #0:2[0x80]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Stream #0:3[0x81]: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Stream #0:4[0x82]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
    Stream #0:5[0x20]: Subtitle: dvd_subtitle
    Stream #0:6[0x21]: Subtitle: dvd_subtitle
    Stream #0:7[0x22]: Subtitle: dvd_subtitle
    Stream #0:8[0x23]: Subtitle: dvd_subtitle
    Stream #0:9[0x24]: Subtitle: dvd_subtitle
    Stream #0:10[0x25]: Subtitle: dvd_subtitle
    Stream #0:11[0x26]: Subtitle: dvd_subtitle
    Stream #0:12[0x27]: Subtitle: dvd_subtitle
    Stream #0:13[0x29]: Subtitle: dvd_subtitle
    Stream #0:14[0x2a]: Subtitle: dvd_subtitle
    Stream #0:15[0x2b]: Subtitle: dvd_subtitle
    Stream #0:16[0x2c]: Subtitle: dvd_subtitle
    Stream #0:17[0x2d]: Subtitle: dvd_subtitle
    Stream #0:18[0x2e]: Subtitle: dvd_subtitle
    Stream #0:19[0x2f]: Subtitle: dvd_subtitle
File 'starwarssub2 64k mono.mp4' already exists. Overwrite ? [y/N] Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (libx264))
  Stream #0:2 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
[ac3 @ 00000000025d85e0] frame sync error
Error while decoding stream #0:2: Invalid data found when processing input
[aac @ 0000000002b115c0] Queue input is backward in time
[libx264 @ 0000000002b10760] using SAR=64/45
[libx264 @ 0000000002b10760] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0000000002b10760] profile Constrained Baseline, level 3.0
[libx264 @ 0000000002b10760] 264 - core 148 r2762 90a61ec - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - - options: cabac=0 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=750 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'starwarssub2 64k mono.mp4':
    encoder         : Lavf57.70.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 750 kb/s, 25 fps, 12800 tbn, 25 tbc
      encoder         : Lavc57.88.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/750000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, mono, fltp, 64 kb/s
      encoder         : Lavc57.88.100 aac
[mp4 @ 000000000033b5a0] Non-monotonous DTS in output stream 0:1; previous: 2560, current: 2048; changing to 2561. This may result in incorrect timestamps in the output file.
frame=  135 fps=0.0 q=27.0 size=     306kB time=00:00:05.09 bitrate= 492.3kbits/s dup=6 drop=0 speed=10.2x    
frame=  263 fps=262 q=27.0 size=     804kB time=00:00:10.28 bitrate= 640.8kbits/s dup=6 drop=0 speed=10.3x    
frame=  386 fps=256 q=29.0 size=    1412kB time=00:00:15.21 bitrate= 760.6kbits/s dup=6 drop=0 speed=10.1x    
frame=  513 fps=255 q=28.0 size=    1883kB time=00:00:20.30 bitrate= 759.7kbits/s dup=6 drop=0 speed=10.1x    
frame=  634 fps=253 q=29.0 size=    2400kB time=00:00:25.10 bitrate= 783.2kbits/s dup=6 drop=0 speed=  10x    
frame=  777 fps=258 q=28.0 size=    2894kB time=00:00:30.82 bitrate= 769.0kbits/s dup=6 drop=0 speed=10.2x    
frame=  887 fps=253 q=29.0 size=    3379kB time=00:00:35.22 bitrate= 785.8kbits/s dup=6 drop=0 speed=  10x    
[mpeg2video @ 00000000025d7c40] ac-tex damaged at 9 31
[mpeg2video @ 00000000025d7c40] Warning MVs not available
[mpeg2video @ 00000000025d7c40] concealing 225 DC, 225 AC, 225 MV errors in P frame
[ac3 @ 00000000025d85e0] incomplete frame
frame=  959 fps=238 q=-1.0 Lsize=    3939kB time=00:00:38.32 bitrate= 842.2kbits/s dup=6 drop=0 speed=9.51x    
video:3616kB audio:301kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.571200%
[libx264 @ 0000000002b10760] frame I:8     Avg QP:19.11  size: 37600
[libx264 @ 0000000002b10760] frame P:951   Avg QP:22.40  size:  3577
[libx264 @ 0000000002b10760] mb I  I16..4: 29.4%  0.0% 70.6%
[libx264 @ 0000000002b10760] mb P  I16..4:  0.7%  0.0%  0.2%  P16..4: 27.7%  8.7%  3.3%  0.0%  0.0%    skip:59.5%
[libx264 @ 0000000002b10760] final ratefactor: 22.86
[libx264 @ 0000000002b10760] coded y,uvDC,uvAC intra: 43.7% 53.4% 30.7% inter: 10.9% 13.5% 0.2%
[libx264 @ 0000000002b10760] i16 v,h,dc,p: 86%  6%  4%  4%
[libx264 @ 0000000002b10760] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 18% 14%  6%  7%  8%  7%  7%  6%
[libx264 @ 0000000002b10760] i8c dc,h,v,p: 57% 26% 14%  3%
[libx264 @ 0000000002b10760] ref P L0: 80.5% 12.8%  6.7%
[libx264 @ 0000000002b10760] kb/s:772.08
[aac @ 0000000002b115c0] Qavg: 187.389

In this case, the Bitrate is 64.7 kbps...

Note: See TracTickets for help on using tickets.