Home > Command-Line, Open Source > Capturing Streaming Video Using DCOP + Xine

Capturing Streaming Video Using DCOP + Xine

This morning, the Vice Counselor of my university was interviewed on tv. No one is recording the event and I did not notice about it until it is aired. It will be nice if I can always capable of recording such memorable event. Therefore, I began to write a script that can help me to do a scheduled recording.

From the Internet, I notice that this can be done using mencoder or FFMpeg. However due to some circumstances I can’t use these tools on my PC. That leave me no choice but to use xine.

Xine on my desktop is fine enough to capture the shows on tv but the problem is I could not find any way to schedule the recording using GUI. As time pass, the problems reminds me about my favorite command in past, DCOP!!!

I used to play text based games using DCOP. Actually the idea is not to play games but to learn bash scripting. Learning process made me bored. Therefore, I thought, I need a project that could keep me motivated during the process. So I made a robot that could help me to play games without really touch the game daily. So that was the moment I enjoys using DCOP and the fun of scripting began.

However, the fun with DCOP is not long. I learned Python after that and Python made me completely abandon my old friend. Python is too efficient, as I can reduce my scripts errors almost to zero.

Now, due to the challenge i face, the DCOP is coming again to help me (actually I did not have enough time to do research on doing this using Python).

The idea of the script is to get the video capture done from command line and be scheduled using cron/at. I am using dcop and kmplayer as the GUI for xine. Below is the steps I did to get the recording done:

  1. get kmplayer process ID
    $ dcop | grep kmplayer
  2. get the kxineplayer process ID
    $ dcop kmplayer-10963 kmplayer-mainwindow#1 getWinID
  3. give the kmplayer the appropriate url
    $ dcop kmplayer-10963 KMediaPlayer openURL \ http://www.um.com.my/tv_channels/malaysia/rtm1.asx
  4. record it using kxineplayer
    $ kxineplayer -wid 14680071 -f ‘/home/fadli/.kde/share/apps/kmplayer/xine_config’ -vo xv,sdl,x11 -ao alsa -cb kmplayer-10963/KMPlayerCallback-0 -rec ‘/home/fadli/test.avi’

Sound easy, right? but the challenge is not over yet. What I have done is just to record the video. What I need is a program that are able to be scheduled. Em… well just put all the previous commands into a file. Add some chili sauces and ketchup. A little salt will make it more tasty. Also some sugar. 30 minutes baked in oven should be fine. Finally make the file executable using chmod. Now, it is ready to be served and yummy!

This is what I have in the script:


# Definitions

# Getting IDs
PID=`dcop | grep kmplayer`
if [ -e $PID ] ; then
echo Starting KMPLAYER…
nohup kmplayer &
sleep 5
PID=`dcop | grep kmplayer`
echo KMPLAYER already started.
WID=`dcop $PID kmplayer-mainwindow#1 getWinID`

# Process
dcop $PID KMediaPlayer openURL $SRC
sleep 5

echo killall kxineplayer | at now + $TIME minutes
kxineplayer -wid $WID -f ‘/home/fadli/.kde/share/apps/kmplayer/xine_config’ -vo xv,sdl,x11 -ao alsa -cb $PID/KMPlayerCallback-0 -rec $OUTPUT

And finally, put it up on schedule using cron or at.

Powered by ScribeFire.

Categories: Command-Line, Open Source
  1. 10/07/2010 at 10:14 pm

    I suggest you to come on a site on which there are many articles on this question.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: