Labels

bittorrent (1) chromium (1) dvb (1) dvb-t (1) fedora (1) fm (1) gqrx (1) howto (1) idle (1) ireland (1) linux (3) lubuntu (1) openbsd (1) ps1 (1) radio (1) rtl-sdr (1) sdr (1) shell (1) tips (1) tuning (1) tv (1) unix (1) vlc (1)

Saturday, December 30, 2017

Watching digital TV broadcasting on a Linux computer in Ireland

Some time ago, I bought a cheap software defined radio (SDR) USB dongle, a NooElec NESDR Mini 2. As all SDRs based on the RTL2832U chip, the original purpose of this dongle is to receive digital video broadcasting (DVB) but as it turned out, these can also be used as SDRs. So these dongles are great value, not only do they allow you to watch digital TV on your computer, but you can also use them as software defined radio receivers. Check out the https://www.rtl-sdr.com/ website to learn more about what you can do with them.

Here's what the dongle looks like:

It works perfectly as an SDR, but what I actually want to talk about is how to use it for it's original purpose, i.e. receiving digital video broadcasting. More specifically, how to watch digital TV on a Linux computer in Ireland. Thankfully, on a modern Linux distribution, such as Fedora Linux which I'm using, and having basic Linux knowledge, it's very easy.

First, install the RPM Fusion software repository into your system and then install the VLC media player, via Software app or the dnf command.

Next, plug in the DVB dongle into your computer. To check that the device has been recognized and initialized, you can run the dmesg command in a terminal window, you should see output similar to the following:

[23101.436902] usb 1-1: new high-speed USB device number 10 using xhci_hcd
[23101.577084] usb 1-1: New USB device found, idVendor=0bda, idProduct=2838
[23101.577088] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[23101.577090] usb 1-1: Product: RTL2838UHIDIR
[23101.577092] usb 1-1: Manufacturer: Realtek
[23101.577094] usb 1-1: SerialNumber: 00000001
[23101.584731] usb 1-1: dvb_usb_v2: found a 'Realtek RTL2832U reference design' in warm state
[23101.640546] usb 1-1: dvb_usb_v2: will pass the complete MPEG2 transport stream to the software demuxer
[23101.640571] dvbdev: DVB: registering new adapter (Realtek RTL2832U reference design)
[23101.653238] i2c i2c-10: Added multiplexed i2c bus 11
[23101.653241] rtl2832 10-0010: Realtek RTL2832 successfully attached
[23101.653258] usb 1-1: DVB: registering adapter 0 frontend 0 (Realtek RTL2832 (DVB-T))...
[23101.653340] r820t 11-001a: creating new instance
[23101.660287] r820t 11-001a: Rafael Micro r820t successfully identified
[23101.672892] Registered IR keymap rc-empty
[23101.672979] rc rc0: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:14.0/usb1/1-1/rc/rc0
[23101.673074] input: Realtek RTL2832U reference design as /devices/pci0000:00/0000:00:14.0/usb1/1-1/rc/rc0/input18
[23101.673375] rc rc0: lirc_dev: driver ir-lirc-codec (dvb_usb_rtl28xxu) registered at minor = 0
[23101.673384] usb 1-1: dvb_usb_v2: schedule remote query interval to 200 msecs
[23101.681940] usb 1-1: dvb_usb_v2: 'Realtek RTL2832U reference design' successfully initialized and connected
On Fedora Linux, the drivers for RTL2832U-based DVB tuners slash software defined radios are installed by default. But in case they aren't on your distribution, the name of the driver is rtl2832:
$ lsmod | grep rtl28
rtl2832                24576  1
i2c_mux                16384  1 rtl2832
dvb_usb_rtl28xxu       40960  0
dvb_usb_v2             40960  1 dvb_usb_rtl28xxu
dvb_core              126976  2 dvb_usb_v2,rtl2832
rc_core                36864  5 ir_lirc_codec,lirc_dev,dvb_usb_v2,dvb_usb_rtl28xxu

Now start the VLC media player, select Media 🡒 Open Capture Device... and input the settings shown on the screenshot below. The frequencies that you can enter depend on your location. In the example below, I've entered one of the two frequencies for receiving in Dublin, the 546000 kHz. The other frequency for Dublin is 570000 kHz. The set of the programmes that you can watch is different depending on the frequency you input. For example, RTE 2 HD is on 546000 kHz, while RTE One is on 570000 kHz.
To find out what frequencies you need to use in your area, refer to the document published by 2RN who run the networks. In the first part of the document, you can look up what channels you need to use in your area, and at the end, there is a table which tells you what frequencies correspond to those channels.

Click play, wait a few seconds for VLC to work it's magic and proceed to select Playback 🡒 Program from the menu which will allow you to choose the program that you want to watch as is shown on screenshot below.

Voila, we're receiving and watching digital TV! The quality of picture on RTE 2 HD is amazing.

If you're not in Ireland but there is digital TV broadcasting in your country, then these instructions should work for you too, you just need to find out the broadcasting frequencies for your location.


As a bonus, here are a couple of screenshots of the Gqrx program, which you can install on Fedora Linux using Software app or dnf command and which, among other things, allows you to listen to FM radio and to narrow FM communications, such as marine VHF radio communications.

Sunday, September 1, 2013

$PS1

For many years I used one and the same PS1 prompt on all computers I had:
PS1='\u@\h:\j:\w\$ '
It looks like this when rendered:
slava@jupiter:0:/usr/local/bin$
Simple and functional, but when dealing with large outputs (say, compiling a C++ program...) it might be hard to find the start of the output, the prompt simply dissolves into the wall of text.

Not long ago I changed my job and decided it was time to update my PS1 as well. I wanted something with better contrast and readability. The result was this:

This is what it looks like on screen:

This prompt is highly visible, turns red when you switch to root user and has the good property of always having the cursor in the same place.

A few days ago I installed good ol' OpenBSD as my main OS on my main PC and I think I came up with an even better prompt:

This is what it looks like:

Neat, huh?

Sunday, July 22, 2012

(Lubuntu 12.04) How to teach Chromium to open BitTorrent magnet links

Here's the solution for the impatient:

  1. Create a bin directory in your home directory.
  2. Inside bin, create a file called xdg-open with the following content:
    #!/bin/sh # A workaround to make BitTorrent magnet links work. # # If a magnet link is given as an argument -- open it # with Transmission, otherwise execute the real xdg-open # passing all arguments through. case "$1" in magnet*) transmission-gtk "$1" > /dev/null & ;; *) exec /usr/bin/xdg-open "$@" ;; esac
  3. Change the file's permissions so that it's executable.
  4. Log out and log back in so that the changes take effect.
  5. The magnet links should now open in Transmission when you click them.

After installing the latest Lubuntu 12.04, I noticed that Chromium is unable to open BitTorrent magnet links. Chromium executes the xdg-open command, giving it the magnet link as an argument, but xdg-open doesn't know how to open the magnet link either.

After googling for a bit I came across two solutions but neither of them worked for me.

http://www.foresightlinux.se/make-chromium-to-open-magnet-links/
I didn't like this approach because it involves changing the xdg-open script, which is naturally a part of some package. I have a feeling that this might cause problems with the package manager because the checksum of the file will change. And whenever the script will be updated, you would have to make the modifications again, because the file would be overwritten.

http://askubuntu.com/a/133693
This one simple didn't work.

So my solution is to provide a script which pretends to be xdg-open. If it receives a magnet link as an argument, it opens it with Transmission, otherwise it just runs the real xdg-open, passing all the arguments through. Chromium will pick up this fake xdg-open over the real one because the $HOME/bin directory will come earlier than /usr/bin in the PATH environment variable.