0
$\begingroup$

I am collecting some data from jotform .wav widget. All the audio files are in .wav format. But when I tried to open the file using python

from pydub import AudioSegment
s = AudioSegment.from_wav(audio_path)

But it was giving error, So I tried to check whether .wav files are correctly encoded. I tried to convert existing .wav files into .wav format using FFmpeg in macOS.

This is the output I got :

$ ffmpeg -i count.wav new.wav
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mp3 @ 0x7ffa44807200] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from 'count.wav':
  Duration: 00:00:09.36, start: 0.000000, bitrate: 160 kb/s
    Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 160 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'new.wav':
  Metadata:
    ISFT            : Lavf58.29.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s
    Metadata:
      encoder         : Lavc58.54.100 pcm_s16le
size=    1755kB time=00:00:09.36 bitrate=1536.1kbits/s speed= 339x    
video:0kB audio:1755kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.004340%

Confusing part is if it is already .wav file then FFmpeg won't increase or decrease size while converting in same format, but after I used FFmpeg to convert this .wav to .wav it's size increased from 187KB to 1.8 MB

I thought maybe that's how FFmpeg works, so I downloaded one .wav format from internet and tried same command, but on this .wav file the size didn't increase or decrease, the size was same.

$ ffmpeg -i file_example_WAV_1MG.wav check2.wav 
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[wav @ 0x7f9726007400] Discarding ID3 tags because more suitable tags were found.
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'file_example_WAV_1MG.wav':
  Metadata:
    title           : Impact Moderato
    album           : YouTube Audio Library
    artist          : Kevin MacLeod
    genre           : Cinematic
  Duration: 00:00:33.53, bitrate: 256 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, stereo, s16, 256 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, wav, to 'check2.wav':
  Metadata:
    INAM            : Impact Moderato
    IPRD            : YouTube Audio Library
    IART            : Kevin MacLeod
    IGNR            : Cinematic
    ISFT            : Lavf58.29.100
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 8000 Hz, stereo, s16, 256 kb/s
    Metadata:
      encoder         : Lavc58.54.100 pcm_s16le
size=    1048kB time=00:00:33.52 bitrate= 256.0kbits/s speed=2.83e+03x    
video:0kB audio:1048kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.016031%

I am confused about which format jotform is using to store the audio files because the extension says .wav but it's not opening in pyaudio and also FFmpeg is converting in .wav with bigger size, which indicates that the raw format is not actually .wav it's the compressed version?

I am uploading the .wav file here

$\endgroup$
  • $\begingroup$ Some pretty good clues in the output $\endgroup$ – Dan Szabo Jun 29 at 12:34
  • 1
    $\begingroup$ It says everything in the log - good old mp3: Input #0, mp3, from 'count.wav': Duration: 00:00:09.36, start: 0.000000, bitrate: 160 kb/s Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 160 kb/s $\endgroup$ – jojek Jun 29 at 13:41
0
$\begingroup$

Both files play in the VLC media player. Looking at the coder information, the first "I downloaded one .wav format from internet" gets this (in French for the tags, sorry)

PCM file and the second one you created:

MP3 file

So likely, one in PCM encoded, the other is referred to as MPEG audio.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.