我运行这个命令:ffmpeg -f f32le -i pipe:0 -f wav pipe:1
ffmpeg version 4.1-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
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
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, f32le, from 'pipe:0':
Duration: N/A, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_f32le, 44100 Hz, mono, flt, 1411 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_f32le (native) -> pcm_s16le (native))
Output #0, wav, to 'pipe:1':
Metadata:
ISFT : Lavf58.20.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s
Metadata:
encoder : Lavc58.35.100 pcm_s16le
size= 15144kB time=00:02:55.82 bitrate= 705.6kbits/s speed= 352x
size= 30684kB time=00:05:56.24 bitrate= 705.6kbits/s speed= 356x
size= 32043kB time=00:06:12.01 bitrate= 705.6kbits/s speed= 354x
video:0kB audio:32042kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000238%
pipe:0
左声道的原始 PCM 数据在哪里这个文件。 这里是输出波形。
输出似乎半有效。它无法在 Quicktime 或 iTunes 中播放。当我尝试将其添加到 Ableton 项目时,我收到“无法读取 output.wav。它可能已损坏或未获得许可。”
但是,如果我只是将输出 wav 拖到 Chrome 中,它确实播放正常。
ffprobe 输出确认该文件存在某种问题。对于此命令:
ffprobe -loglevel verbose /Users/maximedupre/Desktop/Dropbox/Programming/api/gg.wav
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
[wav @ 0x7f81e3004a00] Ignoring maximum wav data size, file may be invalid
[wav @ 0x7f81e3004a00] parser not found for codec pcm_s16le, packets or times may be invalid.
[wav @ 0x7f81e3004a00] Estimating duration from bitrate, this may be inaccurate
Input #0, wav, from '/Users/maximedupre/Desktop/Dropbox/Programming/api/gg.wav':
Metadata:
encoder : Lavf58.20.100
Duration: 00:06:12.01, bitrate: 705 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 1 channels, s16, 705 kb/s
我如何修改我的 ffmpeg 命令来生成有效的 wav 文件?
干杯!
答案1
当输出通过管道等不可寻址协议写入时,FFmpeg 无法更新 WAVE 文件中的元数据。Quicktime 似乎依赖元数据来确定文件的有效性。您必须写入文件或其他可寻址协议。
ffmpeg -f f32le -i pipe:0 -f wav file-out.wav
顺便说一句,你的输入是立体声,所以应该是
ffmpeg -f f32le -channels 2 -i pipe:0 -f wav file-out.wav