Digital TV Record with Kaffeine and mpg2avi

Ever wisher you could record your preferred TV Shows with your Linux Box? You did it but cannot get rid of the annoying mpeg format? Want to cut all the adds? No problem, that’s the post for you. Firsts, lets’ see what we’re going to need for this how-to.

1) Kaffeine, a free multimedia player for Linux. It is specifically working for KDE but works very nice on Gnome and any other Desktop Environment as well. Just open your package manager and look for Kaffeine. In Ubuntu (Or in any Debian system), you can use Synaptic to manage your packages. Search for Kaffeine and install it. All the dependencies will be automatically solved. I suggest you to install Konqueror too if it is not automatically chosen for installation.

2) An USB or PCI digital / analog TV receiver for PC. I use the Terratec Cinergy T2 which is immediately compatible with Linux, out of the box. Just plug it in the USB port and it works!

The Terratec Cinergy T2 Digital Terrestrial Receiver

3) A little tool called avidemux. Download it from your repos.

4) Search the repositoryes you usually use to find and install “mencoder” (Without quotes, of course).

5) An executable script I included in this page, called mpg2avi. This script can convert .mpg files to .avi files. Download it from the link on the bottom of this page.

Now that we’ve got everything and are ready for work, what can we do? First of all, connect the Cinergy T2 to your PC, then start Kaffeine. On the main screen you’ll see the option Digital TV enabled! Wow, it works 🙂 Click on this option. There’re no channels in the list. Don’t worry, we’re going to work on this. You’ll see, on the upper left corner of the Kaffeine Window, this set of icons:

The Channels Icons

Click on the red circled Icon. A new window with the channel list will appear. You’ll see non channels here. Click on the Start Scan button. Kaffeine will scan all your available digital TV channels. Once the scan is completed (Also a certain number of radios will be detected), select all the channels you want to have in your list and click on the Add Selected Button. Now close this window and open whichever channel you want to watch! Kaffeine is configured…

Did you know that… while you are watching a TV program you can press the pause button to pause the program from playing? The incredible fact is that the program will pause for real! As if it was a recorder video! When you’ll press play again, the program will begin to play from the exact point where you paused it! That’s a little Kaffeine miracle. If you want to be sincronized again with the real TV program time, just change channel and return to the one you where previously watching again, or you can also press the Stop button and Play button again..

Let’s press now the DVB Setting Options, the last icon on the same line of the one to edit the channels. in this newly opened window we’ll be able to set some options. One of the most important here is where the recordings should be stored. Choose a folder on an Hard Disk with a lot of disc space… a TV program recorder with Kaffeine in that way can be several gigabytes big (We’ll shrink and edit it in the next passages).

Now that Kaffeine is all setted up, to start recording a TV program, just press on the Save Button, the one surrounded by the red circle in this screenshot, on the left bottom corner of the Kaffeine Window.

Kaffeine Save Button

The “Timer succesfully created and started” window will open. Press OK. The TV program is starting to be recorded. Now press again on the save button and a new window will open, called “Timers”. Choose your timer (The one wich has just been created), edit it, set all the options you like and when you’re done close this window. You can delete this newly created timer at any time by opening this window again and clicking on the Delete Timer button. The recording will end by itself in any case when the timer will reach an end.

Open the folder where you decided to store your recording and find the new file. It is a a huge .mpg file. The resolution is really something… but we need a shorter file, this one is really too big. At this point, let’s use a little utility I found somewhere on the net called mpg2avi (If the author has seen this post, please contact me, I’ll post his name if he wishes). Download mpg2avi from the link on the bottom of this page and estract it in the same folder where your TV recordings are stored (Inside the archive there’s a single file. This file has to be placed in the folder mentioned before). You’ll have to right click on this file, now, and make it executable from the propertyes window. At this point, you’ll just have to open a Terminal inside of this folder and type:

./mpg2avi

This command will convert any .mpg file inside the folder into .avi compressed files! The original file will not be deleted. Pay caution: I sayd EVERY single mpg file inside that folder so, if you want to convert a single file, move the others somewhere else.

What to do if, after giving the ./mpg2avi command from a console, the script answers that it cannot find the file name.mpg ? Simple, you’ll just have to rename the file saved by Kaffeine to a different name, leaving the extesion unmodified! This is a frequent error, maybe it is due to the format Kaffeine uses to save its files….

Now you can run avidemux. If you don’t find it in the Programs Menù (It happens to me), you can run it from a terminal window. In avidemux you can load your .avi video and edit it to delete any annoying ad. Just set the start pointer and end pinter and then choose delete from the menù, for every ad you’ll encounter during the TV show. At the end of this cleaning process, just save the avi file with another name and delete the original .mpg and .avi files! All is good and your task is completed!

You may want to try out the avi converted file before deleting it. Some times, the conversion can be problematic, specially fro the sound compression part of the process. If this is your case and you’ve got an avi converted file with broken audio, just download mpg2avi2 file instead of mpg2avi file. The second file avoids audio compression wich is, in any case, very poor.

Here are the two mpg2avi files, prepared by me directly for you. Just put them inside the folder where your TV recordings are and execute them from a terminal (Remember to make them executable!).

mpg2avi
mpg2avi2 (Use this only if you have problems encoding the audio stream with the normal mpg2avi).

Leave a Reply