Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#5070 closed defect (fixed)

Lot of artifacts in AAC encoder and duration is incorrect

Reported by: d4eva Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: aac
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

There are lot of artifacts in the resulting m4a file, also the duration of the m4a file differs from the original wav file.

How to reproduce:

ffmpeg started on 2015-12-06 at 12:40:33
Report written to "ffmpeg-20151206-124033.log"
Command line:
"D:\\converted\\output\\ffmpeg.exe" -report -i short.wav -y short.m4a
ffmpeg version 2.8.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 5.2.0 (i686-win32-dwarf-rev0, Built by MinGW-W64 project)
  configuration: --enable-memalign-hack --extra-cflags=-I/local/include --extra-ldflags=-L/local/lib --extra-cflags=-U__STRICT_ANSI__ --extra-ldflags='-static-libgcc -static-libstdc++' --disable-shared --disable-doc --enable-encoder=aac --enable-static --enable-ffmpeg --enable-ffplay
  libavutil      55. 10.100 / 55. 10.100
  libavcodec     57. 16.101 / 57. 16.101
  libavformat    57. 19.100 / 57. 19.100
  libavdevice    57.  0.100 / 57.  0.100
  libavfilter     6. 20.100 /  6. 20.100
  libswscale      4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
Splitting the commandline.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-i' ... matched as input file with argument 'short.wav'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'short.m4a' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file short.wav.
Successfully parsed a group of options.
Opening an input file: short.wav.
[wav @ 00a04280] Format wav probed with size=2048 and score=99
[wav @ 00a04280] Before avformat_find_stream_info() pos: 44 bytes read:36872 seeks:2
[wav @ 00a04280] probing stream 0 pp:32
[wav @ 00a04280] probing stream 0 pp:31
[wav @ 00a04280] probing stream 0 pp:30
[wav @ 00a04280] probing stream 0 pp:29
[wav @ 00a04280] probing stream 0 pp:28
[wav @ 00a04280] probing stream 0 pp:27
[wav @ 00a04280] probing stream 0 pp:26
[wav @ 00a04280] probing stream 0 pp:25
[wav @ 00a04280] probing stream 0 pp:24
[wav @ 00a04280] probing stream 0 pp:23
[wav @ 00a04280] probing stream 0 pp:22
[wav @ 00a04280] probing stream 0 pp:21
[wav @ 00a04280] probing stream 0 pp:20
[wav @ 00a04280] probing stream 0 pp:19
[wav @ 00a04280] probing stream 0 pp:18
[wav @ 00a04280] probing stream 0 pp:17
[wav @ 00a04280] probing stream 0 pp:16
[wav @ 00a04280] probing stream 0 pp:15
[wav @ 00a04280] probing stream 0 pp:14
[wav @ 00a04280] probing stream 0 pp:13
[wav @ 00a04280] probing stream 0 pp:12
[wav @ 00a04280] probing stream 0 pp:11
[wav @ 00a04280] probing stream 0 pp:10
[wav @ 00a04280] probing stream 0 pp:9
[wav @ 00a04280] probing stream 0 pp:8
[wav @ 00a04280] probing stream 0 pp:7
[wav @ 00a04280] probing stream 0 pp:6
[wav @ 00a04280] probing stream 0 pp:5
[wav @ 00a04280] probing stream 0 pp:4
[wav @ 00a04280] probing stream 0 pp:3
[wav @ 00a04280] probing stream 0 pp:2
[wav @ 00a04280] probing stream 0 pp:1
[wav @ 00a04280] probed stream 0
[wav @ 00a04280] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav @ 00a04280] All info found
[wav @ 00a04280] After avformat_find_stream_info() pos: 204844 bytes read:266248 seeks:2 frames:50
Guessed Channel Layout for  Input Stream #0.0 : stereo
Input #0, wav, from 'short.wav':
  Duration: 00:00:11.79, bitrate: 1414 kb/s
    Stream #0:0, 50, 1/44100: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Successfully opened the file.
