2017年3月30日星期四

转: 在命令行临时指定pip的源

经常在使用Python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的烦恼。
网上有很多可用的源,例如豆瓣:http://pypi.douban.com/simple/
                                          清华:https://pypi.tuna.tsinghua.edu.cn/simple
最近使用得比较多并且比较顺手的是清华大学的pip源,它是官网pypi的镜像,每隔5分钟同步一次,地址为 https://pypi.tuna.tsinghua.edu.cn/simple
 
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple gevent,这样就会从清华这边的镜像去安装gevent库。
 
永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple
 
windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
 
 [global]
 index-url = https://pypi.tuna.tsinghua.edu.cn/simple

2017年3月28日星期二

IronPython clr.AddReferenceToFile Error

 问题:在脚本中可以执行,但在交互解释器中出错。

 IronPython Tutorial
clr.AddReferenceToFile adds reference to the assembly specified by its file name. This function will load the assembly from the file regardless of the assembly version. As a result, it doesn't guarantee that the correct assembly version is being loaded. To guarantee that correct assembly version is being loaded, use clr.AddReferenceByName. Moreover, AddReferenceToFile requires that the assembly be located in a directory listed in sys.path.

how-to-use-a-c-sharp-dll-in-ironpython

import sys
import os

sys.path.insert(0, os.getcwd())


将脚本编译为可执行文件:
ipyc.exe /main:ymmj.py ymmj.py /platform:x64 /target:exe /standalone

miniupnp端口映射

