欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Streaming ffmpeg with nodejs on web sockets to html
The last months we (with Sergi Lario) had some fun implementing a GUI to control a media server done by playmodes. We used web technologies and had the need to stream the content of the media server to our app. This article gave us the inspiration about how to easily stream video from ffmpeg to HTML5 canvas.
In resume, data gets streamed from ffmpeg through and is received frame by frame as Motion JPEG. Then we encoded the images as Base64, sent them over web sockets to the frontend and draw them to HTML.
Here follows a short description of the essential parts:
Nodejs starts a child process and receives the stream as Motion JPEG:
1
2
3
4
5
6
7
8
9
10
11
var ffmpeg = require('child_process').spawn("ffmpeg", [
"-re",
"-y",
"-i",
"
"-preset",
"ultrafast",
"-f",
"mjpeg",
"pipe:1"
]);
Actually this is the code to make it work on Linux (ubuntu 14.04 with ffmpeg 2.6), but I couldn’t make it run on Windows and really would apreciate any tips for that.
Data is received frame by frame and sent over web sockets (
socket.io) to the frontend. Here it would be nice to sharpen images using ImageMagick, but I didn’t have success with that part:
1
2
3
4
ffmpeg.stdout.on('data', function (data) {
var frame = new Buffer(data).toString('base64');
io.sockets.emit('canvas',frame);
});
Finally the data is received on the frontend and drawn as CSS background to HTML. Alternativly it can be painted directly into the canvas:
1
2
3
4
5
this.socket.on('canvas', function(data) {
try {
$('#videostream').css('background', 'transparent url(data:image/jpeg;base64,'+data+') top left / 100% 100% no-repeat');
} catch(e){ }
});
You find the test program here on github, these are the steps you have to follow to reproduce the described example:
1. Set up ffmpeg and make a test stream, for example using the webcam:
ffmpeg -f video4linux2 -i /dev/video0 -f h264 -vcodec libx264 -r 10 -s 160x144 -g 0 -b 800000 udp://127.0.0.1:1234
2. Adapt your directory and server IP and port and run node server program from server directory by typing:
node streamserver.js
3. Open browser, type your IP and port like http://localhost:8080/ and you should see your video stream embeded into the website.
Tags: canvasffmpegHTML5javascriptnodejssocket.iostreamvideo
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
HTML5 視頻直播(二)
Nginx+ffmpeg+ckplayer??当O控攝像頭在web頁(yè)面播放RTSP轉RTMP
web前端學(xué)習路線(xiàn)與書(shū)籍推薦
WebSocket實(shí)戰 | 新浪UED
NodeJS 常用模塊推薦
ffmpeg 常用命令
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久