MythTV Stream Debugging

In release 0.25, the MythTV developers added some new external APIs with support for HTTP Live Streaming (HLS).

Since I published the MythTV Go app to allow users with Android devices to watch their TV recordings “on the go”, a number of people have contacted me, to say that the video streaming isn’t working. In the majority of these cases, it’s been due to a problem with their backend. This post is to share the information on how to debug your backend streaming problem.

MythTV HLS Overview

When an application requests a new stream for a recording or video, the mythtv backend starts a background job to transcode the video into H.264 format. The resulting video is written to lots of separate numbered files, each containing 10 seconds of video. These files are store in this directory on the mythbackend:

/home/mythtv/.mythtv/tmp/hls

and they look something like this:

1001_20120106192800.mpg.704x400_1024kV_64kA.av.000001.ts
1001_20120106192800.mpg.704x400_1024kV_64kA.av.000002.ts
1001_20120106192800.mpg.704x400_1024kV_64kA.av.000003.ts
...
1001_20120106192800.mpg.704x400_1024kV_64kA.av.000176.ts
1001_20120106192800.mpg.704x400_1024kV_64kA.av.000177.ts
1001_20120106192800.mpg.704x400_1024kV_64kA.av.000178.ts

These files can be played just like any other video file, e.g.

mplayer 1001_20120106192800.mpg.704x400_1024kV_64kA.av.000001.ts

As soon as one file has been written, the player application can start streaming the video whilst the rest of the video is still being transcoded in the background. Depending on the CPU power of the backend, and the speed of the network, it’s generally better to wait for a few files to be ready before starting the player.

Known Problems

The problems I’ve seen so far can be diagnosed by looking at this log file on the mythbackend:

/var/log/mythtv/mythtranscode.log

Missing Deinterlacers

If you see entries like this in the mythtranscode.log:

Jul 17 13:36:37 myth mythtranscode[27691]: E CoreContext
 filtermanager.cpp:93 (FilterManager) Filter dir '/usr/lib/mythtv/filters' doesn't exist?
...
Jul 17 13:36:37 myth mythtranscode[27691]: E CoreContext filtermanager.cpp:243 (LoadFilters) FilterManager: Failed to load filter 'onefield', no such filter exists

You need to install the deinterlacers that are normally installed with the mythfrontend, as mythtranscode is trying to use them. Installing the mythfrontend package is probably enough on most systems (you don’t have to actually run the frontend if your system is a mythbackend only).

On mythbuntu for example:

apt-get install mythtv-frontend

Incorrect Compile Options

If you see entries like this in the mythtranscode.log:

2012-08-14T20:27:55.155813-04:00 myth mythtranscode[11218]: E CoreContext transcode.cpp:1148 (TranscodeFile) avfw->Init() failed

Your myth packages haven’t been built to support HLS. To be able to transcode to the correct video and audio formats for HLS, mythtv needs to be built with the following options:

  --enable-libx264 --enable-libmp3lame

Known working distributions:

Please let me know of any other distributions that have been tested in the comments, and I’ll update this list.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s