How to use ffmpeg to convert a G711 u-law or a-law file to wav

audioconversionffmpeg

One of our applications allow user to upload several audio formats like mp3, G711 u-law or a-law etc. and it uses ffmpeg to convert those formats to wav.

Convert mp3 to wav seems easy by using the following command. What parameters can I use to convert u-law or a-law to wav?

ffmpeg -i input.mp3 output.wav

Tried the following commands for g711 u-law and all got same errors:

ffmpeg.exe -i output.g711u -acodec u-law -ar 44100 -ac 1 output.wav

ffmpeg.exe -i output.g711u output.wav

ffmpeg version N-80234-g49b0246 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 5.3.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --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-libmfx --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --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-decklink --enable-zlib
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 45.100 / 57. 45.100
  libavformat    57. 37.101 / 57. 37.101
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 46.101 /  6. 46.101
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100

**output.g711u: Invalid data found when processing input**

But it works by using sox with the following command.

sox --type raw --rate 44100 -e u-law output.g711u output_file3.wav

Best Answer

I've used the following command to resolve the issue.

ffmpeg.exe -f mulaw -ar 44100 -i output.g711u output_file3.wav
Related Question