2016年7月27日 星期三

RTMP

https://www.vultr.com/docs/setup-nginx-rtmp-on-ubuntu-14-04 Setup Nginx-RTMP on Ubuntu 14.04 Modified on: Wed, Jul 20, 2016 at 5:45 pm EST Linux Guides Ubuntu Web Servers RTMP is great for serving live content. When RTMP is paired with FFmpeg, streams can be converted into various qualities. Vultr is great for these applications as they provide fast and dedicated CPU performance. Vultr’s global network also ensures that you can deliver high quality live content with minimal delay. Lets get started! Installing Nginx and Nginx-RTMP Install the tools required to compile Nginx and Nginx-RTMP from source. sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev Make a working directory and switch to it. mkdir ~/working cd ~/working Download the Nginx and Nginx-RTMP source. wget http://nginx.org/download/nginx-1.7.5.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip Install the Unzip package. sudo apt-get install unzip Extract the Nginx and Nginx-RTMP source. tar -zxvf nginx-1.7.5.tar.gz unzip master.zip Switch to the Nginx directory. cd nginx-1.7.5 Add modules that Nginx will be compiled with. Nginx-RTMP is included. ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master Compile and install Nginx with Nginx-RTMP. make sudo make install Install the Nginx init scripts. sudo wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx sudo chmod +x /etc/init.d/nginx sudo update-rc.d nginx defaults Start and stop Nginx to generate configuration files. sudo service nginx start sudo service nginx stop Installing FFmpeg Add the FFmpeg PPA. sudo apt-get install software-properties-common sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next Update the package lists. sudo apt-get update Install FFmpeg. sudo apt-get install ffmpeg Note: The apt-add-repository command may not be installed in some cases. To install it run sudo apt-get install software-properties-common. Configuring Nginx-RTMP and FFmpeg Open the Nginx configuration file. sudo nano /usr/local/nginx/conf/nginx.conf Append the following. rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; exec ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name; } application live360p { live on; record off; } } } After you've added the above, you can customize settings such a video bitrate, audio bitrate and resolution. These changes will only be applied to the lower quality stream. To add more qualities, copy and paste the exec ffmpeg line and change the settings. You'll also need to create a new application. You can do this by copying and pasting the live360 example that has been included. Don't forget to update the exec ffmpeg line with the address of the new application. You can do this by changing the final RTMP address in the exec ffmpeg line. Note: Changing the value after -b:v will change the video bitrate. This is measured in kilobits per second. Changing the value after -b:a will change the audio bitrate. This is measured in kilobits per second. Changing the value after -s will change the resolution. Save the file by pressing Control and X together. Restart Nginx. sudo service nginx restart Note: For best performance, each stream being converted should have its own CPU core. For example two qualities, 360P and 480P are being created from a 720P stream. A Vultr instance with at least two CPU cores should be used. Security Note If you're using a firewall, you'll need to make sure TCP 1935 is allowed. The current configuartion allows anyone to stream to your server. We can fix this by only allowing certain IP addresses the publish permission. Open the Nginx configuration. sudo nano /usr/local/nginx/conf/nginx.conf Look for the following lines. live on; record off; Add the following to each set of the above lines. Change 0.0.0.0 to your IP address. allow publish 127.0.0.1; allow publish 0.0.0.0; deny publish all; The configuration should now look something like this. rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; allow publish 127.0.0.1; allow publish 0.0.0.0; deny publish all; exec ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name; } application live360p { live on; record off; allow publish 127.0.0.1; allow publish 0.0.0.0; deny publish all; } } } Save the file by pressing Control and X together. Restart Nginx. sudo service nginx restart Configuring Software to Work with Nginx-RTMP Streaming applications typically have two fields for connection information. The first field is usually for the server information and the second field is usually for the stream name or key. The information that you should place into each field is listed. The stream name or key can be set to anything. Field 1: rtmp://your.vultr.ip/live/ Field 2: stream-key-you-set To view streams open the following links in a player supporting RTMP. rtmp://your.vultr.ip/live/stream-key-you-set rtmp://your.vultr.ip/live360p/stream-key-you-set

2016年7月26日 星期二

openswan

