Wednesday, February 8, 2012

Mediatomb, stream your PC media to TV (Ubuntu)

MediaTomb is an open source UPnP Media server with a cool web user interface, which allows you to stream your digital media through your home network and listen to, or watch it on a variety of UPnP compatible devices. That means no cable directly connected to your PC! It even makes it possible (with some tweaking) to stream YouTube videos to your TV.

You can get it with this CLI command in Ubuntu:
sudo apt-get install mediatomb

Now start your Mediatomb and quit it right after it starts, either with CTRL+C or kill pid, does not matter.
You can start it with this command:

(*Note, I had to do this for the config file to be created in the hidden directory, .mediatomb that is)

Open the config file (be sure you are in right directory!):
sudo gedit ~/.mediatomb/config.xml

<ui enabled="no" show-tooltips="yes">
<ui enabled="yes" show-tooltips="yes"

if you wish to enable web user interface (this is a major security risk though, anyone on your network can access your root files and manipulate them, so be sure to disable this when done with the config, especially if you plan to run this for a few hours+!).
You can select within it, which folder is being scanned for media. It is quite user friendly and straightforward.

If you have a TV with a ethernet port, be sure to plug it into the same network, and source-find Mediatomb. When opened, you will be able to select videos, music or photos available from your PC, and play them!
Do not forget to select which folder is "sharing" content to your TV, which is done in the Web user interface.

***I had some issues with the Samsung TV, everything i tried to play gave me "unsupported format" error. Here is a fix that seemed to work even for other TV brands.

Open the config file:
sudo gedit ~/.mediatomb/config.xml

Remove the comments (<!-- -->) from <custom-http-headers> part and add/modify things so it looks like this (note that 017000 000.. is all in a same line):
<add header=" Streaming"/>
<add header=" DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=017000 00000000000000000000000000"/>

Now, find <mappings> and add the following:
<map from="avi" to="video/mpeg"/>
<map from="mkv" to="video/mpeg"/>

You need to restart Mediatomb for the changes to take effect.

***To disable Mediatomb autorun, do this (backup first):
sudo mv /etc/init.d/mediatomb /etc/init.d/mediatomb.backup
sudo update-rc.d mediatomb remove

If you instead wish to use the autorun feature, be sure to edit the config file located in /etc/mediatomb (yes, there are actually two config.xml).


Saturday, February 4, 2012

Automate Desktop screenshoting in Ubuntu

Today I'll present (and explain) a tiny script used to create a screenshot of the active window in your Ubuntu installation.
Naturally, you can easily press Print Screen key and take the screenshot with the native Gnome-screenshot, but automating screen capture can be good in case you wish to stream your desktop or active program to some other computer - but still wish to avoid CPU intensive programs that stream it live.

I will be using ImageMagick (import), which you can easily get via apt, if it is not already installed on your Ubuntu.

Here is the script:
echo "taking screenshots"
while :
        import -window root -resize 1920 Screenshot.png
        sleep 10
Save it and execute in Terminal with "bash scriptname" (eg.: bash /home/user/scriptname). You could also make it executable either via chmod +x in Terminal or by ticking it in the file options accessible via right click.

As you can see, it is a bash script. Echo will output the text between quotes, while : do signals the beginning of the endless loop (which means this screen will be canceled upon kill signal, either a CTRL+C or kill pid in Terminal).
Import -window root -resize 1920 Screenshot.png will screenshot your active window (your browser, a program, etc), resize it to 1920x1080 pixels and save it as Screenshot.png in your home (~/) folder.
Sleep 10 is the delay (in seconds), and since it is the last line in the loop, it is the delay until the loop repeats itself. You may switch that as you see fit.


Thursday, February 2, 2012

Sandboxie protects your Windows

Today I present you Sandboxie. A Windows application which may save you a headache or two.
Basically, what it does, is runs applications in a closed environment (sandbox), preventing them from making any changes to your system.

That means it is a great app to run your:
-web browser (when visiting questionable websites)
-suspicious applications (cd-key generators for example)
-email client (those supposedly funny emails that threaten you will die if you don't forward it to 10 friends)
-etc . . .

Definately a great application + it keeps your Windows installation nice&tidy!

You can get it HERE