How to resolve ffmpeg error "input contains (near) nan/+-inf"? 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&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
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