Recording TV programs with Ubuntu and converting them to .AVI files as commonly seen on the internet can be tricky. This guide will detail one method to achieve this using three pieces of software available in the Ubuntu 9.10 (Karmic Koala) repositories. I'll assume you already have an Ubuntu compatible DVB-T PCI card or USB stick installed.

Installing necessary software

Use the Ubuntu Software Center or package manager of choice to install MeTV, ProjectX, and AVIDemux.

Record some TV

MeTV is very self explanatory. You can either use the record button at the top of the screen or click on programs in the guide to record them.

Preparing the file for editing.

By default you will now have a Raw MPEG-TS Transport Stream in your /home/username/Videos folder. Most likely some commercial TV with ads that you'd like to remove. AVI demux is great for a bit of quick editing and has a very simple interface, however it cannot keep the audio in sync when dealing with Transport Streams.

ProjectX on the other hand has a rather unfriendly interface for editing but can easily sort out unruly TS files.

Separate the audio and video (Demux)

Open ProjectX from Applications> Sound & Video> ProjectX. Once within ProjectX click File>Add and open your recorded file. You will see an image from you video appear in the preview pane. Now click the Quickstart button on the left hand side. There is no need to adjust any other settings. This will open another window with a progress bar at the bottom. This will sort out any broadcast errors or sync issues. Two files now reside in the same folder as your original. One will be a .m2v file containing the video. The other will be a .mp2 or .ac3 file containing the audio. You may now close ProjectX.

Bring audio and video together again (Multiplex)

Open AVIDemux from Applications> Sound & Video> AVIDemux(GTK+). Click the open button and open the .m2v file created by ProjectX. The video will now appear in the preview pane. Now click Audio> Main Track, and from the dropdown box select "Use External AC3", browse for the audio track created by ProjectX. Click ok to load it in.

Now we are going to save the file as an MPEG-PS file. (We need this intermediate step or the audio will lose sync at the first comercial cut!) Over on the left controls under format select MPEG-PS(A+V). Leave Video and Audio set to Copy. Press the Save button above the vedeo and give you new file a name nameoffile.mpg. Press save and wait for the file to finish. Now close this file with File>Close.

Editing out the ads (or anything else you don't want)

Open the .mpg file you created with the Open button. Now use the select and cut functions to remove anything you don't want. TIP: The left and right arrows on your keyboard provide very fine grained control, you can use them to cut at just the right spot. Once you have it edited as you like move on to the next step.

Set final encoding settings.

Now would be a good time to look at the properties of your file and make decisions about final resolution and bitrate. Click File> Properties. A typical standard definition program will have a resolution of 720x576 with a 16:9 aspect ratio at 25 frames/sec. (At least in former PAL countries). To save on bitrate we will reduce this to 624X352 a common size found in internet downloads. To do this click the video dropdown box and select your codec of choice. MPEG4-AVC(h.264) is a good choice as it provides very good quality at small file sizes. Set the format dropdown to AVI at this time as well. Now click the video filters button. The filter manager will now appear with available filters on the left and in use filters on the right. Double clicking a filter on the left will activate it and add it to the right side.

Double click MPlayer-Resize. In the resize box set the input aspect ratio to 16:9 (if you have a 4:3 non wide screen video select that instead. Leave the output ratio at 1:1. Check the 16 round up box as this is necessary for .AVI files. Now use the slider to select 624x352 (624x496 for 4:3). Click ok and preview the changes to check the aspect ratio is correct (Not stretched horizontally or vertically).

If all is well click on the audio dropdown box and select MP3. Click the configure box for audio and set it to 128kbps CBR Stereo (This is a reasonable bitrate for tv program audio, you may want higher or lower). Now click the Calculator button at the top of the main screen. Leave the format as AVI. Change the medium to custom and enter your desired final filesize in the text box. 350mb is typical for a 1 hour tv program (with ads removed so 45 odd minutes actual playtime). Now click apply. Take note of the number calculated for Video Size (MB). Close the calculator. Now click the configure button for video. Use the dropdown to select "Two Pass - Video Size". Change the number there to the Video size number you got from the calculator. Click Apply.

Final Steps

Click the Save button at the top of the main window and give your file a name something.avi and click save. The program will now resize your video, re-encode the audio to MP3 and re-encode the video to h.264 and place the results in a handy .avi container.

Converting DVB-T streams to AVI files (last edited 2009-12-01 03:58:49 by caish5-hotmail)