Parsing a group of options: output file short.m4a.
Successfully parsed a group of options.
Opening an output file: short.m4a.
Successfully opened the file.
detected 8 logical cores
[graph 0 input from stream 0:0 @ 00a089a0] Setting 'time_base' to value '1/44100'
[graph 0 input from stream 0:0 @ 00a089a0] Setting 'sample_rate' to value '44100'
[graph 0 input from stream 0:0 @ 00a089a0] Setting 'sample_fmt' to value 's16'
[graph 0 input from stream 0:0 @ 00a089a0] Setting 'channel_layout' to value '0x3'
[graph 0 input from stream 0:0 @ 00a089a0] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[audio format for output stream 0:0 @ 00a0be20] Setting 'sample_fmts' to value 'fltp'
[audio format for output stream 0:0 @ 00a0be20] Setting 'sample_rates' to value '96000|88200|64000|48000|44100|32000|24000|22050|16000|12000|11025|8000|7350'
[audio format for output stream 0:0 @ 00a0be20] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 00a0ef20] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 00a0c0e0] [SWR @ 03f12840] Using s16p internally between filters
[auto-inserted resampler 0 @ 00a0c0e0] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:2 chl:stereo fmt:fltp r:44100Hz
Output #0, ipod, to 'short.m4a':
  Metadata:
    encoder         : Lavf57.19.100
    Stream #0:0, 0, 1/44100: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.16.101 aac
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
size=     110kB time=00:00:07.10 bitrate= 126.7kbits/s    
[output stream 0:0 @ 00a0bca0] EOF on sink link output stream 0:0:default.
No more output streams to write to, finishing.
[aac @ 03ed3b00] Trying to remove 324 more samples than there are in the queue
size=     185kB time=00:00:11.79 bitrate= 128.5kbits/s    
video:0kB audio:182kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.491890%
Input file #0 (short.wav):
  Input stream #0:0 (audio): 508 packets read (2079472 bytes); 508 frames decoded (519868 samples); 
  Total: 508 packets (2079472 bytes) demuxed
Output file #0 (short.m4a):
  Output stream #0:0 (audio): 508 frames encoded (519868 samples); 509 packets muxed (186676 bytes); 
  Total: 509 packets (186676 bytes) muxed
508 frames successfully decoded, 0 decoding errors
[AVIOContext @ 03ed3f00] Statistics: 30 seeks, 532 writeouts
[aac @ 03ed3b00] Qavg: 3679.664
[AVIOContext @ 00a080a0] Statistics: 2120448 bytes read, 2 seeks

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (2)

short.wav (2.0 MB ) - added by d4eva 8 years ago.
short.m4a (185.0 KB ) - added by d4eva 8 years ago.

Change History (19)

by d4eva, 8 years ago

Attachment: short.wav added

by d4eva, 8 years ago

Attachment: short.m4a added

comment:1 by Rostislav Pehlivanov, 8 years ago

Seems to be related to TNS. Are the artifacts still audiable with -aac_tns 0?
I'll try to increase the thresholds if the artifacts dissapear or are reduced with TNS.

As for the lengths being different, the difference is exactly one frame (1024 samples at 44.1 Khz samplerate). This is normal for lossy audio codecs because of overlapping.

in reply to:  description comment:2 by Carl Eugen Hoyos, 8 years ago

Replying to d4eva:

ffmpeg version 2.8.git Copyright (c) 2000-2015 the FFmpeg developers

I have an unrelated question (I am unable to hear a difference between the files you uploaded...):
How do you get "2.8.git" as version? Please explain, we try to avoid this because it makes bug reports less useful.

built with gcc 5.2.0 (i686-win32-dwarf-rev0, Built by MinGW-W64 project)
configuration: --enable-memalign-hack --extra-cflags=-I/local/include --extra-ldflags=-L/local/lib --extra-cflags=-USTRICT_ANSI --extra-ldflags='-static-libgcc -static-libstdc++' --disable-shared --disable-doc --enable-encoder=aac --enable-static --enable-ffmpeg --enable-ffplay

The following configure options have no effect, I suggest you remove them:
--disable-shared -enable-encoder=aac --enable-static --enable-ffmpeg --enable-ffplay
--enable-memalign-hack has a (slightly negative) effect but it shouldn't be necessary since several years.
What is the effect of --extra-cflags=-U__STRICT_ANSI__? Is there a bug in our build system that we don't know about?

comment:3 by d4eva, 8 years ago

About version 2.8: I cloned source as "git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg" and that's the version I got. I'm building on Windows using msys and mingw.

