Advanced MythTV Video Processing

Advanced methods for deinterlacing video playback and extracting video to take on the road.

Because of its stability and extensibility, Linux is often found at the frontier of computing. Linux has emerged as a promising platform for home theater audio/visual applications. My television viewing is now handled by a special-purpose Linux PC running MythTV. As I set up MythTV, the two major pain points I encountered were both related to video processing. The first challenge is to configure smooth video playback, and the second challenge is to take recorded programs on the road.

Deinterlacing Video Playback

To work within the limitations of the electronics of the day, television frames are transmitted as two separate “fields”. A field consists of either the even-numbered or the odd-numbered horizontal lines in the picture. On playback, the even-numbered and odd-numbered fields are weaved together, and viewers far enough away from the display see continuous blended motion.

Two consecutive fields are related, but are not identical. During periods of rapid side-to-side motion of the camera, a field will be slightly ahead of its predecessor, and there may be jagged edges to images sliding across the screen. Figure 1 is a screenshot from a 1080i high-definition broadcast. In the scene, the camera is panning from left to right, causing the objects in the image to slide rapidly across the screen. Each field is in a slightly different position, leading to sawtooth-edge distortion, which is also called combing, serrations or mice teeth. In scenes with a great deal of sideways motion, it may be extremely difficult to follow the content through the distortion.

Figure 1. Combing Distortion on Playback

To make a video like Figure 1 watchable, it can be converted into a smooth picture by a process called deinterlacing. MythTV offers users a choice between several deinterlacing methods:

  • One field—instead of using two fields for one frame, this extremely simple method keeps only one of the two fields. Every other field is displayed as a still image, and the unused fields are discarded.

  • Linear—this method blends directly adjacent lines, which by definition come from alternate fields, together. A slight ghost image may appear, but the sawtooth distortion will be gone.

  • Kernel—this method blends several lines together instead of just adjacent lines. Ghost images do not appear, though faint remnants of one field may remain.

  • Bob—Bob is the most taxing method. Each field is line-doubled to create a frame, and then the reconstructed frames are played at double the frame rate.

Deinterlacing does require significant processing power, but most modern CPUs have multimedia instruction sets that reduce the load of the processing power. If you have an Intel processor with MMX or SSE instructions, or an AMD processor with 3Dnow!, deinterlacing should not be too difficult.

Bob is the best deinterlacing method to use with a synchronous TV output, though it can tax a less-capable machine. My personal MythTV front end is a 2GHz AMD Athlon64, and it has more than enough power to display Bob-deinterlaced high-definition video to an analog TV set. Although the CPU requirement is higher than the other deinterlacing methods, it is still well within the performance capabilities of my system.

Linear deinterlacing and kernel deinterlacing have similar visual effects, with the latter having a slightly larger CPU impact. Both are less taxing than Bob, which may be helpful on underpowered CPUs. Between the two, I prefer kernel deinterlacing because it blends several adjacent lines and eliminates ghosts, which make the resulting picture sharper.

Exporting Video to Other Systems

One of the initial reasons for setting up a MythTV system was a desire to take my television programs on the road. Now that “television” means “files on hard disk”, it is much easier to store, transport and watch where it it is convenient for me. Like many mobile professionals, my laptop has practically become an extra appendage, and it is an ideal platform for playing back video while mobile, especially now that many airplanes have added power ports for mobile electronics.

The basic tension in exporting video from MythTV is a trade-off between size and processing time. Digital TV broadcast standards describe how to send an MPEG-2 video stream over a TV channel, so it is natural for MythTV to store digital TV broadcasts in their “natural” MPEG-2 format. Converting the MPEG-2 digital TV stream to another MPEG-2-based video format is relatively easy and can be done without lots of processing time. Converting the digital TV stream to MPEG-4 requires much more processing power, but the resulting video file will be much smaller.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

An easier way

harmic's picture

Something I found out recently: these days mplayer can be used to replay the nuv container format used by mythtv directly. So, you can simply copy the nuv files onto your laptop and play them with mplayer.

I was using mplayer 1.0pre6 for windows.

Much faster than transcoding them into another format. nuvexport can also be used to export the files directly as nuv, but there seems little advantage to that over simply copying them, except it might be a bit easier to identify the correct files.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix