作者guestaadd (nn)
看板Ajax
標題[node] request.abort()不刪除資料
時間Thu Oct 26 14:27:33 2017
各位大大好
目前想要實現的功能為遠端有一台IP camera透過VLC送stream
然後這邊有一個使用node.js架的網頁會開啟此stream並依照情況儲存影片
開啟stream並儲存沒什麼問題
但我想要停止錄影的時候,找不到適當的method使用
abort雖然可以中斷,但也會把我儲存的影片清空
stream格式為ogg,遠方ip camera在192.168.0.55:8080
filename = './video1.ogg';
file = fs.createWriteStream(filename);
if(req.body.record == 1) //recording
{
theRequest = request('
http://192.168.0.55:8080/');
theRequest.pipe(file);
}
else if(req.body.record == 0) //stop recording
{
theRequest.abort();
}
有查過node.js的網站的確也是說會把資料丟掉
https://nodejs.org/api/http.html#http_request_abort
想請問有其他method可以中斷又不丟掉資料
有試過先複製一份資料,但好像因為一直pipe的關係
複製後的檔案大小為0
試過lockfile也會出現error
程式碼為部分內容,如有需要其他部分會再補上
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 122.116.71.79
※ 文章網址: https://webptt.com/m.aspx?n=bbs/Ajax/M.1508999261.A.122.html
※ 編輯: guestaadd (122.116.71.79), 10/26/2017 14:30:47
※ 編輯: guestaadd (122.116.71.79), 10/26/2017 14:31:40
1F:→ DarkKnightX: 試試看 theRequest.unpipe() ? 10/29 07:59