<p>If you have a ffmpeg build with <code>libfdk_aac</code> then you can use that encoder since it doesn't report that error.</p>

<p>With your current build, you have to convert the audio to 16 bit integer samples first.</p>

<pre><code>ffmpeg -i input.wmv -vf "scale=320:240,setsar=1" -crf 24 -af aformat=s16p -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4
</code></pre>

CC BY-SA 4.0
2018-11-17T17:54:08.173Z
Thank you. What is the actual problem though? What's wrong with the wmv's audio that I would have to do this first?
user3643
CC BY-SA 4.0
2018-11-17T19:10:58.940Z
During a transform process, some of the coefficients generated were too large in some frequency bands, as best as I can tell. No connection with the input codec or format.
Gyan
CC BY-SA 4.0
2018-11-19T17:05:00.550Z
Thanks, renders as expected now. Have you seen this before? I only have this happen to me on these old WMVs I have. And they're quite old. This one was captured in 2008, with tech from 2002.
user3643
CC BY-SA 4.0
2018-11-19T17:17:44.333Z
No, this is an esoteric error from inside the encoding machinery. It's sort of strange that the encoder doesn't just smooth over the coefficients.
Gyan
CC BY-SA 4.0
2018-11-17T06:26:16.160Z
2018-11-17T11:08:56.597Z
2018-11-17T11:08:56.597Z
Gyan
<p>I'm trying to convert some old WMVs into MP4s, but ffmpeg will not do it. I keep getting the following error:</p>

<pre><code> input contains (near) nan/+-inf
 audio encoding failed
</code></pre>

<p>Exact command used is:</p>

<pre><code> ffmpeg -i input.wmv -vf "scale=320:240,setsar=1" -crf 24 -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4
</code></pre>

<p>If it helps, ffprobe gives the following:</p>

<pre><code>Users\name&gt;ffprobe input.wmv
ffprobe version N-90143-gb6652f5100 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --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-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 12.102 / 58. 12.102
  libavformat    58.  9.100 / 58.  9.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
[wmv3 @ 0000020416485e40] Extra data: 8 bits left, value: 0
Input #0, asf, from 'input.wmv':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@LL
    WMFSDKVersion   : 11.0.5358.4827
    IsVBR           : 0
  Duration: 00:27:02.46, start: 0.000000, bitrate: 205 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, 2 channels, fltp, 32 kb/s
    Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 320x240, 168 kb/s, 14.99 fps, 14.99 tbr, 1k tbn, 1k tbc
[wmv3 @ 00000204164fe740] Extra data: 8 bits left, value: 0
</code></pre>

CC BY-SA 4.0
2018-11-16T20:48:12.077Z
Definitely related to the audio. I was able to run the following: `ffmpeg -i input.wmv -crf 24 -an -movflags +faststart output.mp4`. However, I got a lot of "past duration x.xxxxxx too large" warnings.
user3643
CC BY-SA 4.0
2018-11-16T20:49:06.937Z
I tried to run the original command with higher and lower `-b:a` values, but got the same errors.
user3643
CC BY-SA 4.0
2018-11-17T05:17:35.483Z
Can you share the file?
Gyan
CC BY-SA 4.0
2018-11-17T05:31:20.037Z
@Gyan Sure: https://www.dropbox.com/s/0fkrw8vqzyjjsa7/A4M-083SS402.wmv
user3643
<ffmpeg><audio>
How to resolve ffmpeg error "input contains (near) nan/+-inf"?
user3643
# How to resolve ffmpeg error "input contains (near) nan/+-inf"?

(Asked by: username_0 on 2018-11-16)

I'm trying to convert some old WMVs into MP4s, but ffmpeg will not do it. I keep getting the following error:
 input contains (near) nan/+-inf
 audio encoding failed

Exact command used is:
 ffmpeg -i input.wmv -vf "scale=320:240,setsar=1" -crf 24 -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4

If it helps, ffprobe gives the following:
Users\name>ffprobe input.wmv
ffprobe version N-90143-gb6652f5100 Copyright (c) 2007-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --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-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 12.102 / 58. 12.102
  libavformat    58.  9.100 / 58.  9.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
[wmv3 @ 0000020416485e40] Extra data: 8 bits left, value: 0
Input #0, asf, from 'input.wmv':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: MP@LL
    WMFSDKVersion   : 11.0.5358.4827
    IsVBR           : 0
  Duration: 00:27:02.46, start: 0.000000, bitrate: 205 kb/s
    Stream #0:0(eng): Audio: wmav2 (a[1][0][0] / 0x0161), 32000 Hz, 2 channels, fltp, 32 kb/s
    Stream #0:1(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 320x240, 168 kb/s, 14.99 fps, 14.99 tbr, 1k tbn, 1k tbc
[wmv3 @ 00000204164fe740] Extra data: 8 bits left, value: 0

**Tags:** ffmpeg, audio

> **Comments:**
> **username_0**: Definitely related to the audio. I was able to run the following: `ffmpeg -i input.wmv -crf 24 -an -movflags +faststart output.mp4`. However, I got a lot of "past duration x.xxxxxx too large" warnings.  
> **username_0**: I tried to run the original command with higher and lower `-b:a` values, but got the same errors.  
> **username_1**: Can you share the file?  
> **username_0**: @username_1 Sure: https://www.dropbox.com/s/0fkrw8vqzyjjsa7/A4M-083SS402.wmv  

---

## 1 answers

### Answer by username_1 on 2018-11-17. Score: 1 | Accepted answer

If you have a ffmpeg build with libfdk_aac then you can use that encoder since it doesn't report that error.
With your current build, you have to convert the audio to 16 bit integer samples first.
ffmpeg -i input.wmv -vf "scale=320:240,setsar=1" -crf 24 -af aformat=s16p -c:a aac -b:a 48k -ac 1 -movflags +faststart output.mp4

> **Comments:**
> **username_0**: Thank you. What is the actual problem though? What's wrong with the wmv's audio that I would have to do this first?  
> **username_1**: During a transform process, some of the coefficients generated were too large in some frequency bands, as best as I can tell. No connection with the input codec or format.  
> **username_0**: Thanks, renders as expected now. Have you seen this before? I only have this happen to me on these old WMVs I have. And they're quite old. This one was captured in 2008, with tech from 2002.  
> **username_1**: No, this is an esoteric error from inside the encoding machinery. It's sort of strange that the encoder doesn't just smooth over the coefficients.  

---

