วันจันทร์ที่ 29 กันยายน พ.ศ. 2557

Brewing Gst-Python

From the last post about gstreamer. I would like to do my work on Python. Then i have to brew gst-python again.

$ brew create http://anongit.freedesktop.org/git/gstreamer/gst-python.git --set-name GstPython

Then edit formula. My formula is. $ brew edit GstPython

require "formula"

class Gstpython < Formula
  homepage "http://gstreamer.freedesktop.org/releases/gst-python/1.3.90.html"
  url "http://anongit.freedesktop.org/git/gstreamer/gst-python.git", :using => :git
  sha1 ""

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "glib" => :build
  depends_on "gstreamer" => :build
  depends_on "pkg-config" => :build
  depends_on "pygobject3" => :build
  depends_on "libffi" => :build

  def install
    system "./autogen.sh"
    system "./configure", "--disable-debug",
                          "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--prefix=#{prefix}"

    system "make"
    system "make install"
  end

end

But!!!

Remember i've not install any python yet. Yes we use python site-packages from /usr/local/lib/python2.7/site-packages/ . Homebrew can have their python environment. Then we have to install python first.

First we have to uninstall our previous python package first. Then install python by $ brew install --verbose python 

Then you will have to install GStreamer again. 

It's time to brewing get-python from now.

$ brew install --verbose GstPython

Then you can try the installation by 
Python 2.7.8 (default, Sep 29 2014, 18:34:51) 
Type "copyright", "credits" or "license" for more information.

IPython 2.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from gi.repository import Gst, GObject

In [2]: Gst.version()
Out[2]: (1L, 4L, 1L, 0L)



วันอาทิตย์ที่ 28 กันยายน พ.ศ. 2557

Streaming IP Camera to Kivy Video

Finally, after spend 3 weeks with Mac OS X Yosemite , Raspberry Pi, IP Camera that support RTSP Protocol.

Kivy is an amazing framework to start with. It's not new language but it's a new idea to bring the softwares together. GStreamer is a multimedia framework.  I used this for media-handling. It's recommend by Kivy. Compiling this framework is awesome. Homebrew , another tool to get package for Mac. Previously i used fink. OS X Yosemite is my Favourite OS.

I do IP camera streaming by install MJPEG Server on Raspberry PI. But it's a Moving JPEG. Then i want to do more on RTSP and If i have luck, i can stream also audio too.

IP Camera on the market today are support both MJPEG an RTSP. But if you want to get both Video and Audio you need RTSP.

Then, this is my target.

First install Kivy. You can easily install Kivy by get the package on the Kivy web site. But I'm interesting to set up GStreamer on OS X Yosemite..

Let's compile the GStreamer.

First you need to install Homebrew. Again you can install Homebrew easy by follow the instruction from the web site.

If you install GStreamer follow the instruction on Kivy. You will only get few of pipeline. I need more pipeline!

