80

While converting flv to mp4 conversion using FFMPEG it's showing following error

[aac @ 0x2b4b640] The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it.

Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
Sandeep Nambiar
  • 1,656
  • 3
  • 22
  • 38
  • 1
    If you're seeing the "experimental" message then your `ffmpeg` is old. The FFmpeg AAC encoder is no longer experimental so you don't need to use `-strict experimental`/`-strict -2` anymore. See the [FFmpeg Download](https://ffmpeg.org/download.html) page for links to builds for Linux, macOS, and Windows. – llogan Dec 15 '17 at 07:09
  • 2
    As of this comment Ubuntu 16.04 LTS is providing version 7:2.8.15-0ubuntu0.16.04.1 which still triggers the "experimental" error. Assuming you're just using the apt package. – Sebastian Iorga Jan 30 '19 at 18:06

5 Answers5

186

Actually it is not enough to add -strict -2 to the command line. It is very important where the -strict -2 is added and unfortunately this is not explained in the error message. It should be just before the last argument, that is, as follows:

ffmpeg -i infile -strict -2 outfile
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Giulio Genovese
  • 2,761
  • 1
  • 15
  • 12
  • 10
    Thanks a lot for this, these zero byte files (because of incorrect flag order) had me baffled. – Brian FitzGerald Jun 14 '16 at 20:24
  • I was encoding videos from mp4 to hls and kept getting the aac/strict 2 error message. freeseek's answer was the only one that worked. – Kalob Taulien Jan 22 '18 at 02:55
  • 3
    Crazy that they don't point this out in the logs. Thanks, @freeseek, really helped me out. – Mitya Nov 04 '18 at 16:48
  • "It should be just before the last argument" is incorrect. You can do something like this `ffmpeg -i infile -c:a aac -strict 2 -ab 192k outfile` without any problems. – YTZ Nov 09 '20 at 21:29
  • @brillout ffmpeg is known for its insane/idiosyncratic syntax. This hasn't been fixed in 2022 and I doubt it ever will be. – Navin Apr 16 '22 at 09:33
10

Like the message says, the native ffmpeg AAC audio encoder is experimental and you need to add -strict -2 or -strict experimental to your command use it. However, this encoder is no longer marked as experimental, so recent ffmpeg builds do not need to use this option.

For the best results use libfdk_aac instead. You need to compile ffmpeg with this lib, see the compilation guide.

To set the audio encoder use -c:a libfdk_aac.

llogan
  • 121,796
  • 28
  • 232
  • 243
aergistal
  • 29,947
  • 5
  • 70
  • 92
  • 1
    @SandeepNambiar "You need to compile ffmpeg with this lib, see the [compilation guide](https://trac.ffmpeg.org/wiki/CompilationGuide/Centos)." Also, you should accept one of these answers; the `Unknown encoder 'libfdk_aac'` is a different issue than what your question asks about. – llogan Oct 04 '15 at 17:37
  • When making an advice like this it is good form to mention that codec is not GPL (basically that means you cannot use it without paying for it). See https://trac.ffmpeg.org/wiki/Encode/AAC – Mike Versteeg Nov 04 '15 at 08:50
  • 2
    @Mike Versteeg In this case there is nothing in the question that indicates the asker wants to distribute the code and there are no license fees for distributing AAC content. Plus it's not an advice. See: http://www.vialicensing.com/licensing/aac-faq.aspx – aergistal Nov 04 '15 at 09:01
5

Try following command :

ffmpeg -i Inputfile.flv -vcodec h264 -acodec aac -strict -2 Filename.mp4

You can use this command to convert any type of video file into mp4 with x264 and with same quality.

I have tried so many ways but this worked for me like a charm. ;)

Gerhard
  • 22,678
  • 7
  • 27
  • 43
Ravi Gohil
  • 147
  • 1
  • 11
2

You can add the -strict experimental in your C++ code by setting the codec-context strict_std_complaince variable to -2 before opening the codec.

AVCodecContext *c;
c->strict_std_compliance = -2;

/* open it */
ret = avcodec_open2(c, codec, NULL);

See the original author's explanation here.

Dumisani Kunene
  • 659
  • 7
  • 9
-8

Your question answers itself. Add -strict -2 to it. That should be enough

Akhil Gupta
  • 101
  • 1
  • 8