Node.js - 错误:编写 EPIPE 代码:'EPIPE

MeV*_*MeV 2 node.js ffprobe node.js-stream

我在标准输入流上不断收到 EPIPE 错误,但找不到原因:

这是我的代码:

var checkFile = function(data, callback){
   var child_process = spawn('ffprobe', ['-print_format', 'json', '-show_format', 'pipe:0']);

   var stdInError = function(e) {
       console.log(e);
   }
   child_process.stdin.on('error', stdInError);

   var generalError = function() {
       console.log("general Error" + "\n");
   }
   child_process.on('error', generalError);

   child_process.stdout.on('data', function(data){
        console.log("data" + "\n");
        console.log(data);
        console.log("\n");
   });

   child_process.on('close', function(){
       console.log("close" + "\n");
   }

   var exit = function(){
       console.log("exit");
   }
   child_process.on('exit', exit);

   console.log("write" + "\n");
   child_process.stdin.write(data);
   child_process.stdin.end();
};
Run Code Online (Sandbox Code Playgroud)

这是我的输出:

write

data

<Buffer 7b 0a 20 20 20 20 22 66 6f 72 6d 61 74 22 3a 20 7b 0a 20 20 20 20 20 20 20 20 22 66 69 6c 65 6e 61 6d 65 22 3a 20 22 70 69 70 65 3a 30 22 2c 0a 20 20 20 ...>

data

<Buffer 0a 7d 0a>

{ [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'write' }

exit
close
Run Code Online (Sandbox Code Playgroud)

我找不到这个错误的原因,我也试图实现

child_process.stderr.on('data', function (data) {
    //throw errors
    console.log('stderr: ' + data);
});
Run Code Online (Sandbox Code Playgroud)

并且从 ffprobe(这是一个检查音频/视频文件规格的软件)打印的每一行都被标记为 stderr。例如:

stderr:ffprobe 版本 2.2.4 版权所有 (c) 2007-2014 FFmpeg 开发人员于 2014 年 7 月 2 日 15:07:45 使用 Apple LLVM 版本 5.1 (clang-503.0.40)(基于 LLVM 3.4svn)配置:-- prefix=/usr/local/Cellar/ffmpeg/2.2.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable- avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libfreetype -- enable-libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass --enable-ffplay - -enable-libspeex --enable-libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r --enable-libopenjpeg --extra-cflags='-I/usr/local/Cellar/openjpeg/1.5 .1_1/include/openjpeg-1.5 ' libavutil 52. 66.100 / 52. 66.100

标准错误:libavcodec 55. 52.102 / 55. 52.102 libavformat 55. 33.100 / 55. 33.100 libavdevice 55. 10.100 / 55. 10.100 libavfilter 4. 2.100.120 1 . 2.100.120 1.100.100 1.100.100 1.100 .100 .100.100 1.100.100 1.100.100.100.102 / 2. 5.102 libswresample 0. 18.100 / 0. 18.100 libpostproc 52. 3.100 / 52. 3.100

MeV*_*MeV 5

经过几次测试后,我发现了一个错误,该错误是由一个太大的文件引起的。

  • 打扰一下,文件大小与此有什么关系?我遇到了同样的错误,但是,我只是执行 stdin.write 命令(那里有一个短字符串) (2认同)