(If you're on Debian. Believe me, Building GStreamer on Debian is very funny and easy!)

You have to read more instruction on Homebrew.

0. Install Xcode and Xcode Command Line Tool (CLT)
Without Xcode and Xcode Command Line Tool you will get error when compiling. Please see detail.

1. Install pygobject3 
$ brew install pygobject3

2. Install gstreamer
$ brew install gstreamer --with-gobject-introspection

After you've build gstreamer. Please see the core elements from $ gst-inspect-1.0  . It will help you to understand what gstreamer is.

I recommend to also install gst-libav. it's former ffmpeg.
$ brew install gst-libav


3. Install gst-plugins-base
Before you install gst-plugins-base please see $ brew edit gst-plugins-base  output. Then you command will be $ brew install gst-plugins-base --with-orc --with-gtk+ --with-libogg --with-pango --with-theora --with-libvorbis --with-gobject-introspection 

At this plugins i would recommend you to see the plugin list here. Then you can decide which plugins you need to install. 

After finished please see $ gst-inspect-1.0 output. You will see the list of plugins.

4. Install gst-plugins-good
Again, see the plugins list here. Then run $ brew edit gst-plugins-good . My installation would be

$ brew install gst-plugins-good --with-gobject-introspection --with-orc --with-gtk+ --with-aalib --with-libcdio --with-esound --with-flac --with-jpeg --with-libcaca --with-libdv --with-libshout --with-speex --with-taglib --with-libpng --with-libogg

Again. after finished please $ gst-inspect-1.0 output.

5. Install gst-plugins-bad
Then for gat-plugins-bad i also do the same way. My installation would be

$ brew install gst-plugins-bad --with-gobject-introspeciton  --with-faac --with-facc2 --with-gnutls --with-libdvdread --with-libexif --with-libmms --with-rtmpdump --with-schroedinger

note: disable dirac because it's error.

6. Install gst-plugins-ugly

My installation would be.
$ brew install gst-plugins-ugly --with-gobject-introspection --with-mad --with-jpeg --with-libvorbis --with-cdparanoia --with-lame --with-two-lame --with-libshout --with-aalib --with-libcaca --with-libdvdread --with-libmpeg2 --with-a52dec --with-liboil --with-flac --with-gtk+ --with-pango --with-theora --with-libmms --with-x264 --with-opencore-amr

note: x264 is a library that often used, don't forget

Luckily  i have

Total count: 163 plugins, 612 features

Test videotestsrc with this

$ gst-launch-1.0 videotestsrc ! autovideosink


It's amazing output on OpenGL. This is a very very famous test source for beginner.

The part to install GStreamer with plugins is completed here. But we need gst-rtsp-server

Please visit GStreamer RTSP Server Library page here.

7. Install GStreamer RTSPServer
For this you can now install gst-rtsp-server from ./autogen.sh . But for me. I'm have to do some with brew

Create brewing GstRtspStreamer
$ brew create http://anongit.freedesktop.org/git/gstreamer/gst-rtsp-server --set-name GstRtspServer

Edit GstRtspStreamer Formular
$ brew edit  GstRtspServer
Then i do a bit of change. This is my version of GstRtspServer Formular.
require "formula"

class Gstrtspserver < Formula
  homepage "http://cgit.freedesktop.org/gstreamer/gst-rtsp-server/"
  url "http://anongit.freedesktop.org/git/gstreamer/gst-rtsp-server", :using => :git, :tag => "1.4.2"
  sha1 ""

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "gettext" => :build
  depends_on "glib" => :build
  depends_on "pkg-config" => :build

  depends_on "gtk-doc" => :build
  depends_on "gstreamer" => :build
  depends_on "gst-plugins-base" => :build

  def install
    system "./autogen.sh"
    system "./configure", "--disable-debug",
                          "--disable-dependency-tracking",
                          "--disable-silent-rules",
                          "--prefix=#{prefix}"
    system "make"
    system "make install"
  end

end

Install our Formula GstRtspStreamer
$ brew install --debug --verbose  GstRtspServer

Yes, you can now have gst-rtsp-server library. You can go to make a test from git like this.
$ git clone --branch 1.4.2 git://anongit.freedesktop.org/gstreamer/gst-rtsp-server

$ cd gst-rtsp-server

$ ./autogen.sh

This will failed you! Please update path to support Brew
$ export PATH="/usr/local/opt/gettext/bin:$PATH"

$ ./autogen.sh

$ ./configure

$ make

Let's go to example folder 
$ cd examples/

Then Launch RTSP Server
$ ./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"

From VLC try to open the network streaming from the streaming you see!

But for me i want to show you the easy from GStreamer, gst-launch-1.0 

Open new terminal and then try this command
$ gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8554/test  ! rtph264depay ! decodebin ! autovideosink

Yes for the proxy rtsp-server you can change 'videotestsrc' to 'v4l2src'

Because i'm test on the Raspberry Pi with Raspberry PI Camera Module. It's easy to try!

Kivy Layout.
It's also easy to display the Video Stream from Kivy Please try to change your widget like this

    Video:
        source: 'rtsp://127.0.0.1:8554/test'
        size_hint: .5, .5

        state: 'play'




วันพุธที่ 17 กันยายน พ.ศ. 2557

Another i like most on Mac OS X Yosemite

I wonder about the new Mac OS X Yosemite feature,

Instead show the flag i'm using on keyboard layout, Now is the first Thai character is "Ko Kai"


วันอาทิตย์ที่ 14 กันยายน พ.ศ. 2557

a Problem with Kivy on RTSP Video Streaming

2 days for searching and trying to Play RTSP IP Camera in Kivy.

It was no video show any on Kivy, no error !

It's not easy for me to find someone to help me continue develop Kivy to support RTSP now in Thailand.

Should i continue with Kivy?

updated: 25 Sep 2014

I'm back. Kivy is awesome.

วันจันทร์ที่ 8 กันยายน พ.ศ. 2557

Asynchronous TV channel preview.

Request from myself at this post http://hanattaw.blogspot.com/2014/09/blog-post.html

The Asynchronous can solved this problem easily?