ffmpeg在将wav转换为flac时抛出错误

时间:2017-08-24 20:16:55

标签: ffmpeg wav flac

我正在研究一个研究项目,它要求我首先从浏览器录制音频(使用getuserMedia)并以wav格式保存。我的代码如下所示:

navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
        const chunks = [];
        const recorder = new MediaRecorder(stream);
        recorder.ondataavailable = e => {
            chunks.push(e.data);
            if (recorder.state == 'inactive') {
                $scope.blob = new Blob(chunks, { type: 'audio/wav' });
                $scope.file = new File([$scope.blob], "myFile.wav", {type: 'audio/wav', lastModified: Date.now()});

                $scope.blobUrl = URL.createObjectURL($scope.blob);
                createAudioElement($scope.blobUrl);
            }
        };
        recorder.start(1000);
        $scope.stop = function() {
            recorder.stop();    
        };

    }).catch(console.error);

在文件系统上保存$ scope.file后,我使用ffmpeg实用程序([https://www.ffmpeg.org/)将其转换为flac格式。

现在我的问题是ffmpeg工具有时会给我一个错误,说这个文件无法被识别为wav文件。 ffmpeg工具的确切输出是:

  ffmpeg-user: Wav to Flac conversion: Invalid data found when processing input

  ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers 
  built with Apple LLVM version 7.0.2 (clang-700.1.81) 
  configuration: --prefix=/usr/local/Cellar/ffmpeg/3.3.3 --enable-shared 
  --enable-pthreads --enable-gpl --enable-version3 
  --enable-hardcoded-tables 
  --enable-avresample --cc=clang --host-cflags= --host-ldflags= 
  --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl 

  --disable-lzma --enable-vda 
  libavutil      55. 58.100 / 55. 58.100 
  libavcodec     57. 89.100 / 57. 89.100 
  libavformat    57. 71.100 / 57. 71.100 
  libavdevice    57.  6.100 / 57.  6.100 
  libavfilter     6. 82.100 /  6. 82.100 
  libavresample   3.  5.  0 /  3.  5.  0 
  libswscale      4.  6.100 /  4.  6.100 
  libswresample   2.  7.100 /  2.  7.100 
  libpostproc    54.  5.100 / 54.  5.100 

有谁知道我为什么会收到此错误?

0 个答案:

没有答案
相关问题