SageTV Logo

I am an avid SageTV user. Works great for analog TV and QAM cable HDTV channels (no OTA HD for me unless I get really large antennas). I've been wanting to record from a cable box for a long time and made various attempts via firewire. On PCs this does not work out but on Macintoshes this works great. So why not use a MAC as a SageTV Firewire Network encoder? I developed some software to do this. This software is copyright Hugo Lyppens (2007) and is free for personal use.

My solution includes the AVCVideoServices framework (part of Firewire SDK). Here is the required disclaimer from Apple:

In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple’s copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Computer, Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated.

The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.

IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

To start, download SageTVFirewireNetworkEncoder.zip and unzip it into /Applications or anywhere else you'd like. This contains the binary, AVCVideoServices framework and a sample config file.


The config file specifies the following items:

  • portnumber:TCP port number for server to listen for commands on.
  • device: firewire device to use. Either a number (sequence number as per --list listing starting at 0) or name. Default 0, so first firewire device.
  • channelchangemethod: leave blank for default or set to scientific-atlanta if you have this brand of cable box. Only tested with Scientific Atlanta SA4200HD. As of November 2008, some of the Scientific Atlanta cable boxes received updates enabling the default channel change method. So if you experience channel changing problems please try both channel change methods.
  • channelchangedelay: Time in ms between channel change command and start of recording
  • poweroffdelay: time of no activity in ms after last recording before turning off STB
  • directoryprefixmap: Directory mapping from where SageTV recording directories to mount points on encoder machine. Unneeded if paths are the same on both or if firewire encoder and sagetv run on same Macintosh. Format: sagetv1|local1,sagetv2|local2,...,sagetvN|localN. Example: E:|/Network/SAGETV, saying that paths that start with E: on SageTV computer correspond to paths starting with /Network/SAGETV on this computer.
  • maxrecordingbuffers: max # of 128k buffers to allocate in case server is not keeping up with video stream. Set at 512, so on rare occasions the encoder allocates up to 64MB. But normally less than 1MB buffer suffices.

For Tiger and before, I use the NetInfo manager to set up automounts. My SageTV runs on a PC so I use cifs mounts. Go to Applications/Utilities/Netinfo Manager and click on /mounts. Add value. Set its name to SAGETVMACHINE:/SHARENAME. Set dir to /Network/SHARENAME. Set vfstype to url. Set opts to: url==cifs://username:password@SAGETVMACHINE/SHARENAME. Spaces in any of the values inside the URL are to be represented as %20. In my case I could only get it to work by using my SageTV machine's IP address (fine as it has a fixed IP in my LAN anyway) but perhaps it is possible using host name too. This is very cool it mounts the drives on an as-needed basis when a recording starts if it hasn't already been mounted. Test the mount from the terminal window by typing ls /Network/SHARENAME. If all is well it should automount the share and list the files on the SageTV machine.

For Leopard, MacOS X 10.5, which lacks the NetInfo manager, I followed the instructions on automounting Samba shares in Leopard (ignoring the 1st paragraph, I think MacOS automounts are very reliable). These instructions are more general as they work on all MacOS X but require you to use the shell command line. First, become root, sudo bash. Then create file /etc/auto.smb and add lines for each network share like this:

SHARENAME -fstype=smbfs ://username:password@SAGETVMACHINE/SHARENAME.

Finally, add a line to /etc/auto_master:

/Network/SageTV auto.smb

Then restart the automounter by typing: automount -vc. If you follow the latter instructions your shares will be under /Network/SageTV/SHARENAME, not /Network/SHARENAME so make sure the encoder configfile reflects this. Also if you reboot the SageTV machine and leave this network encoder running, it is no problem as it'll just remount the drives as needed, which makes this much better than other methods of accessing Windows shares from the Mac.

I've had a lot of problems with SageTV not ensuring there's sufficient diskspace. If any of your recording drives use the 'use all' diskspace rule, set it to leave 1GB free. This works for me to prevent out of disk space conditions encountered by the network encoder.

This is a universal binary for PPC and Intel Macs. It has only been tested on Mac OS X 10.4 and 10.5. To start, open a terminal, cd to the directory you unzipped it to and type
./MacOS/SageTVFirewireNetworkEncoder --help
To list firewire devices: ./MacOS/SageTVFirewireNetworkEncoder --list
To run: ./MacOS/SageTVFirewireNetworkEncoder --configfile config.txt

