Skip to content Skip to sidebar Skip to footer

Coverting Webm To Wav With Ffmpeg

I've succesfully used ffmpeg in Python to convert mp3-files into wav so I can post them to Google Speech-To-Text. Now I have same situation with webm files and the old function I h

Solution 1:

You need to convert to pcm data:

ffmpeg -i ./big-buck-bunny_trailer.webm -c:a pcm_f32le ./out.wav

Output:

ffmpegversion4.2.3Copyright(c)2000-2020theFFmpegdevelopersbuiltwithAppleclangversion11.0.3(clang-1103.0.32.59)configuration:--prefix=/usr/local/Cellar/ffmpeg/4.2.3--enable-shared--enable-pthreads--enable-version3--enable-avresample--cc=clang--host-cflags=-fno-stack-check--host-ldflags=--enable-ffplay--enable-gnutls--enable-gpl--enable-libaom--enable-libbluray--enable-libdav1d--enable-libmp3lame--enable-libopus--enable-librubberband--enable-libsnappy--enable-libsrt--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=jacklibavutil56.31.100/56.31.100libavcodec58.54.100/58.54.100libavformat58.29.100/58.29.100libavdevice58.8.100/58.8.100libavfilter7.57.100/7.57.100libavresample4.0.0/4.0.0libswscale5.5.100/5.5.100libswresample3.5.100/3.5.100libpostproc55.5.100/55.5.100Input#0, matroska,webm, from './big-buck-bunny_trailer.webm':Metadata:encoder         :http://sourceforge.net/projects/yamkacreation_time   :2010-05-20T08:21:12.000000ZDuration:00:00:32.48,start:0.000000,bitrate:533kb/sStream#0:0(eng): Video: vp8, yuv420p(progressive), 640x360, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)Stream#0:1(eng): Audio: vorbis, 44100 Hz, mono, fltp (default)Stream mapping:Stream#0:1 -> #0:0 (vorbis (native) -> pcm_f32le (native))Press [q] tostop, [?] forhelpOutput#0, wav, to './out.wav':Metadata:ISFT            :Lavf58.29.100Stream#0:0(eng): Audio: pcm_f32le ([3][0][0][0] / 0x0003), 44100 Hz, mono, flt, 1411 kb/s (default)Metadata:encoder         :Lavc58.54.100pcm_f32lesize=5597kBtime=00:00:32.50bitrate=1410.7kbits/sspeed=625xvideo:0kB audio:5597kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:0.001989%

Solution 2:

No need to convert to WAV then do a separate command to segment. Just remove -c copy and do it all in one command:

def convert_and_split(filename):
    command = ['ffmpeg', '-i', filename, '-f', 'segment', '-segment_time', '15', 'out%09d.wav']
    subprocess.run(command,stdout=subprocess.PIPE,stdin=subprocess.PIPE)

-c copy enables stream copy mode. It is like a copy and paste, but you can't put Opus audio into WAV. Removing -c copy will allow ffmpeg to convert Opus to WAV.

Post a Comment for "Coverting Webm To Wav With Ffmpeg"