2014-10-30 134 views
2

我不斷收到EPIPE錯誤,我無法找到一個理由:的Node.js - 錯誤:寫EPIPE代碼:標準輸入流「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(); 
}; 

而且這是我的輸出:

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 

我找不到此錯誤的原因,我也試圖實現

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

並且從ffprobe(它是檢查音頻/視頻文件規格的軟件)打印的每一行都標記爲stderr。例如:

stderr:ffprobe版本2.2.4版權所有(c)2007-2014 FFmpeg開發人員 建立於2014年7月2日15:07:45蘋果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 - 額外CFLAGS = ' - I/USR /本地/地窖/ openjpeg/1.5.1_1 /包含/ openjpeg-1.5' libavutil 52. 66.100/52 66.100

標準錯誤:libavcodec的55 52.102/52.102 55. 了libavformat 55. 33.100/33.100 55. libavdevice 55. 10.100/10.100 55. libavfilter 4. 2.100/2.100 4 libavresample 1. 2. 0/1。2. 0 libswscale 2. 5.102/2 5.102 libswresample 0.18.100/0.18.100 libpostproc 52. 3.100/52. 3.100

+0

你使用什麼節點版本? – mscdex 2014-10-30 16:24:26

+0

另外,你是否試過''-i','pipe:0'而不是'pipe:0'? – mscdex 2014-10-30 16:28:45

+0

v0.10.28 @mscdex – MeV 2014-10-30 16:40:18

回答

3

經過幾次測試,我發現一個錯誤,並且錯誤是由一個太大的文件引起的。

+0

你是如何解決這個問題的? – 2016-05-12 09:39:13

+0

在我的情況下,上傳的文件太大,減少了它的大小,防止了錯誤 – MeV 2016-05-12 13:36:18