sudo /etc/init.d/ipsec restart sudo ipsec auto --add test sudo ipsec whack --name test --listen --initiate conn test left=%eth2 leftsourceip=10.20.90.1 leftsubnet=10.20.90.0/24 # leftid=116.59.9.76 leftid=@00A6C2278850 right=61.216.103.2 # rightid=61.216.103.2 rightid=@18B1690131A0 rightsubnet=10.9.8.0/24 rightnexthop=10.9.8.254 rekeymargin=3m keyingtries=2 pfs=no aggrmode=yes ike=3des-sha1-modp1024 # ikev2=yes phase2=esp phase2alg=3des-sha1 authby=secret ikelifetime=28800s auto=start rm /var/run/pluto -rf mkdir /var/run/pluto -p ifconfig ppp0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' echo @00A6C2278850 @18B1690131A0 : PSK \"25683366\" > /etc/ipsec.secrets killall -9 pluto /usr/libexec/ipsec/pluto --stderrlog --nofork --use-netkey --secretsfile /etc/ipsec.secrets --nat_traversal & /usr/libexec/ipsec/whack --name sonic --ipv4 --host 10.183.128.223 --client 10.20.90.0/24 --srcip 10.20.90.1 --id @00A6C2278850 --to --host 61.216.103.2 --client 10.9.8.0/24 --srcip 61.216.103.2 --id @18B1690131A0 --esp 3des-sha1 --ike 3des-sha1-modp1024 --encrypt --psk --aggrmode /usr/libexec/ipsec/whack --name sonic --listen --initiate

2016年7月22日 星期五

SDK

https://www.dropbox.com/sh/8pyvpyccs56flq2/AACDWO5ig2-GvOeJoEpw8urha?dl=0

2016年7月11日 星期一

testtw