--extra-cflags=-USTRICT_ANSI - some time ago I had some weird issues while building and then I added it (found the solution on google). Now I removed it and it worked just fine.

About artifacts: -aac_tns 0 helped. Those artifacts sound much like very first mp3 encoders back in the days. I tested with foobar, windows media player and itunes and all of them sounded the same.

Thanks for the lengths explanation.

Last edited 8 years ago by d4eva (previous) (diff)

comment:4 by Rostislav Pehlivanov, 8 years ago

Pushed a fix for the artifacts to git master. Give it a listen, I think I've gotten rid of all the crackling and popping.
Thanks for submitting the bug, do close it in case you think it's fixed.

in reply to:  3 comment:5 by Carl Eugen Hoyos, 8 years ago

Replying to d4eva:

About version 2.8: I cloned source as "git clone http://source.ffmpeg.org/git/ffmpeg.git ffmpeg" and that's the version I got. I'm building on Windows using msys and mingw.

What does the following command show if you cd into your build directory?
$ git describe --tags --match N

comment:6 by d4eva, 8 years ago

Now it sounds better. Thanks.

Here's the git output:

$ git describe --tags --match N
N-77129-ga0050d9

comment:7 by Hendrik, 8 years ago

Resolution: fixed
Status: newclosed

comment:8 by Carl Eugen Hoyos, 8 years ago

And what does ./version.sh in the relevant directory show?

comment:9 by d4eva, 8 years ago

The same.

$ ./version.sh
N-77129-ga0050d9

comment:10 by d4eva, 8 years ago

Btw, to keep issue per report, I created ticket #5075 about duration of M4A file. I think it is an issue after all.

comment:11 by Carl Eugen Hoyos, 8 years ago

And the following?

$ rm libavutil/ffversion.h && make V=1 libavutil/ffversion.h && cat libavutil/ffversion.h

comment:12 by d4eva, 8 years ago

Here.

$ rm libavutil/ffversion.h && make V=1 libavutil/ffversion.h && cat libavutil/ffversion.h
./version.sh . libavutil/ffversion.h
touch .version
/* Automatically generated by version.sh, do not manually edit! */
#ifndef AVUTIL_FFVERSION_H
#define AVUTIL_FFVERSION_H
#define FFMPEG_VERSION "N-77129-ga0050d9"
#endif /* AVUTIL_FFVERSION_H */

comment:13 by Carl Eugen Hoyos, 8 years ago

Am I correct that if you do make ffmpeg.exe && ./ffmpeg.exe -version now you do not get 2.8.git as version? Why did you get it originally?

comment:14 by d4eva, 8 years ago

Huh, this is weird. After the 1st build I go this:

ffmpeg version N-77129-ga0050d9 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 5.2.0 (i686-win32-dwarf-rev0, Built by MinGW-W64 project)

But then, after this:

make distclean && make clean

./configure                         \
--enable-memalign-hack              \
--extra-cflags=-I/local/include     \
--extra-ldflags=-L/local/lib        \
--extra-ldflags="-static-libgcc -static-libstdc++" \
--disable-shared                     \
--disable-doc                      \
--enable-static                    \
  
make -j8

2.8.git is back.

/* Automatically generated by version.sh, do not manually edit! */
#ifndef AVUTIL_FFVERSION_H
#define AVUTIL_FFVERSION_H
#define FFMPEG_VERSION "2.8.git"
#endif /* AVUTIL_FFVERSION_H */

comment:15 by Carl Eugen Hoyos, 8 years ago

What about make distclean && ./configure && make -j8 ffmpeg.exe?
Note that make distclean && make clean makes no sense / cannot work and shows errors.

As said --disable-shared --enable-static has absolutely no effect (but will be copied from sites like this one), --enable-memalign-hack has an effect but I don't think the effect is intended by you.

comment:16 by d4eva, 8 years ago

Huh, I finally resolved the issue.
Thing is that I pull source using Git Bash (via msysgit), but build I start under msys and from there git.exe was not in the path, that's why version.sh from the build environment picked up RELEASE file and the result was 2.8.git. I added git.exe to the path and now it's fine. Thanks.

comment:17 by Carl Eugen Hoyos, 8 years ago

Thank you for the explanation (I expected this or an ancient version of git, that's why I originally asked for the result of a git command line)!

Note: See TracTickets for help on using tickets.