It opens a socket on the given port number and begins waiting for requests from SageTV. It prints incoming requests except NOOPs and FILESIZE requests to limit the output.

To run this on startup, simply open preferences, acoounts, login items and drag or otherwise add the SageTVFirewireNetworkEncoder.command batch file, included in the zipfile, as a login item. Now the encoder will be there after every reboot.

On the SageTV end to get this to work you need to edit your sage.properties file. Stop the service if in service mode and exit SageTV. Backup your SageTV directory. Add these lines to the mmc/encoders section in sage.properties.

mmc/encoders/12348/100/0/available_channels=
mmc/encoders/12348/100/0/brightness=0
mmc/encoders/12348/100/0/contrast=0
mmc/encoders/12348/100/0/device_name=
mmc/encoders/12348/100/0/encode_digital_tv_as_program_stream=false
mmc/encoders/12348/100/0/hue=0
mmc/encoders/12348/100/0/last_channel=737
mmc/encoders/12348/100/0/provider_id=1876569738441
mmc/encoders/12348/100/0/saturation=0
mmc/encoders/12348/100/0/sharpness=0
mmc/encoders/12348/100/0/tuning_mode=Cable
mmc/encoders/12348/100/0/tuning_plugin=
mmc/encoders/12348/100/0/tuning_plugin_port=0
mmc/encoders/12348/100/0/video_crossbar_index=0
mmc/encoders/12348/100/0/video_crossbar_type=100
mmc/encoders/12348/audio_capture_device_index=-1
mmc/encoders/12348/audio_capture_device_name=
mmc/encoders/12348/audio_capture_device_num=0
mmc/encoders/12348/audio_processor=
mmc/encoders/12348/broadcast_standard=ATSC
mmc/encoders/12348/capture_config=0
mmc/encoders/12348/default_device_quality=
mmc/encoders/12348/device_class=
mmc/encoders/12348/dshow_tv_type=
mmc/encoders/12348/encoder_merit=0
mmc/encoders/12348/encoding_host=ENCODERHOST\:6969
mmc/encoders/12348/forced_video_storage_path_prefix=
mmc/encoders/12348/last_cross_index=0
mmc/encoders/12348/last_cross_type=100
mmc/encoders/12348/live_audio_input=
mmc/encoders/12348/multicast_host=
mmc/encoders/12348/never_stop_encoding=false
mmc/encoders/12348/video_capture_device_name=SA4200HD
mmc/encoders/12348/video_capture_device_num=0
mmc/encoders/12348/video_compressor=
mmc/encoders/12348/video_encoding_params=Best
mmc/encoders/12348/video_processor=

Set mmc/encoders/12348/encoding_host correctly to desired host and port. The number 12348 is arbitrary and can be any number unused by any of your other encoders. The setting 'encode_digital_tv_as_program_stream' is false as the encoder generates transport stream files (.ts) not program stream (.mpg) files. Then go to the source setup. It should show a digital tuner. Choose this and assign the desired channel lineup. I suggest starting small, disabling all channels and just picking a few for experimentation. Note that if you pick the same channel lineup as existing encoders in your SageTV setup, any enabling/disabling of channels will affect them, too. I had to pick a different cable lineup from a neighboring area (in reality exactly the same) to make SageTV think it is a different lineup without affecting my other encoders' lineups.

If you have multiple cable boxes that you wish to use for SageTV recordings, simply start multiple instances of the SageTV Firewire Network Encoder on different port numbers.

You should have a wired connection between the Mac and the SageTV server if they're on different computers to ensure sufficient throughput for HD TV recordings and sufficiently low latency for live TV watching. When tuning to Live TV you may momentarily see 'no signal' due to the channel change delay but you will see video soon thereafter.

When I first started using this, I had my channel change delay too low. It caused recording of transport streams starting with a brief blip from the previous channel. SageTV does not like this kind of transport stream and more often then not, playback would stall at the moment of the channel change. So I have mine at 10 seconds now and I have no issues with playback anymore. If you experience similar issues, increase the channel change delay.

This has been tested with SageTV 6 running on PC, MacOS X 10.4 and 10.5 on Intel, Scientific Atlanta SA4200HD only. If there are additional channel change methods (only via firewire, I am not supporting any IR contraptions yet) besides the default and 'scientific-atlanta', please send me the technical details (command bytes to be sent via firewire). As of November 2008, some SA4200HD/SA4250HD reverted to the default channel change method via a software update. If you experience channel changing problems please try both channel change methods.


Visitor Counter by Digits