Powered by Blogger.

Building JRTP in Windows

Monday, May 20, 2013

1.
- jrtp depends on jthread. Hence, we have to build jthread first.
- Download jrtplib and jthread from this link and extract it.
- Detailed video tutorial is available in the following links from the authors, thanks a lot for such a good library and help. ;-).

http://research.edm.uhasselt.be/jori/jthread_jrtplib_example_mpeg1.mpg
http://research.edm.uhasselt.be/jori/jthread_jrtplib_example_mpeg2.mpg
http://research.edm.uhasselt.be/jori/jthread_jrtplib_example.avi

2. Download and install CMake.

3.
- Open CMake.
- Set the jthread folder path as the browse source.
- Create a folder named "build" in the above folder and set build folder location in CMake to that path.
- Click 'Add entry' and add an entry named 'CMAKE_INSTALL_PREFIX', type is 'PATH', set the value to a empty folder. In my case it is 'C:/testlocal'.
- Click OK.

- Click 'Configure'.
- Click Finish.


- Click "configure" again.

- Then click "generate".

- Now you can see VS project files in the build directory.
- Open the solution with VS.
- Right click in the 'INSTALL' project and select 'Build'.

- Check whether it builds without any fails.

- Select 'Release' from the 'Solutions configuration' menu. and build the 'INSTALL' project again.
- Again check for any errors.

4.
- Now follow the same steps for the jrtplib as well.
- Make sure to set the 'CMAKE_INSTALL_PREFIX' same like before.
- Build 'INSTALL' project for both 'Debug' and 'Release' Solution configurations in VS same as before.

5.
- Now you can locate all the relevant header and library files in 'C:\testlocal'

Use RtMidi in Windows in a Microsoft Visual Studio C++ Project

Sunday, May 12, 2013

Create a "Win32 Console Application" in Visual Studio.


Name it, click OK.


Click next.


Deselect "Precompiled header" and select "Empty project", click Finish.

Add a C++ (.cpp) file, name it and click Add.


Copy the code of "midiout.cpp" from this link to your .cpp file.
Change "SLEEP" in the code to "Sleep". (Since we are using Windows)
Add "#include " at the beginning of the code.
Copy "RtMidi.cpp", "RtMidi.h" and "RtError.h" files to your project folder. You can find these files from here.

Right click on your project in VS -> Add -> Existing item.
Select and add above three files to your project.


Now your project file structure will look like this.


Add "#define __WINDOWS_MM__" line at the beginning of the "RtMidi.h" file.


Right click on your project in VS -> Properties.


Go to Configuration properties -> Linker -> Input. Add "winmm.lib" at the end of "Additional dependencies".


Click Apply and OK.

Go to Visual Studio project. Press "F7". Press "Control key + F5". Then you can see the command prompt and can hear a short beep. If so, your RtMidi now works fine. Good luck!


Install GStreamer OSSBUILD in Windows 8

Sunday, April 21, 2013

1. Download and install "GStreamer-WinBuilds-GPL-x86-Beta04-0.10.7.msi" from this link.





2. Download and install "GStreamer-WinBuilds-SDK-GPL-x86-Beta04-0.10.7.msi" from this link. Make sure to disable the "Python bindings".







3. Now your GStreamer should be ready.
Try the following code in your command prompt and you should get an output like below.

gst-launch videotestsrc ! autovideosink


To test audio try the following code in the terminal then you should hear a continuous beep.

gst-launch audiotestsrc ! autoaudiosink

Running QtAV project using QT5, FFMpeg and VS2010 on Windows 7/8

Monday, April 1, 2013

1. Install VS2010

2. Install QT5 Creator
- Download "Qt 5.0.1 for Windows 32-bit (VS 2010, 481 MB)" from this link.

3. Download QtAV source code as a zip file from this link.
- Extract the file
- Paste that extracted file to "C:\Qt\Qt5.0.1\Tools\QtCreator\bin"

