Saturday, January 20, 2018

audio - ffmpeg wav to pcm and back (invalid data found)



I'm having problems getting ffmpeg to convert wav to pcm.



I want to convert



A WAV file pcm_s24le, 44100 Hz, mono, s32 (24 bit), 1058 kb/s


to




A RAW (PCM) file s16le, 48000 Hz, mono


I've tried even doing it in two steps:



ffmpeg -i step0.wav -sample_fmt s16 -ac 1 -ar 48000 step1.wav
ffmpeg -i step1.wav -f s16le -acodec pcm_s16le -ac 1 -ar 48000 step2.pcm



However, when I try to verify the conversion was correct:



ffmpeg -i step2.pcm -ar 48000 -ac 1 -f s16le step3.wav


I get



step2.pcm: Invalid data found when processing input



What am I doing wrong?
Thanks.



P.S. Software and file in question:



This is the ffmpeg version:



ffmpeg version n4.1.3 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181127
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3

libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100



And in case it's the file, that's the problem - I am trying to convert "kick-808.wav" downloaded from http://99sounds.org/drum-samples/


Answer



In FFmpeg the input options go before the input file. So to open a raw PCM file you need



ffmpeg -ar 48000 -ac 1 -f s16le -i step2.pcm step3.wav


This is not an issue opening a file with a container format (e.g. wav), as these informations are part of the container headers.


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...