Saturday, March 31, 2018

gstreamer


  • Install:
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools
  • Build:
g++ -std=c++14 00_011_gstreamer.cpp `pkg-config --cflags --libs gstreamer-1.0`




NEST

Using ffmpeg we can do conversion from one format to another. Install ffmpeg http://jonhall.info/how_to/setup_and_use_ffmpeg_on_windows . (follow this link, no need to work on both 32 bit and 64 bit, just do for 64 bit and create bat file for ffplay as well)
The live stream url is  "https://video.nest.com/embedded/live/KVKQXyMSCL?autoplay=1  and the video link is rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79
The command to play live stream is
ffplay rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79
The command to save live stream on local system is (duration 10 seconds ) -
ffmpeg -i rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79  -r  5  -t  10  C:\Users\chitode\Downloads\test.mp4
The formats supported by setbox are HLS, rtsp, mss (Microsoft Smooth Streaming). Hence we need to convert rtmp to either of these formats.
1.       To transcode from live rtmp to live hls we I tried to configure rtmp server on nginx. I refered this link http://stackoverflow.com/questions/19658216/how-can-we-transcode-live-rtmp-stream-to-live-hls-stream-using-ffmpeg . But at the time of server creation its giving error I am not sure whether its because of firewall issue. Error - nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
I tried to use “Nimble streamer” but its giving permission errors while installing
2.       Rtmp to rtsp can be done using wowza. I have started to look into will inform the update soon.
3.       I haven’t worked on mss yet.
I will work on the conversion part on weekend.
Some use full links

So I installed on my fedora 23 (64bit) machine and it works well (my home linux is also fc 23-64 and works well).
I’d recommend to use fc 23-64.
Please see bottom of this email about the issue I currently have, help me!
(1)    ffmpeg
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
dnf install ffmpeg
(2)    nginx: should install from source to use rtmp module
·        openssl:
wget http://www.openssl.org/source/openssl-1.0.2f.tar.gz
cd openssl-1.0.2f
./Configure linux-x86_64 --prefix=/usr
make; sudo make install
·        pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz
./configure; make; sudo make install
·        zlib
wget http://zlib.net/zlib-1.2.11.tar.gz
./configure; make; sudo make install
·        download https://github.com/arut/nginx-rtmp-module and decompress
·        Finally nginx
wget http://nginx.org/download/nginx-1.11.9.tar.gz
./configure --add-module=../nginx-rtmp-module-master --with-http_ssl_module
make; sudo make install
(3)    Nginx setup
·        sudo mkdir /tmp/HLS
·        sudo mkdir /tmp/HLS/cam
o   You will see files in /tmp/HLS/cam/nest once you start nginx.
·        cd /usr/local/nginx/conf/ and sudo vi nginx.conf and add followings:
rtmp {
    server {
        listen 1935;
        allow play all;
        chunk_size 4000;
        # video on demand for flv files
        application cam {
            allow play all;
            live on;
            hls on;
            hls_nested on;
            hls_path /tmp/HLS/cam;
            hls_fragment 10s;
            exec_static ffmpeg -i rtmps://stream-delta.dropcam.com/nexus/a203d89605a4454a94caed1b16024f79 -c:v libx264 -an -f flv rtmp://localhost:1935/cam/nest;
        }
        # video on demand for mp4 files
        application vod {
            allow play all;
            play /home/yjpark/www/nginx/mp4s;
        }
        application hls {
            live on;
            hls on;
            hls_path /tmp/HLS;
        }
    }
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;
    server {
        listen       8090;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root /home/yjpark/www/nginx/html;
            index index.html index.htm;
        }
        #creates the http-location for our full-resolution (desktop) HLS stream - "http://my-ip/cam/nest/index.m3u8"
        location /cam {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            alias /tmp/HLS/cam;
            add_header Cache-Control no-cache;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
}
(4)    check http ports
sudo semanage port -l | grep http_port_t
http_port_t                    tcp      8090, 80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988
If you don’t see
sudo semanage port -a -t http_port_t -p tcp 8090
(5)    start nginx
sudo /usr/local/nginx/sbin/nginx
(6)    if you change any config, restart nginx by:
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
(7)    Play with rtmp
Open VLC and give rtmp://yjpark-linux-02.hq.k.grp:1935/cam/nest.
(8)    Play with hls
http://yjpark-linux-02.hq.k.grp:8090/cam/nest/index.m3u8
Now, VLC still complains about index.m3u8 and ts files.
Can anyone help me while I’m working on something else?

Friday, November 10, 2017

Ubuntu Setup

Ubuntu Setup

  • docker CE
    • sudo apt-get update
    • sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
    • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    • test: sudo apt-key fingerprint 0EBFCD88
    • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    • sudo apt-get install docker-ce
    • sudo groupadd docker
    • sudo gpasswd -a yjpark docker
    • sudo usermod -aG docker yjpark
    • su - yjpark
    • id -nG
  • ssh
    • apt-get install openssh-server
    • cp /etc/ssh/ssd_config /etc/ssh_sshd_config.factory-defaults
    • chmod a-w /etc/ssh/sshd_config.factory-defaults
    • systemctl restart ssh
  • openstack
    • sudo apt-get install python-pip
    • sudo pip install python-openstackclient
    • /etc/openstack/clouds-public.yaml
      • public-clouds:
          eu-zrh:
            auth:
              auth_url: https://cloud.eu-zrh.hub.kudelski.com:5000/
          us-phx:
            auth:
              auth_url: https://cloud.us-phx.hub.kudelski.com:5000/
    • ~/.config/openstack/clouds.yaml
      • clouds:
          eu-zrh-uex-proci:
            cloud: eu-zrh
            identity_api_version: '3'
            interfacepublic
            auth:
              domain_name: hq.k.grp
              project_name: uex-proci
              username: ludovic.pierre@nagra.com
              password: xxxx
          us-phx-uex-proci:
            cloud: us-phx
            identity_api_version: '3'
            interfacepublic
            auth:
              domain_name: hq.k.grp
              project_name: uex-proci
              username: ludovic.pierre@nagra.com
  • ansible
    • $ sudo apt-get update
      $ sudo apt-get install software-properties-common
      $ sudo apt-add-repository ppa:ansible/ansible
      $ sudo apt-get update
      $ sudo apt-get install ansible
    • sudo pip install shade
  • ss