$ upnpc
upnpc : miniupnpc library test client. (c) 2005-2014 Thomas Bernard
Go to http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
for more information.
Usage :    upnpc [options] -a ip port external_port protocol [duration]
        Add port redirection
           upnpc [options] -d external_port protocol [port2 protocol2] [...]
        Delete port redirection
           upnpc [options] -s
        Get Connection status
           upnpc [options] -l
        List redirections
           upnpc [options] -L
        List redirections (using GetListOfPortMappings (for IGD:2 only)
           upnpc [options] -n ip port external_port protocol [duration]
        Add (any) port redirection allowing IGD to use alternative external_port (for IGD:2 only)
           upnpc [options] -N external_port_start external_port_end protocol [manage]
        Delete range of port redirections (for IGD:2 only)
           upnpc [options] -r port1 protocol1 [port2 protocol2] [...]
        Add all redirections to the current host
           upnpc [options] -A remote_ip remote_port internal_ip internal_port protocol lease_time
        Add Pinhole (for IGD:2 only)
           upnpc [options] -U uniqueID new_lease_time
        Update Pinhole (for IGD:2 only)
           upnpc [options] -C uniqueID
        Check if Pinhole is Working (for IGD:2 only)
           upnpc [options] -K uniqueID
        Get Number of packets going through the rule (for IGD:2 only)
           upnpc [options] -D uniqueID
        Delete Pinhole (for IGD:2 only)
           upnpc [options] -S
        Get Firewall status (for IGD:2 only)
           upnpc [options] -G remote_ip remote_port internal_ip internal_port protocol
        Get Outbound Pinhole Timeout (for IGD:2 only)
           upnpc [options] -P
        Get Presentation url

protocol is UDP or TCP
Options:
  -e description : set description for port mapping.
  -6 : use ip v6 instead of ip v4.
  -u url : bypass discovery process by providing the XML root description url.
  -m address/interface : provide ip address (ip v4) or interface name (ip v4 or v6) to use for sending SSDP multicast packets.
  -p path : use this path for MiniSSDPd socket.

2017年3月25日星期六

How to install the latest Python version on Debian separately or upgrade?

How to install the latest Python version on Debian separately or upgrade?


Fixing an AVI index with mencoder

 Fixing an AVI index with mencoder

Fixing an AVI index with mencoder
This is more a “note to self”, but I’m sure others find it useful as well.

Quite often I run across AVI files with a broken index. That index is used in media players to seek rapidly in the movie file. Without an index or with a corrupt index, seeking either does not work at all or takes a long time.

mencoder, which is available on almost any platform, allows you to massage AVI files besides tons of other operations on a never-ending list of video formats.

Here’s the command to repair a broken AVI index (I used the mplayer/mencoder version that comes with the FreeBSD ports collection):

$ mencoder -idx in.avi -ovc copy -oac copy -o out.avi

2017年3月12日星期日

知呼:OS X 系统自带的截图快捷键

OS X 系统自带的截图快捷键

作者:陈浩
链接:https://www.zhihu.com/question/19550327/answer/12222576
来源:知乎
著作权归作者所有,转载请联系作者获得授权。

Cmd+Shift+3:全屏截图;截取整个屏幕,保存截图至桌面文件夹。
Cmd+Shift+4:区域截图;鼠标光标变成带坐标的小十字,通过拖拽截取特定区域,保存截图至桌面文件夹。
Cmd+Shift+4 - 单击空格键 - 鼠标单击指定窗口:窗口截图;出现小十字光标后对指定窗口按空格键,鼠标光标变成照相机,鼠标单击截取指定窗口,保存截图至桌面文件夹。
  • 进阶快捷键

  • Cmd+Shift+4 - 按住空格键拖动鼠标:区域截图;选取区域范围后,按住空格键并拖到鼠标可移动选取范围,释放按键后保存截图至桌面文件夹。
    Cmd+Shift+4 - 按住Shift - 上下/左右移动鼠标:区域截图;选取区域范围后,按住 Shift 并上下/左右移动鼠标即可固定选取范围宽度/高度改变高度/宽度,释放按键后保存截图至桌面文件夹。
    Cmd+Shift+4 - 按住Shift和Option: 区域截图;选取区域范围后,按住 Shift 和 Option 键在上一快捷键功能的基础上自由切换高度宽度,释放按键后保存截图至桌面文件夹。
    Cmd+Shift+4 - 按住Option: 区域截图;选取区域范围后,按住 Option 键可按比例缩放选取范围,释放按键后保存截图至桌面文件夹。
    PS:以上介绍的快捷键配合按住 Control 键即可将截图文件保存在剪切板,以供调用。

    2017年3月7日星期二

    使用mailx发送qq邮件

    本文出自 “宁静致远” 博客,
    请务必保留此出处http://irow10.blog.51cto.com/2425361/1812638

    mailx安装我就不介绍了,很简单!我先介绍下系统的版本和mailx的版本

    [root@localhost ~]# mailx -V
    12.4 7/29/08
    [root@localhost ~]# cat /etc/issue
    CentOS release 6.8 (Final)
    Kernel \r on an \m

    mailx的配置文件在/etc/mail.rc(我是rpm安装的)

    在配置文件中添加下面的代码(passwd写开通smtp客户端给的授权码)
       
    set from=usernam@163.com
    set smtp=smtp.163.com
    set smtp-auth-user=username@163.com
    set smtp-auth-password=passwd
    set smtp-auth=login

    测试下是否可以使用
       
    cat /opt/tesh |mailx -v -s 'hello' '*****@163.com'

    测试发现有时能发送,有时会退信并报以下错误:
       
    554 DT:SPM 163 smtp3,DdGowACX1p2fRn9X_lIIAA--.2018S2 1467958944,please see http://mail.163.com/help/help_spam_16.htm?ip=*.*.*.*&hostid=smtp3&time=1467958944
    smtp-server: 554 DT:SPM 163 smtp3,DdGowACX1p2fRn9X_lIIAA--.2018S2 1467958944,please see http://mail.163.com/help/help_spam_16.htm?ip=*.*.*.*&hostid=smtp3&time=1467958944
    "/root/dead.letter" 0/0
    . . . message not sent.

    554 DT:SPM 发送的邮件内容包含了未被许可的信息,或被系统识别为垃圾邮件。请检查是否有用户发送病毒或者垃圾邮件

    查了下原因,因为163反垃圾邮件设置的原因,所有我采用了qq邮箱及hostmail

    qq邮箱

       
    set from=224******53@qq.com
    set smtp=smtp.qq.com
    set smtp-auth-user=224******53@qq.com
    set smtp-auth-password=euia********chb   #授权码
    set smtp-auth=login

    错误提示:

    530 Error: A secure connection is requiered(such as ssl). More information at http://service.mail.qq.com/cgi-bin/help?id=28

    smtp-server: 530 Error: A secure connection is requiered(such as ssl). More information at http://service.mail.qq.com/cgi-bin/help?id=28

    "/root/dead.letter" 19/438

    . . . message not sent

    于是我改了下配置文件添加了几个参数

       
    set from=224******53@qq.com
    set smtp=smtp.qq.com
    set smtp-auth-user=224******53@qq.com
    set smtp-auth-password=euia********chb
    set smtp-auth=login
    set smtp-use-starttls
    set ssl-verify=ignore
    set nss-config-dir=/etc/pki/nssdb/

    邮件发送成功,在/etc/pki/nssdb/有证书文件

    当然还有两个方式可以获取证书文件

       
    mkdir -p /root/.certs/
    echo -n | openssl s_client -connect smtp.qq.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/qq.crt
    certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/qq.crt
    certutil -L -d /root/.certs

    然后mail.rc的配置文件改成
       
    set from=224******53@qq.com
    set smtp=smtp.qq.com
    set smtp-auth-user=224******53@qq.com
    set smtp-auth-password=euia********chb
    set smtp-auth=login
    set smtp-use-starttls
    set ssl-verify=ignore
    set nss-config-dir=/root/.certs

    有些邮箱无法通过上述方式获取证书,我们可以在装有火狐浏览器的服务器中把证书拷贝过来

       
    [root@localhost test]# cd /home/test/.mozilla/firefox/twmiqm5n.default/
    [root@localhost twmiqm5n.default]# ll *db
    -rw-------. 1 test test 65536 Jul  7 16:29 cert8.db
    -rw-------. 1 test test 16384 Jul  7 16:29 key3.db
    -rw-------. 1 test test 16384 May 28 20:38 secmod.db

    把这个三个文件拷贝到指定文件下。比如:/root/.certs1

       
    set from=224******53@qq.com
    set smtp=smtp.qq.com
    set smtp-auth-user=224******53@qq.com
    set smtp-auth-password=euia********chb
    set smtp-auth=login
    set smtp-use-starttls
    set ssl-verify=ignore
    set nss-config-dir=/root/.certs1

    mailx的操作还是蛮简单的,就是一直报一个错误

    Error in certificate: Peer's certificate issuer is not recognized.

    证书没有获得认可

    解决方法:找个存放证书的目录

       
    [root@localhost .certs]# pwd
    /root/.certs
    [root@localhost .certs]# ll
    total 80
    -rw-------. 1 root root 65536 Jul  8 15:13 cert8.db
    -rw-r--r--. 1 root root  2293 Jul  7 16:25 qq.crt
    -rw-------. 1 root root 16384 Jul  8 15:13 key3.db
    -rw-------. 1 root root 16384 Jul  7 16:24 secmod.db
    [root@localhost .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu"  -d ./ -i qq.crt
    Notice: Trust flag u is set automatically if the private key is present.

    这样就不会报错了。

       
    Resolving host smtp.qq.com . . . done.
    Connecting to *.*.*.* . . . connected.
    220 smtp.qq.com Esmtp QQ Mail Server
    >>> EHLO localhost
    250-smtp.qq.com
    250-PIPELINING
    250-SIZE 73400320
    250-STARTTLS
    250-AUTH LOGIN PLAIN
    250-AUTH=LOGIN
    250-MAILCOMPRESS
    250 8BITMIME
    >>> STARTTLS
    220 Ready to start TLS
    Comparing DNS name: "mx2.qq.com"
    ................................
    Comparing DNS name: "smtp.qq.com"
    SSL parameters: cipher=AES-256, keysize=256, secretkeysize=256,
    issuer=CN=GeoTrust SSL CA - G3,O=GeoTrust Inc.,C=US
    subject=CN=pop.qq.com,OU=R&D,O=Shenzhen Tencent Computer Systems Company Limited,L=Shenzhen,ST=Guangdong,C=CN
    >>> EHLO localhost
    250-smtp.qq.com
    250-PIPELINING
    250-SIZE 73400320
    250-AUTH LOGIN PLAIN
    250-AUTH=LOGIN
    250-MAILCOMPRESS
    250 8BITMIME
    >>> AUTH LOGIN
    334 VXNlcm5hbWU6
    >>> MjI0Njk0NTU1M0BxcS5jb20=
    334 UGFzc3dvcmQ6
    >>> ZXVpYXl1a3JrZ3JoZWNoYg==
    235 Authentication successful
    >>> MAIL FROM:<22******53@qq.com>
    250 Ok
    >>> RCPT TO:<username@163.com>
    250 Ok
    >>> DATA
    354 End data with <CR><LF>.<CR><LF>
    >>> .
    250 Ok: queued as
    >>> QUIT
    221 Bye

    sendEmail

    下面来介绍sendEmail的使用
       
    wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
    tar -zxvf sendEmail-v1.56.tar.gz
    cd sendEmail-v1.56
    mv sendEmail /usr/local/bin/
    yum -y install perl-IO-Socket-SSL openssl-perl openssl-devel

    sendEmail就可以使用了。应为sendEmail没有配置文件,所以在发送邮件的时候需要填上发件人的账户密码,没有mailx方便.

    这是我们需要脚本辅助

       
    #!/bash/sh
    from_email='username@hotmail.com'
    smtp='smtp-mail.outlook.com:587'
    title='标题'
    to_email=`username@qq.com`
    passwd='passwd'
    body=`cat test`
    /usr/sbin/sendEmail -o tls=yes -f "$from_email"  -s "$smtp"  -u "$title"  -o message-content-type=text  -o message-charset=utf8 -t "$to_email" -xu "$from_email"  -xp "$passwd"  -m "$body"

    以上是个简单的脚本,当然标题和内容以及发件人你都可以传参进来。这样的话就不会再命令行中暴露密码。

    2017年3月6日星期一

    使用openssl发送邮件

    openssl s_client -connect smtp.qq.com:465 -crlf -ign_eof
    EHLO localhost
    AUTH LOGIN
    xxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxx

    MAIL FROM:<xxxx@qq.com>
    RCPT TO:<xxxx@163.com>
    DATA
    From: Test <xxxx@qq.com>
    To: Me <xxxx@163.com>
    Subject: Testing email from telnet
    This is the body
    .
    QUIT

    -------------------------------------------------------------------------------------
    # openssl s_client -connect smtp.qq.com:465 -crlf -ign_eof
    CONNECTED(00000003)
    depth=1 C = US, O = GeoTrust Inc., CN = GeoTrust SSL CA - G3
    verify error:num=20:unable to get local issuer certificate
    ---
    Certificate chain
     0 s:/C=CN/ST=Guangdong/L=Shenzhen/O=Shenzhen Tencent Computer Systems Company Limited/OU=R&D/CN=pop.qq.com
       i:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
     1 s:/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
       i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
    ---
    Server certificate
    -----BEGIN CERTIFICATE-----
    MIIHrTCCBpWgAwIBAgIQStxVhUEPlKCJNmsoaRVQVjANBgkqhkiG9w0BAQsFADBE
    MQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEdMBsGA1UEAxMU
    R2VvVHJ1c3QgU1NMIENBIC0gRzMwHhcNMTYwOTA3MDAwMDAwWhcNMTgxMjA3MjM1
    OTU5WjCBkzELMAkGA1UEBhMCQ04xEjAQBgNVBAgMCUd1YW5nZG9uZzERMA8GA1UE
    BwwIU2hlbnpoZW4xOjA4BgNVBAoMMVNoZW56aGVuIFRlbmNlbnQgQ29tcHV0ZXIg
    U3lzdGVtcyBDb21wYW55IExpbWl0ZWQxDDAKBgNVBAsMA1ImRDETMBEGA1UEAwwK
    cG9wLnFxLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALeSY7Vb
    60Cvv7P2O+zhaZnqlz/KFs//DH4It3xmyMPFOPUFopzN1h8n3/4FPqGBtqEEuWBE
    /o7soZT30E8bw30Tl07VOcYm/fPKi1pyro3hNEdLi5Wlta9fKxDAvw0U3clSq39R
    qihYIDAA3QrDuqI54gULa5IZnqM16A9VBULPfIDaXbdgaAIJ5Ak92nC13YcdQYuv
    egL6jOWSKzCRTqeRAg+6dWkfce1+gAOCuCUDgAso2EJ+k9nFe/LAMMGdGbe4KI9H
    CwpDCMo+2k2u4SQtXOmuYke7nNmRnpJeL3qZnGWsqT7l3N0mYCc/+3zcMfAcmyuo
    H90stoWF/G2T2rcCAwEAAaOCBEkwggRFMIIBPwYDVR0RBIIBNjCCATKCEnVwbG9h
    ZC5tYWlsLnFxLmNvbYIUaHdzbXRwLmV4bWFpbC5xcS5jb22CFGh3aW1hcC5leG1h
    aWwucXEuY29tgg5jbG91ZG14LnFxLmNvbYISaW1hcC5leG1haWwucXEuY29tghNo
    d3BvcC5leG1haWwucXEuY29tggtzbXRwLnFxLmNvbYIKbXgzLnFxLmNvbYIRcnR4
    LmV4bWFpbC5xcS5jb22CCmRhdi5xcS5jb22CCm14MS5xcS5jb22CDW14Yml6MS5x
    cS5jb22CCWV4LnFxLmNvbYILaW1hcC5xcS5jb22CEXBvcC5leG1haWwucXEuY29t
    gg1teGJpejIucXEuY29tggpteDIucXEuY29tghJzbXRwLmV4bWFpbC5xcS5jb22C
    CnBvcC5xcS5jb20wCQYDVR0TBAIwADAOBgNVHQ8BAf8EBAMCBaAwKwYDVR0fBCQw
    IjAgoB6gHIYaaHR0cDovL2duLnN5bWNiLmNvbS9nbi5jcmwwgZ0GA1UdIASBlTCB
    kjCBjwYGZ4EMAQICMIGEMD8GCCsGAQUFBwIBFjNodHRwczovL3d3dy5nZW90cnVz
    dC5jb20vcmVzb3VyY2VzL3JlcG9zaXRvcnkvbGVnYWwwQQYIKwYBBQUHAgIwNQwz
    aHR0cHM6Ly93d3cuZ2VvdHJ1c3QuY29tL3Jlc291cmNlcy9yZXBvc2l0b3J5L2xl
    Z2FsMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBTS
    b/eW9IU/cjwwfSPahXibo3xafDBXBggrBgEFBQcBAQRLMEkwHwYIKwYBBQUHMAGG
    E2h0dHA6Ly9nbi5zeW1jZC5jb20wJgYIKwYBBQUHMAKGGmh0dHA6Ly9nbi5zeW1j
    Yi5jb20vZ24uY3J0MIIBfQYKKwYBBAHWeQIEAgSCAW0EggFpAWcAdgDd6x0reg1P
    piCLga2BaHB+Lo6dAdVciI09EcTNtuy+zAAAAVcCsiY3AAAEAwBHMEUCIBZMjuD9
    LRps0VXtC5F0Dn5FXD8gM0iySH7lLJak/k/vAiEAiLxBze2hKotXAjrolqeYpTy2
    LE5B8/mm6HDRnTO5NpwAdQCkuQmQtBhYFIe7E6LMZ3AKPDWYBPkb37jjd80OyA3c
    EAAAAVcCsidpAAAEAwBGMEQCIBFWt7QviHZxdzT4N1eU+97X00f/iiYTKBnqcKAa
    ls/jAiBCer4UAZrSJ64TjbXhbARmSe+rKtoNEh3FbszBe0TSTAB2AGj2mPgfZIK+
    OozuuSgdTPxxUV1nk9RE0QpnrLtPT/vEAAABVwKyJ4sAAAQDAEcwRQIgCJlZbkC8
    uTXLwyyQPLWRMqLlVJ9bbVsEceP35AMq1V0CIQCgcwNrkcte+84dURDiteDnoco5
    NKLuVwk6+eMt0y3GtjANBgkqhkiG9w0BAQsFAAOCAQEAQDICKJnfn2hc/AzAfc1+
    v6PpIyDTLeT8mOd7qsO/PbTD7H38mdT1hk9M7lTqxYG/DcFmsPWhluGxHeVNq6St
    gw360UE241C3KTl+jQtN8BRSMJpmAL636mVuRU3euAJNmI21fuiz/vauWM85qsWj
    E6N91WTqbOijYU2p/HmwMjd7HEfQQUZtxzmJLlkPoFMy0P9fv2Q+01XTtrx4wpGQ
    VttfWsRh0388L56i3oyK3o50ZrT2twQuK59pUEgL1n7GBXIAe8L/YhYeW349UbYT
    jtFwjo+fYreSQaQe+1bKWRO+ZzUschK/QZ877zAZDe1gN0tqB9kqTLp4pAABkQ7s
    1A==
    -----END CERTIFICATE-----
    subject=/C=CN/ST=Guangdong/L=Shenzhen/O=Shenzhen Tencent Computer Systems Company Limited/OU=R&D/CN=pop.qq.com
    issuer=/C=US/O=GeoTrust Inc./CN=GeoTrust SSL CA - G3
    ---
    No client certificate CA names sent
    ---
    SSL handshake has read 3432 bytes and written 675 bytes
    ---
    Server public key is 2048 bit
    Secure Renegotiation IS supported
    Compression: NONE
    Expansion: NONE
    No ALPN negotiated
    SSL-Session:
        Protocol  : TLSv1.2
        Cipher    : AES128-SHA256
        Session-ID: A14F67315BF1542D3CD45B3B49A1FE6DEBA95A883B802728B6FCE4549CFD851D
        Session-ID-ctx:
        Master-Key: A8FDCD1EB692E305CB6D6BFEA985E4E7468908780DAE63173139892A4D97C7455A4F5E2D4FC08F573985F4D1EAC09BE9
        Key-Arg   : None
        PSK identity: None
        PSK identity hint: None
        SRP username: None
        TLS session ticket lifetime hint: 1200 (seconds)
        TLS session ticket:
        0000 - 67 30 86 a2 f7 69 8a cc-78 8e 26 48 d6 08 63 68   g0...i..x.&H..ch
        0010 - a5 11 d1 e4 09 f4 70 3f-e9 13 0b 46 63 bb 56 93   ......p?...Fc.V.
        0020 - d6 6d 94 ba 27 b0 a4 ef-ad b4 92 8b 05 83 aa 5e   .m..'..........^
        0030 - 84 00 46 74 ae c3 b5 55-d9 a7 74 e5 36 10 17 9e   ..Ft...U..t.6...
        0040 - 34 71 e9 bb de cd c1 ed-c6 15 04 73 b2 c9 54 4f   4q.........s..TO
        0050 - d5 14 ad d8 88 b7 fd 73-16 e4 8d a4 b1 09 22 52   .......s......"R
        0060 - df 75 5c 8c 35 72 33 c1-2f c5 f6 8b fe f8 1e d4   .u\.5r3./.......
        TLS session ticket:
        0000 - 67 30 86 a2 f7 69 8a cc-78 8e 26 48 d6 08 63 68   g0...i..x.&H..ch
        0010 - a5 11 d1 e4 09 f4 70 3f-e9 13 0b 46 63 bb 56 93   ......p?...Fc.V.
        0020 - d6 6d 94 ba 27 b0 a4 ef-ad b4 92 8b 05 83 aa 5e   .m..'..........^
        0030 - 84 00 46 74 ae c3 b5 55-d9 a7 74 e5 36 10 17 9e   ..Ft...U..t.6...
        0040 - 34 71 e9 bb de cd c1 ed-c6 15 04 73 b2 c9 54 4f   4q.........s..TO
        0050 - d5 14 ad d8 88 b7 fd 73-16 e4 8d a4 b1 09 22 52   .......s......"R
        0060 - df 75 5c 8c 35 72 33 c1-2f c5 f6 8b fe f8 1e d4   .u\.5r3./.......
        0070 - 8e bf 60 1b 19 57 5c 76-5e dd 97 83 a5 ec 4d ef   ..`..W\v^.....M.
        0080 - 8e 6d 26 b7 f5 3e f4 cc-ea 4b 5f 5f 25 99 2f f1   .m&..>...K__%./.
        0090 - 55 13 2b 12 02 42 69 39-5e ae 12 7d 47 0b 36 25   U.+..Bi9^..}G.6%

        Start Time: 1488852592
        Timeout   : 300 (sec)
        Verify return code: 20 (unable to get local issuer certificate)
    ---
    220 smtp.qq.com Esmtp QQ Mail Server
    ehlo [127.0.1.1]
    250-smtp.qq.com
    250-PIPELINING
    250-SIZE 73400320
    250-AUTH LOGIN PLAIN
    250-AUTH=LOGIN
    250-MAILCOMPRESS
    250 8BITMIME
    AUTH PLAIN xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    235 Authentication successful
    mail FROM:<xxxx@qq.com> size=78
    250 Ok
    rcpt TO:<xxxx@163.com>
    250 Ok
    data
    354 End data with <CR><LF>.<CR><LF>
    From: Test <xxxx@qq.com>
    To: Me <xxxx@163.com>
    Subject: Testing email from telnet
    This is the body
    .
    250 Ok: queued as
    quit
    221 Bye
    closed

    Python one-line HTTP server

    python -m SimpleHTTPServer 8000

    will serve the contents of the current working directory over HTTP on port 8000.

    If you use Python 3, you should instead write

    python3 -m http.server 8000

    See the SimpleHTTPServer module docs for 2.x and the http.server docs for 3.x.

    By the way, in both cases the port parameter is optional.

    2017年3月5日星期日

    FFmpeg实用命令:音频、视频格式转换和其它操作

    FFmpeg实用命令:音频、视频格式转换和其它操作

    下面命令从mp4文件中提取出MP3音频:

    ffmpeg -i yourvideo.mp4 -vn -ab 128k outputaudio.mp3

    -vn用来提取声音,-ab指定存储为128Kbps mp3格式,可以指定256K或其他码率。


    Cutting small sections

    To extract only a small segment in the middle of a movie, it can be used in combination with -t which specifies the duration, like -ss 60 -t 10 to capture from second 60 to 70. Or you can use the -to option to specify an out point, like -ss 60 -to 70 to capture from second 60 to 70. -t and -to are mutually exclusive. If you use both, -t will be used.
    Note that if you specify -ss before -i only, the timestamps will be reset to zero, so -t and -to have not the same effect. If you want to keep the original timestamps, add the -copytsoption.
    The first command will cut from 00:01:00 to 00:03:00 (in the original), using the faster seek.
    The second command will cut from 00:01:00 to 00:02:00, as intended, using the slower seek.
    The third command will cut from 00:01:00 to 00:02:00, as intended, using the faster seek.
    ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy cut.mp4
    ffmpeg -i video.mp4 -ss 00:01:00 -to 00:02:00 -c copy cut.mp4
    ffmpeg -ss 00:01:00 -i video.mp4 -to 00:02:00 -c copy -copyts cut.mp4
    
    If you cut with stream copy (-c copy) you need to use the -avoid_negative_ts 1 option if you want to use that segment with the concat demuxer .
    Example:
    ffmpeg -ss 00:03:00 -i video.mp4 -t 60 -c copy -avoid_negative_ts 1 cut.mp4
    

    Time unit syntax

    Note that you can use two different time unit formats: sexagesimal (HOURS:MM:SS.MICROSECONDS, as in 01:23:45.678), or in seconds. If a fraction is used, such as 02:30.05, this is interpreted as "5 100ths of a second", not as frame 5. For instance, 02:30.5 would be 2 minutes, 30 seconds, and a half a second, which would be the same as using 150.5 in seconds.