var watson = require('watson-developer-cloud'); var fs = require('fs'); var cp = require('child_process'); var Sound = require('node-aplay'); console.log('start tw watson regonition'); opencmd(); function opencmd() { var speech_to_text = watson.speech_to_text({ username: 'c8090707-bcda-49e0-98f9-172c40420c1a', password: 'cZGWayUpvsSJ', version: 'v1' }); var params = { content_type: 'audio/wav', model: 'zh-CN_BroadbandModel', continuous: true }; // create the stream var recognizeStream = speech_to_text.createRecognizeStream(params); // pipe in some audio //fs.createReadStream('/home/pi/voice/interlude/help.wav').pipe(recognizeStream); // start the recording var mic = cp.spawn('arecord', ['--device=plughw:0,0', '--format=S16_LE', '--rate=44100', '--channels=1']); //, '--duration=10' mic.stderr.pipe(process.stderr); // save a local copy of your audio (in addition to streaming it) by uncommenting this //mic.stdout.pipe(require('fs').createWriteStream('test.wav')); // optionally compress, and then pipe the audio to the STT service mic.stdout.pipe(recognizeStream); // alternate option for testing: comment out all of the mic/flac stuff and pipe from a file //require('fs').createReadStream('test.wav').pipe(transcriptInput); //new Sound('/home/pi/voice/interlude/pleasesay.wav').play(); // end the recording setTimeout(function() { mic.kill(); }, 45* 5000); // and pipe out the transcription //recognizeStream.pipe(fs.createWriteStream('transcription.txt')); //new Sound('/home/pi/voice/interlude/pleasesay.wav').play(); // listen for 'data' events for just the final text // listen for 'results' events to get the raw JSON with interim results, timings, etc. recognizeStream.setEncoding('utf8'); // to get strings instead of Buffers from `data` events /* // listen for 'data' events for just the final text recognizeStream.on('results', function(data) { if(data.results[0] && data.results[0].final && data.results[0].alternatives) { console.log('xxxxx'+data.results[0].alternatives[0].transcript); } //console.log.bind(console, 'data event: '); //var transcription = converter.toBuffer(); //console.log(transcription); }); */ // listen for 'data' events for just the final text recognizeStream.on('error', function() { console.log.bind(console, 'error event: '); //var transcription = converter.toBuffer(); // console.log(transcription); }); // listen for 'data' events for just the final text recognizeStream.on('data', function(data) { console.log('xxxxx'+data); console.log.bind(console, 'data event: '); // var transcription = converter.toBuffer(); // console.log(transcription); }); //['data', 'error', 'connection-close'].forEach(function(eventName) { // recognizeStream.on(eventName, console.log.bind(console, eventName + ' event: ')); //}); }

0109temp.js

var watson = require('watson-developer-cloud'); var mqtt = require('mqtt'); var clientId = ['d', "49fhje", "vehicle", "mycar"].join(':'); iot_client = mqtt.connect("mqtt://49fhje.messaging.internetofthings.ibmcloud.com:1883", { "clientId" : clientId, "keepalive" : 30, "username" : "use-token-auth", "password" : "yz(GjvSahc95RQ2jEo" }); var temploop=[ 12, 33, 22, 34, 26, 35, 27]; var i=0; iot_client.on('connect', function() { console.log('Temp client connected to IBM IoT Cloud.'); var interval = setInterval(function() { console.log("temp: " + temploop[i%7]); iot_client.publish('iot-2/evt/temp/fmt/json', '{"d":{"temp": '+ temploop[i%7] +' }}'); i++; }, 2000); } ); iot_client.subscribe('iot-2/cmd/+/fmt/+', function(err, granted){ console.log('subscribed command, granted: '+ JSON.stringify(granted)); }); iot_client.on("message", function(topic,payload){ console.log('received topic:'+topic+', payload:'+payload);});

2016年7月10日 星期日

https://sourceforge.net/projects/sox/files/latest/download?source-files

2015年7月29日 星期三

<方有毅>In addition to / Besides / Apart from / Except / Except for 之差別(純
學術無廣告)

In addition to
adv. 修飾整句,除。。。之外,還。。。(添加別的)
1. 除…之外,還……(somebody/something)
2. 除……之外,並且……
In addition to French, he has to study Japanese.
除了法語外,他還得學日語。
In addition to giving a general introduction to computers, the course also
provides practical experience.
課程除了介紹一般電腦知識外, 還提供實際操作的機會.

Besides
而且; 此外; 以及; 更
prep.(表示排斥)除…之外(還有); 在…之外(更有),X…之餘兼有Y.
1. prep 此外;另外;除了
Besides something or beside something means in addition to it.
I think she has many good qualities besides being very beautiful...
我覺得她不但長得非常漂亮,而且還有很多優秀品質。
There was only one person besides Ford who knew Julia Jameson.
除了福特以外,只有一個人認識朱麗亞‧詹姆森。
2. adv.
You get to sample lots of baked things and take home masses of cookies
besides.
您不僅可以品嘗各種烘烤糕點,還可以帶很多餅乾回家。
Fruit will give you, besides enjoyment, a source of vitamins
水果不但好吃,而且富含維生素。

*但應注意,用於談論除某人或某物之外*唯一的*人或物時, besides 的意思與 apart from 相同:He was the only person besides Gertrude who talked to Guy
除了格特魯德以外,他是唯一和蓋伊說話的人

Apart from
1. 除此之外(表示除…以外別無) ; 離開,脫離
I've finished apart from the last question.
除了最後一道題,我全做完了。
Apart from some spelling mistakes, the composition is fairly good.
除了一些拼寫錯誤,這篇文章寫得很不錯。
I have nothing more to ask you about apart from these questions.
除了這些問題,我沒有別的要瞭解了。
 Apart from [ Except for ] a few grammatical mistakes, this composition of
yours is wellwritten.
除了幾處語法錯誤之外, 你這篇作文寫得不錯.

離開:
There can be no knowledge apart from practice.
離開實踐就沒有知識.

2. 除此之外(表示除…以外尚有),此外,加之
Apart from his intelligence, he was tirelessly industrious.
除了很聰穎之外, 他還是一個孜孜不倦的勤奮的人.
Apart from gold, the Indians sought tin and offered trinkets in exchange.
除黃金外, 印度人還尋找錫,並用小飾品來交易.
Apart from the cost, it will take a lot of time.
除了費錢以外, 還要花很多時間.
Apart from the body of the book there are three informative appendices.
除正文外,該書還有三個資料豐富的附錄.

Except
except 用來引出陳述中”唯一不適用”的事物、情形、人或想法:
All of his body relaxed except his right hand.
除了右手以外(唯一不適用後面放鬆的情形),他全身上下都放鬆了
Travelling was impossible, except in the cool of the morning.
除了在涼爽的早晨(唯一不適用後面不出門的時候),其他時候出門是不可能的
Except for
except for 用於引出使某說法不能完全成立的事物:
The classrooms were silent, except for the scratching of pens on paper.
除了鋼筆在紙上發出的沙沙聲(使後面說法不能完全成立),教室裏一片寂靜
I had absolutely no friends except for Tom.
除了湯姆,我一個朋友也沒有(使前面說法不能完全成立)