[FFmpeg-user] need help to convert wav to mp3

Reindl Harald h.reindl at thelounge.net
Wed Sep 22 15:36:29 EEST 2021



Am 22.09.21 um 14:09 schrieb Ashtiani:
> It is created by a type of recorder but I need to play it in My Web
> Application .
> browser just support webm, mp3 and ogg format :(

i wouldn't use ffmpeg for mp3 conversion to begin with

[harry at srv-rhsoft:~]$ lame --help
LAME 64bits version 3.100 (http://lame.sf.net)

usage: lame [options] <infile> [outfile]

     <infile> and/or <outfile> can be "-", which means stdin/stdout.

RECOMMENDED:
     lame -V2 input.wav output.mp3

OPTIONS:
     -b bitrate      set the bitrate, default 128 kbps
     -h              higher quality, but a little slower.
     -f              fast mode (lower quality)
     -V n            quality setting for VBR.  default n=4
                     0=high quality,bigger files. 9.999=smaller files
     --preset type   type must be "medium", "standard", "extreme", "insane",
                     or a value for an average desired bitrate and depending
                     on the value specified, appropriate quality 
settings will
                     be used.
                     "--preset help" gives more info on these

     --help id3      ID3 tagging related options

     --longhelp      full list of options

     --license       print License information

> On Wed, Sep 22, 2021 at 3:34 PM Paul B Mahol <onemda at gmail.com> wrote:
> 
>> On Wed, Sep 22, 2021 at 1:57 PM Ashtiani <ashtiani.alireza at gmail.com>
>> wrote:
>>
>>> yes the sound is correct and play with MPC-HC <https://mpc-hc.org/>
>>> player ;
>>> Format                         : Wave
>>> File size                      : 356 KiB
>>> Duration                       : 1 min 50 s
>>> Overall bit rate               : 26.4 kb/s
>>>
>>> Audio
>>> Format                         : 701
>>> Codec ID                       : 701
>>> Duration                       : 1 min 50 s
>>> Bit rate                       : 26.4 kb/s
>>> Channel(s)                     : 2 channels
>>> Sampling rate                  : 8 000 Hz
>>> Stream size                    : 356 KiB (100%)
>>>
>>
>>
>> Hm, what created such wav file? Because that adpcm variant should have
>> 0x0017 twocc and not 0x1700 one.
>>
>>
>>>
>>> On Wed, Sep 22, 2021 at 3:17 PM Paul B Mahol <onemda at gmail.com> wrote:
>>>
>>>> On Wed, Sep 22, 2021 at 1:22 PM Ashtiani <ashtiani.alireza at gmail.com>
>>>> wrote:
>>>>
>>>>> thanks paul :
>>>>>
>>>>> *" ffplay -avcodec adpcm_ima_oki input.wav" : *
>>>>> Failed to set value 'adpcm_ima_oki' for option 'avcodec': Option not
>>>> found
>>>>>
>>>>
>>>> Sorry, i meant acodec. not avcodec.
>>>>
>>>>
>>>>
>>>>>
>>>>>
>>>>> *"ffmpeg -c:a adpcm_ima_oki -i  input.wav out.mp3"*
>>>>> ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
>>>>>    built with gcc 8 (GCC)
>>>>>    configuration: --arch=x86_64 --bindir=/usr/bin
>>>>> --datadir=/usr/share/ffmpeg --disable-debug --disable-static
>>>>> --disable-stripping --enable-avcodec --enable-avdevice
>>> --enable-avfilter
>>>>> --enable-avformat --enable-avresample --enable-alsa --enable-bzlib
>>>>> --enable-chromaprint --enable-decklink --enable-frei0r
>> --enable-gcrypt
>>>>> --enable-gmp --enable-gpl --enable-gray --enable-iconv
>> --enable-ladspa
>>>>> --enable-libass --enable-libaom --enable-libbluray --enable-libbs2b
>>>>> --enable-libcaca --enable-libcdio --enable-libcodec2
>> --enable-libdc1394
>>>>> --enable-libdav1d --enable-libdavs2 --enable-libdrm
>> --enable-libfdk-aac
>>>>> --enable-libfontconfig --enable-libfreetype --enable-libfribidi
>>>>> --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc
>>>>> --enable-libjack --enable-libkvazaar --enable-libmodplug
>>>>> --enable-libmp3lame --enable-libndi_newtek --enable-libopencore-amrnb
>>>>> --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg
>>>>> --enable-libopenmpt --enable-libopus --enable-libpulse
>>>> --enable-librabbitmq
>>>>> --enable-librsvg --enable-librtmp --enable-librubberband
>>>>> --enable-libsmbclient --enable-libsnappy --enable-libsoxr
>>>> --enable-libspeex
>>>>> --enable-libssh --enable-libtesseract --enable-libtheora
>>>>> --enable-libtwolame --enable-libv4l2 --enable-libvidstab
>>>>> --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
>>>> --enable-libwebp
>>>>> --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxcb
>>>>> --enable-libxcb-shape --enable-libxcb-shm --enable-libxcb-xfixes
>>>>> --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzvbi
>>>>> --enable-lzma --enable-nonfree --enable-openal --enable-opencl
>>>>> --enable-opengl --enable-openssl --enable-postproc --enable-sdl2
>>>>> --enable-shared --enable-swresample --enable-swscale --enable-vaapi
>>>>> --enable-version3 --enable-vdpau --enable-xlib --enable-zlib
>>>>> --incdir=/usr/include/ffmpeg --libdir=/usr/lib64
>>> --mandir=/usr/share/man
>>>>> --optflags='-O2 -g -pipe -Wall -Werror=format-security
>>>>> -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
>>>>> -fstack-protector-strong -grecord-gcc-switches
>>>>> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
>>>>> -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
>>>>> -fasynchronous-unwind-tables -fstack-clash-protection
>> -fcf-protection'
>>>>> --prefix=/usr --shlibdir=/usr/lib64 --enable-libsrt --enable-libzmq
>>>>> --enable-v4l2-m2m --enable-vapoursynth --enable-vulkan --enable-cuda
>>>>> --enable-cuvid --enable-ffnvcodec --enable-libmfx --enable-libnpp
>>>>> --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9
>>>> --enable-libvmaf
>>>>> --enable-nvdec --enable-nvenc --extra-cflags=-I/usr/include/cuda
>>>>> --cpu=x86_64
>>>>>    libavutil      56. 70.100 / 56. 70.100
>>>>>    libavcodec     58.134.100 / 58.134.100
>>>>>    libavformat    58. 76.100 / 58. 76.100
>>>>>    libavdevice    58. 13.100 / 58. 13.100
>>>>>    libavfilter     7.110.100 /  7.110.100
>>>>>    libavresample   4.  0.  0 /  4.  0.  0
>>>>>    libswscale      5.  9.100 /  5.  9.100
>>>>>    libswresample   3.  9.100 /  3.  9.100
>>>>>    libpostproc    55.  9.100 / 55.  9.100
>>>>> Guessed Channel Layout for Input Stream #0.0 : stereo
>>>>> Input #0, wav, from 'input.wav':
>>>>>    Duration: 00:01:50.54, bitrate: 26 kb/s
>>>>>    Stream #0:0: Audio: adpcm_ima_oki ([1][7][0][0] / 0x0701), 8000 Hz,
>>>>> stereo, s16, 64 kb/s
>>>>> File 'out.mp3' already exists. Overwrite? [y/N] y
>>>>> Stream mapping:
>>>>>    Stream #0:0 -> #0:0 (adpcm_ima_oki (native) -> mp3 (libmp3lame))
>>>>> Press [q] to stop, [?] for help
>>>>> Output #0, mp3, to 'out.mp3':
>>>>>    Metadata:
>>>>>      TSSE            : Lavf58.76.100
>>>>>    Stream #0:0: Audio: mp3, 8000 Hz, stereo, s16p
>>>>>      Metadata:
>>>>>        encoder         : Lavc58.134.100 libmp3lame
>>>>> size=     134kB time=00:00:45.58 bitrate=  24.2kbits/s speed= 134x
>>>>> video:0kB audio:134kB subtitle:0kB other streams:0kB global
>> headers:0kB
>>>>> muxing overhead: 0.189990%
>>>>>
>>>>>
>>>>>
>>>> Is sound correct?
>>>>
>>>>
>>>>>
>>>>> On Wed, Sep 22, 2021 at 2:32 PM Paul B Mahol <onemda at gmail.com>
>> wrote:
>>>>>
>>>>>> On Wed, Sep 22, 2021 at 11:06 AM Arif Driessen <arifd86 at gmail.com>
>>>>> wrote:
>>>>>>
>>>>>>> Looking at your output it looks like it can't figure out what
>> your
>>>>>>> input.wav is. Does your wav file work in other applications? Have
>>> you
>>>>>> tried
>>>>>>> increasing the value for 'analyzeduration'?
>>>>>>> If you know the details you could manually specify them,
>> something
>>>>> like:
>>>>>>> ffmpeg -acodec pcm_s16le -i input.wav out.mp3 (it's likely going
>> to
>>>> be
>>>>>>> pcm_s16le or pcm_s24le or pcm_s32le)
>>>>>>>
>>>>>>> Perhaps you don't have these codec installed/enabled. You will
>> want
>>>>>>> something with PCM in it. Run: ffmpeg -codecs and look for
>> anything
>>>>> with
>>>>>>> PCM in it. On Linux, and possibly Mac, you could run: ffmpeg
>>> -codecs
>>>> |
>>>>>> grep
>>>>>>> -e '\sPCM'
>>>>>>> to filter for lines containing PCM for you.
>>>>>>>
>>>>>>> On Wed, Sep 22, 2021 at 7:41 AM Ashtiani <
>>> ashtiani.alireza at gmail.com
>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Try to Convert an Audio wave format file to mp3 with ffmpeg
>> with
>>>>> below
>>>>>>>> command :
>>>>>>>>
>>>>>>>> ffmpeg  -i input.wav output.mp3
>>>>>>>>
>>>>>>>> but ffmpeg say 'could not find codec':
>>>>>>>>
>>>>>>>> ffmpeg version
>> 2021-09-16-git-8f92a1862a-full_build-www.gyan.dev
>>>>>>>> Copyright (c) 2000-2021 the FFmpeg developers
>>>>>>>>    built with gcc 10.3.0 (Rev5, Built by MSYS2 project)
>>>>>>>>    configuration: --enable-gpl --enable-version3 --enable-static
>>>>>>>> --disable-w32threads --disable-autodetect --enable-fontconfig
>>>>>>>> --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp
>>>>>>>> --enable-lzma --enable-libsnappy --enable-zlib --enable-librist
>>>>>>>> --enable-libsrt --enable-libssh --enable-libzmq
>> --enable-avisynth
>>>>>>>> --enable-libbluray --enable-libcaca --enable-sdl2
>>> --enable-libdav1d
>>>>>>>> --enable-libzvbi --enable-librav1e --enable-libsvtav1
>>>>> --enable-libwebp
>>>>>>>> --enable-libx264 --enable-libx265 --enable-libxvid
>>> --enable-libaom
>>>>>>>> --enable-libopenjpeg --enable-libvpx --enable-libass
>>>> --enable-frei0r
>>>>>>>> --enable-libfreetype --enable-libfribidi --enable-libvidstab
>>>>>>>> --enable-libvmaf --enable-libzimg --enable-amf
>> --enable-cuda-llvm
>>>>>>>> --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc
>>>>>>>> --enable-d3d11va --enable-dxva2 --enable-libmfx
>>> --enable-libglslang
>>>>>>>> --enable-vulkan --enable-opencl --enable-libcdio
>> --enable-libgme
>>>>>>>> --enable-libmodplug --enable-libopenmpt
>>> --enable-libopencore-amrwb
>>>>>>>> --enable-libmp3lame --enable-libshine --enable-libtheora
>>>>>>>> --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc
>>>>>>>> --enable-libgsm --enable-libopencore-amrnb --enable-libopus
>>>>>>>> --enable-libspeex --enable-libvorbis --enable-ladspa
>>>> --enable-libbs2b
>>>>>>>> --enable-libflite --enable-libmysofa --enable-librubberband
>>>>>>>> --enable-libsoxr --enable-chromaprint
>>>>>>>>    libavutil      57.  5.100 / 57.  5.100
>>>>>>>>    libavcodec     59.  7.103 / 59.  7.103
>>>>>>>>    libavformat    59.  5.100 / 59.  5.100
>>>>>>>>    libavdevice    59.  0.101 / 59.  0.101
>>>>>>>>    libavfilter     8.  9.100 /  8.  9.100
>>>>>>>>    libswscale      6.  1.100 /  6.  1.100
>>>>>>>>    libswresample   4.  0.100 /  4.  0.100
>>>>>>>>    libpostproc    56.  0.100 / 56.  0.100
>>>>>>>> [wav @ 000001a24340ea40] Could not find codec parameters for
>>>> stream 0
>>>>>>>> (Audio: none ([1][7][0][0] / 0x0701), 8000 Hz, 2 channels, 26
>>>> kb/s):
>>>>>>>> unknown codec
>>>>>>>> Consider increasing the value for the 'analyzeduration' (0) and
>>>>>>>> 'probesize' (5000000) options
>>>>>>>> Guessed Channel Layout for Input Stream #0.0 : stereo
>>>>>>>> Input #0, wav, from 'input.wav':
>>>>>>>>    Duration: 00:01:50.54, bitrate: 26 kb/s
>>>>>>>>    Stream #0:0: Audio: none ([1][7][0][0] / 0x0701), 8000 Hz,
>>>> stereo,
>>>>> 26
>>>>>>>> kb/s
>>>>>>>
>>>>>>
>>>>>> Maybe this is ADPCM variant .
>>>>>>
>>>>>> does:
>>>>>>
>>>>>> ffplay -avcodec adpcm_ima_oki input.wav
>>>>>>
>>>>>> plays anything
>>>>>>
>>>>>>> Stream mapping:
>>>>>>>>    Stream #0:0 -> #0:0 (? (?) -> mp3 (libmp3lame))
>>>>>>>> Decoder (codec none) not found for input stream #0:0


More information about the ffmpeg-user mailing list