This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEmail = (email = null) => { | |
const regex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return regex.test(email); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require('child_process'); | |
const youtube_stream_key = ''; | |
const frame_rate = 30; | |
const streamCommand = `/usr/local/bin/ffmpeg -f avfoundation -i "0:0" -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -r 30 -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv rtmp://a.rtmp.youtube.com/live2/${youtube_stream_key}` | |
const ls = exec(streamCommand); | |
ls.stderr.on('data', (data) => { | |
console.log(`Streaming data: ${data}`); | |
}); | |
ls.on('close', (code) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conf nginx with rtmp module | |
#### Command | |
brew tap homebrew/nginx | |
brew options nginx-full | |
brew info nginx-full | |
brew install nginx-full --with-rtmp-module --with-debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/local/bin/ffmpeg -f avfoundation -r 30 -i "0:0" -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset medium -g 60 -b:v 2500k -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv rtmp://localhost/show/stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nginx.conf | |
worker_processes auto; | |
events { | |
worker_connections 1024; | |
} | |
## HLS server streaming | |
rtmp { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet.protocol import ReconnectingClientFactory | |
from autobahn.twisted.websocket import WebSocketClientProtocol, WebSocketClientFactory | |
import json | |
import subprocess | |
server = "127.0.0.1" # Server IP Address or domain eg: tabvn.com | |
port = 3001 # Server Port | |
streaming_process = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import WebSocket from 'uws' | |
import { config } from './config' | |
import _ from 'lodash' | |
export default class WebSocketClient { | |
constructor (options) { | |
this.connect = this.connect.bind(this) | |
this.reconnect = this.reconnect.bind(this) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// homework | |
// | |
// Created by Toan on 9/16/18. | |
// Copyright © 2018 Toan. All rights reserved. | |
// | |
#include <iostream> | |
#include "math.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// homework | |
// | |
// Created by Toan on 9/18/18. | |
// Copyright © 2018 Toan. All rights reserved. | |
// | |
#include <iostream> | |
using namespace std; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.cpp | |
// homework | |
// | |
// Created by Toan on 9/18/18. | |
// Copyright © 2018 Toan. All rights reserved. | |
// | |
#include <iostream> | |
using namespace std; |
OlderNewer