4. Open QT5 Creator
- Open the QtAV project file (QtAV.pro) in "C:\Qt\Qt5.0.1\Tools\QtCreator\bin\QtAV-master" using menu File -> Open File or Project
- Click "Configure Project"

5. Setup FFMpeg
- Download FFMpeg file (FFmpeg-1.2_mingw32+msvc_20130316) from this link.
- Extract it
- Paste to "C:\Program Files (x86)"
- Append following variables in QT Creator:
  INCLUDE = "C:\Program Files (x86)\FFmpeg-1.2_mingw32+msvc_20130316\include"
  LIB = "C:\Program Files (x86)\FFmpeg-1.2_mingw32+msvc_20130316\lib"


6. Run the program
- Click the run button in left side panel
- You may get some errors, now let us copy the relevant missing DLLs

7. Copy the following relevant DLL files to "C:\Qt\Qt5.0.1\Tools\QtCreator\bin\QtAV-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Debug\bin"
- Copy these DLLs (avcodec-54.dll, avformat-54.dll, avutil-52.dll, swscale-2.dll, zlib1.dll) from "C:\Program Files (x86)\FFmpeg-1.2_mingw32+msvc_20130316\bin"
- Copy this DLL (libportaudio-2.dll) from the bin folder of "portaudio-v19_msvc+mingw32_20130209". You can download it from this link.
- Copy this DLL (pthreadGC2.dll) in "pthreadGC2". Link to download.
- Copy these DLLs (Qt5Cored.dll, Qt5Guid.dll, Qt5Widgetsd.dll) from "C:\Qt\Qt5.0.1\5.0.1\msvc2010\bin"

8. Run the program again. Now hopefully It should show the following screen
- Make sure to delete these files (.qmake, config, Makefile) in "C:\Qt\Qt5.0.1\Tools\QtCreator\bin\QtAV-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Debug" before you run the program.


 Note:
If it is not successful you may use dependency walker to find which DLLs are missing.


Unity3D MasterServer Installation on Ubuntu

Sunday, March 3, 2013

1. Download the MasterServer from http://www.unity3d.com/master-server/index.html

2. Make sure you have installed the "ncurses" library. If not you this code to install it,
sudo apt-get install libncurses5-dev

3. Extract and change the directory to the extracted MasterServer directory

