-
The Node server and client both use the full-duplex communication protocol module provided by socket. IO
IO NPM I socket. IO # NPM I socket. IOCopy the code
-
LIVE roles are divided into the host side and the audience side. Users can identify login status through the shared session and assign LIVE or watch permissions.
NPM I express-socket.io-session is used to share sessions with socket. IOCopy the code
-
To ensure security, Chrome forbids calls to pages that are not transmitted over HTTPs to obtain media rights. Firefox does not.
/ / processing each browser compatibility navigator. GetUserMedia. = the navigator getUserMedia | | the navigator. WebkitGetUserMedia | | navigator.mozGetUserMedia; GetUserMedia ({audio: false, video: {width: videoWidth, height: vidoeHeight }}, onsuccess, onerror )Copy the code
-
The video frame is encoded as Base64 and the image is transmitted to the server through websocket protocol.
// The first parameter can be 'image/ PNG ', 'image/jpeg', 'image/webm' const quality =.5 Canvas. ToDataURL ('image/webp', quality)Copy the code
-
About Base64 encryption and decryption
// Encode base64 data bTOA ('shuaihua') // c2h1YWlodWE= // decode base64 data atob('c2h1YWlodWE=') // shuaihuaCopy the code
-
Ffmpeg extracts video frames at regular intervals and outputs them as image files
Output a frame of 300*250 size image every 0.2 seconds, name the image by serial number, Image format of JPG ffmpeg - i. / movie/videoplayback mp4 -f image2 - vf FPS = FPS = 1 /. Surprised 2-300 x250% s jeter pgCopy the code