4. Edit the Makefile, line 90 (for the facilitator) - move "$(CFLAGS)" to the very end of the line. (Thanks for this link for suggesting this change: http://forum.unity3d.com/threads/143680-Custom-Master-Server)

5. Open the terminal change to the MasterServer directory. Type and enter "make".

6. Type and enter "./MasterServer -d"; -d is to run the process as a daemon. 

Video Streaming with Gstreamer - 03

Thursday, January 3, 2013

Today, I was able to complete the Python Gstreamer receiver with RTCP. But still synchronization within streams is not perfect. Have to research further. I used 4 vertically divided videos from the same original video. Here is the code of the receiver.

#!/usr/bin/python

import pygst
pygst.require("0.10")
import gst
import pygtk
import gtk

class Main:
    def __init__(self):
       
        def onPad(obj, pad, target):
            sinkpad = target.get_compatible_pad(pad, pad.get_caps())
            if sinkpad:
                pad.link(sinkpad)
            print "pad added"
            print obj
            return True
 
        self.pipeline = gst.Pipeline("mypipeline")
        self.mixer = gst.element_factory_make('videomixer')
        self.pipeline.add(self.mixer)
        self.videosink = gst.element_factory_make('autovideosink')
        self.pipeline.add(self.videosink)
        self.ffmpegcs = gst.element_factory_make("ffmpegcolorspace", "ffmpegcs")
        self.pipeline.add(self.ffmpegcs)

        # video 1
        self.udpsrc11 = gst.element_factory_make("udpsrc")
        self.udpsrc11.set_property("port", 5011)
        self.udpsrc12 = gst.element_factory_make("udpsrc")
        self.udpsrc12.set_property("port", 5012)
        caps = gst.caps_from_string("application/x-rtp, media=(string)video, \
                        clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96")
        self.udpsrc11.set_property('caps', caps)
        self.rtpbin1 = gst.element_factory_make("gstrtpbin", 'rtpbin1')
        self.rtpbin1.set_property('latency', 100)
        self.rtp_depay1 = gst.element_factory_make("rtph264depay")
        self.q1 = gst.element_factory_make('queue')
        self.decoder1 = gst.element_factory_make('ffdec_h264')
        self.box1 = gst.element_factory_make('videobox')
        self.box1.set_property('top', 0)
        self.box1.set_property('border-alpha', 0)
        self.udpsink1 = gst.element_factory_make("udpsink")
        self.udpsink1.set_property("host", "10.42.0.13")
        self.udpsink1.set_property("port", 5013)
        self.udpsink1.set_property('sync', False)
        self.udpsink1.set_property('async', False)
        self.pipeline.add_many(self.udpsrc11, self.udpsrc12, self.rtpbin1, self.rtp_depay1, \
                               self.q1, self.decoder1, self.udpsink1, self.box1)
     
        # video 1 linking
        self.udpsrc11.link_pads('src', self.rtpbin1, 'recv_rtp_sink_0')
        self.udpsrc12.link_pads('src', self.rtpbin1, 'recv_rtcp_sink_0')
        self.rtpbin1.connect('pad-added', onPad, self.rtp_depay1)
        self.rtpbin1.link_pads('send_rtcp_src_0', self.udpsink1, 'sink')
        self.rtp_depay1.link(self.q1)
        self.q1.link(self.decoder1)
        self.decoder1.link(self.box1)
        self.box1.link(self.mixer)
       
        # video 2
        self.udpsrc21 = gst.element_factory_make("udpsrc")
        self.udpsrc21.set_property("port", 5021)
        self.udpsrc22 = gst.element_factory_make("udpsrc")
        self.udpsrc22.set_property("port", 5022)
        caps = gst.caps_from_string("application/x-rtp, media=(string)video, \
                        clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96")
        self.udpsrc21.set_property('caps', caps)
        self.rtpbin2 = gst.element_factory_make("gstrtpbin", 'rtpbin2')
        self.rtpbin2.set_property('latency', 100)
        self.rtp_depay2 = gst.element_factory_make("rtph264depay")
        self.q2 = gst.element_factory_make('queue')
        self.decoder2 = gst.element_factory_make('ffdec_h264')
        self.box2 = gst.element_factory_make('videobox')
        self.box2.set_property('top', -120)
        self.box2.set_property('border-alpha', 0)
        self.udpsink2 = gst.element_factory_make("udpsink")
        self.udpsink2.set_property("host", "10.42.0.13")
        self.udpsink2.set_property("port", 5023)
        self.udpsink2.set_property('sync', False)
        self.udpsink2.set_property('async', False)
        self.pipeline.add_many(self.udpsrc21, self.udpsrc22, self.rtpbin2, self.rtp_depay2, \
                               self.q2, self.decoder2, self.udpsink2, self.box2)
     
        # video 2 linking
        self.udpsrc21.link_pads('src', self.rtpbin2, 'recv_rtp_sink_0')
        self.udpsrc22.link_pads('src', self.rtpbin2, 'recv_rtcp_sink_0')
        self.rtpbin2.connect('pad-added', onPad, self.rtp_depay2)
        self.rtpbin2.link_pads('send_rtcp_src_0', self.udpsink2, 'sink')
        self.rtp_depay2.link(self.q2)
        self.q2.link(self.decoder2)
        self.decoder2.link(self.box2)
        self.box2.link(self.mixer)
       
        # video 3
        self.udpsrc31 = gst.element_factory_make("udpsrc")
        self.udpsrc31.set_property("port", 5031)
        self.udpsrc32 = gst.element_factory_make("udpsrc")
        self.udpsrc32.set_property("port", 5032)
        caps = gst.caps_from_string("application/x-rtp, media=(string)video, \
                        clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96")
        self.udpsrc31.set_property('caps', caps)
        self.rtpbin3 = gst.element_factory_make("gstrtpbin", 'rtpbin3')
        self.rtpbin3.set_property('latency', 100)
        self.rtp_depay3 = gst.element_factory_make("rtph264depay")
        self.q3 = gst.element_factory_make('queue')
        self.decoder3 = gst.element_factory_make('ffdec_h264')
        self.box3 = gst.element_factory_make('videobox')
        self.box3.set_property('top', -240)
        self.box3.set_property('border-alpha', 0)
        self.udpsink3 = gst.element_factory_make("udpsink")
        self.udpsink3.set_property("host", "10.42.0.13")
        self.udpsink3.set_property("port", 5033)
        self.udpsink3.set_property('sync', False)
        self.udpsink3.set_property('async', False)
        self.pipeline.add_many(self.udpsrc31, self.udpsrc32, self.rtpbin3, self.rtp_depay3, \
                               self.q3, self.decoder3, self.udpsink3, self.box3)
     
        # video 3 linking
        self.udpsrc31.link_pads('src', self.rtpbin3, 'recv_rtp_sink_0')
        self.udpsrc32.link_pads('src', self.rtpbin3, 'recv_rtcp_sink_0')
        self.rtpbin3.connect('pad-added', onPad, self.rtp_depay3)
        self.rtpbin3.link_pads('send_rtcp_src_0', self.udpsink3, 'sink')
        self.rtp_depay3.link(self.q3)
        self.q3.link(self.decoder3)
        self.decoder3.link(self.box3)
        self.box3.link(self.mixer)
       
        # video 4
        self.udpsrc41 = gst.element_factory_make("udpsrc")
        self.udpsrc41.set_property("port", 5041)
        self.udpsrc42 = gst.element_factory_make("udpsrc")
        self.udpsrc42.set_property("port", 5042)
        caps = gst.caps_from_string("application/x-rtp, media=(string)video, \
                        clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96")
        self.udpsrc41.set_property('caps', caps)
        self.rtpbin4 = gst.element_factory_make("gstrtpbin", 'rtpbin4')
        self.rtpbin4.set_property('latency', 100)
        self.rtp_depay4 = gst.element_factory_make("rtph264depay")
        self.q4 = gst.element_factory_make('queue')
        self.decoder4 = gst.element_factory_make('ffdec_h264')
        self.box4 = gst.element_factory_make('videobox')
        self.box4.set_property('top', -360)
        self.box4.set_property('border-alpha', 0)
        self.udpsink4 = gst.element_factory_make("udpsink")
        self.udpsink4.set_property("host", "10.42.0.13")
        self.udpsink4.set_property("port", 5043)
        self.udpsink4.set_property('sync', False)
        self.udpsink4.set_property('async', False)
        self.pipeline.add_many(self.udpsrc41, self.udpsrc42, self.rtpbin4, self.rtp_depay4, \
                               self.q4, self.decoder4, self.udpsink4, self.box4)
     
        # video 4 linking
        self.udpsrc41.link_pads('src', self.rtpbin4, 'recv_rtp_sink_0')
        self.udpsrc42.link_pads('src', self.rtpbin4, 'recv_rtcp_sink_0')
        self.rtpbin4.connect('pad-added', onPad, self.rtp_depay4)
        self.rtpbin4.link_pads('send_rtcp_src_0', self.udpsink4, 'sink')
        self.rtp_depay4.link(self.q4)
        self.q4.link(self.decoder4)
        self.decoder4.link(self.box4)
        self.box4.link(self.mixer)
       
        self.mixer.link(self.ffmpegcs)
        self.ffmpegcs.link(self.videosink)
       
        self.pipeline.set_state(gst.STATE_PLAYING)
 
start = Main()
gtk.main()