Saturday, April 17, 2010

Viva pyTivo!

No sooner had I posted Stream, Baby, Stream about the StreamBaby computer app than I discovered pyTivo. pyTivo, like StreamBaby, is software you use to play videos on your TiVo when they reside on your computer.

pyTivo incorporates StreamBaby, which means your TiVo can stream a video to itself from a hard drive on your computer. Streaming the video lets you play it without making a copy on your TiVo's hard drive.

pyTivo can also send videos to your TiVo from your computer, meaning that you at your computer can initiate copying a video file to the TiVo's hard drive, after which it can be played just as if the TiVo had recorded it in the usual way.

pyTivo can use TiVo-playable videos in formats that plain old TiVo Desktop software can't deal with.

Just as with StreamBaby, pyTivo does not require you to alter the software or hardware of your TiVo in any way. In fact, your TiVo continues to run the same old software downloaded to it by TiVo, Inc.

pyTivo, like StreamBaby, runs on various computer platforms: Windows, Mac OS X, Linux, and others. I talk here mainly about running it on a Mac.

It is a good thing that there is a Mac version — called pyTivoX — for, as I detailed in Stream, Baby, Stream, installing StreamBaby on a Mac is a bit of a bear. For one thing, StreamBaby installation requires you to obtain and install FFmpeg, the "complete, cross-platform solution" that lets your computer record, format-convert, and stream videos. pyTivoX contains FFmpeg from the get-go.

Since pyTivo likewise contains StreamBaby, installing pyTivo obviates ever having to install and configure either StreamBaby or FFmpeg.

To install pyTivoX version 1.3, click here for a download. (But first go here to see if there's a later version.) pyTivoX downloads to a Mac as a disk image file with a .dmg extension, which, when opened, looks like this:



You just drag the pyTivoX icon to your Applications folder, and your pyTivoX/StreamBaby/FFmpeg installation is finished!


Now, open the pyTivoX application. Above is the pyTivoX window that you'll see. I simply clicked on the + sign and added my "TiVo Transfers" folder to be shared with my TiVos. (In geek parlance, such a folder or directory is called a "video share.")

I also clicked the Prefs button (the light switch) and enabled the use of StreamBaby within pyTivoX:



And I also checked to make sure pyTivo itself was enabled. It was:



In the General Prefs pane I needed to enter my TiVo.com username and password:



That was important because the "push" functionality I talk more about later won't work if you don't supply those two pieces of information to pyTivoX.

Notice that nowhere is there any way for you to enter your TiVo's media access key, or MAK; I assume pyTivoX learns that from your account at TiVo.com. Nor do you have to enter the IP addresses of your computer or your TiVo. pyTivoX figures those out for itself.

After dismissing the Prefs window, I clicked the green Apply checkmark in the main window (which is pyTivoX's only window). At that point I went over to one of my TiVos and found something like this in my Now Playing list:



This is not mine, actually; it's "Rob's PC," which is the "share name" Rob (a Windows user?) gave in his pyTivo Shared Directories list to the folder or directory on his computer that contains his videos. Selecting it in the Now Playing list would bring up a list of that folder's files ... and its subfolders, if any, which themselves contain videos. Navigating down in that list on his TV screen, Rob can tell pyTivo to transfer any one of his videos to his TiVo.

That's pyTivoX as it affects the Now Playing list. Additionally, towards the bottom of the TiVo's Music, Photos, & Showcases menu — which you get to from the TiVo Central menu— you'll see something like pyTivoX - iMac.local, indicating that pyTivoX is running on a computer whose local hostname is iMac.local. If you run pyTivoX and your computer's hostname happens to be (say) Powerhouse.local — you set your Mac's hostname in Sharing Preferences, by the way — you'll see pyTivoX - Powerhouse.local instead.

The Music, Photos, & Showcases menu is pyTivoX's StreamBaby interface per se. It's the way you stream your videos from your computer for instant watching on the TiVo. It's a little bit easier to stream videos from this interface than to download them in the Now Playing list and then start watching them as they are downloading. Plus, using the StreamBaby interface keeps the TiVo from having to make room for a copy of the video on its own hard drive.

Here's the kind of thing you'll see after you select a video in pyTivoX's StreamBaby interface on your TiVo:



This particular video has already started to play, so the top menu item says "Resume playing"; otherwise, it would simply say "Play." The second menu item from the top lets you snap right back to the beginning of the movie if you've already started playing it. If you haven't started playing the video, this item is not present in the menu at all.

"Quality" refers to the average bitrate of the video: the average amount of data per second that will be streamed to the TiVo. Here, "Same - 9769 kb/s" indicates that the size of the video file divided by its running time — its average bitrate — comes to 9,760 kilobytes per second. That's the average bitrate, not the peak, and the fact that the average bitrate is pretty high (anything over, say, 5,000 kb/s is quite high) suggests that occasional bitrate peaks might overload your local network's data delivery speed, causing playback to pause — and, unfortunately, to do so repeatedly. Whenever the playback pauses, you'll have to hit Play on the TiVo remote to get it to start again. You should wait and hit Play after you think there has been enough newly received data buffered on the TiVo to avoid another playback pause any time soon.

If you get tired of hitting Play after endlessly repeated pauses, you can change the StreamBaby Quality to any of several lower bitrates. StreamBaby will, via its self-contained copy of FFmpeg, do things like (I am guessing) drop every third video frame to reduce the peak bitrate to an acceptable level. That will ideally keep you from having to hit Play over and over and over on your TiVo remote, but it can cause playback to present more "strobing" to your eyes than they might appreciate. Strobing can make the playback seem blurry in fast-motion scenes.

The next menu item is interesting. "Push video:" tells StreamBaby to cause the Bedroom TiVo — in this example; you can select among all the TiVos in your house — to summon the entire video file. It will be transferred in its entirely to the Bedroom TiVo's hard drive, and it will then appear the Bedroom TiVo's Now Playing list, allowing it to be played like any other video recording. The benefits:

  1. You can push videos in the MPEG-4 h.264 (or AVC) format that plain old TiVo Transfer on your computer wouldn't let you transfer. These files as computer files usually have an .m4v or .mp4 extension, not the .TiVo or .mpg extensions associated with MPEG-2 files that TiVo Transfer can handle. (The movies and TV Shows in your iTunes library usually have an .m4v extension, by the way.) There's a catch, though. Videos you purchase from the iTunes Store are encrypted and need to be independently decrypted before the TiVo can play them at all. It's beyond the scope of my article to say how to do that.
  2. You can also push and watch unencrypted videos in the familiar (if now outmoded) WMV format.
  3. Pushing a video allows you to (after a sufficient amount of the file has been received and stored) play the video from your TiVo's Now Playing list without encountering irritating pauses or having to throttle down the bitrate to avoid them.

What's the difference between "pushing" and "streaming," again? With "pushing" you wind up with a copy of the original file in your TiVo's Now Playing list. With "streaming," you simply play the video without making a copy on the TiVo.

Both of these options come from the StreamBaby interface on the TiVo, while a third option, "pulling" a copy of the video to the TiVo, comes from the pyTivoX interface proper. The pyTivoX interface is initiated directly from your TiVo's Now Playing list.

"Pulling" the video over to the TiVo has the advantage of having pyTivoX "transcode" the video into a different format en route to the TiVo, and that may be necessary to do if for some reason the video file as it resides on your computer cannot be played "natively" on the TiVo.

So if you try "streaming" the video and it looks terrible or won't play at all, try "pulling" it instead. Go to the Now Playing list on the TiVo and scroll down until you see the name of any of your "share" folders. For example, in the earlier screenshot image "Rob's PC" is the name of a share folder. When selected on the TiVo, it opens up to show all of the video files it contains ... and also any subfolders. You can drill down through the subfolders to find the video you want. Select that video and then select "Transfer this recording." In a matter of seconds it will start to transfer. The blue LED will come on on the front of the TiVo, and you will be asked whether you want to start watching the video while the transfer is ongoing.

If you do start to watch, you may quickly find that playback pauses because the rate of transfer cannot keep up with the rate of playback. After a while, you hit the play button, see some more of the video ... and get another"hard pause." Let the transfer proceed for a while. Then resume play. You may find  at that point that enough of the video has been transferred to keep playback from pausing henceforth.

Or you may not. If not, just do something else for a while. When you come back to the video, you'll most likely find it at the top of your Now Playing list, and if the transfer is not yet complete, you'll see the "blue button" icon next to it. You can initiate playback now just as you would any other recording in the Now Playing list.


So, those are the basics of the pyTivoX/StreamBaby/FFmpeg package for the Mac. Using it, you can watch any video file that sits on your computer — well, any video file that is in a format pyTivoX/StreamBaby/FFmpeg understands — on your TV, via your TiVo. Enjoy!

7 comments:

Unknown said...

Hi thanks for the blog. I find it very useful and thorough. I have been using pyTivoX for a few months now and just love it. But I have a question for you.

But I notice that pyTivoX sometimes cannot stream files but if I copy the videos to the Tivo hard drive they play. This is a little inconvenient. I would like to be able to simply call up a video on demand and not wait for it to be copied over to the Tivo (which sometimes takes a little while).

I noticed that the latest version of Streambaby was released in January while the most recent version of pyTivoX hasn't been updated since August.

Have you found pyTivoX to perform just as reliably as Streambaby when streaming video?

I am thinking about installing Streambaby if it will be an improvement over streaming on pyTivoX.

Keep up the great work! I'll subscribe to your blog as soon as I find the RSS/XML link.

eric said...

Dave,

You said:

I notice that pyTivoX sometimes cannot stream files but if I copy the videos to the Tivo hard drive they play. This is a little inconvenient. I would like to be able to simply call up a video on demand and not wait for it to be copied over to the Tivo (which sometimes takes a little while).

I noticed that the latest version of Streambaby was released in January while the most recent version of pyTivoX hasn't been updated since August.

Have you found pyTivoX to perform just as reliably as Streambaby when streaming video?

I am thinking about installing Streambaby if it will be an improvement over streaming on pyTivoX.


If you want, you can replace the now-outdated version of Streambaby that comes with pyTivoX. Download and expand the latest Streambaby release, the 0.29 version of StreamBaby, available here. Open the folder and find the Unix Executable file called streambaby.

Quit pyTivoX and locate the pyTivoX application file, and right-click on it. Choose Show Package Contents. Then drill down into the Contents: Resources: streambaby folder to find the old Unix Executable file called streambaby. Replace the old one with the new. (You may want to drag the old one to the desktop so you can undo the operation if anything goes wrong.)

Now restart pyTivoX. You'll be using the most up-to-date version of Streambaby, so any problems that resulted from using an older version will be gone.

However, I am having no such problems as you describe, even though I'm using the Streambaby that originally came with pyTivoX.

I encourage you to be sure you're actually using the Streambaby interface in pyTivoX, which is found on the TiVo in the Music, Photos, & Showcases menu. If you're using the interface in the Now Playing list instead, it's not Streambaby.

The latter interface always requires a copy of the file to be made on the TiVo. The former does not (unless, of course, you force that to happen by requesting that the file be "pushed" to your TiVo). As long as you just choose "Play" while in the Streambaby interface, no copy is made on the TiVo.

That said, you may find that such file streaming doesn't go fast enough to avoid repeated pausing. I have noticed that any file whose stated bitrate is over about 4,000 kbps does that. In the Streambaby interface you can reduce the quality to a lesser bitrate to avoid the problem. But that gives you a fair amount of strobing on fast motion scenes, I find. There are tradeoffs no matter what you do ...

I have just become aware that TiVo, Inc. is advertising a new "N wireless" adapter for their boxes, which I plan on checking out. The standard adapter, up to now, is "G wireless." Replacing 802.11g Wi-Fi transmissions with 802.11n stands to speed things up.

Oh, and as to your observation that "pyTivoX sometimes cannot stream files but if I copy the videos to the Tivo hard drive they play":

When files are truly being streamed to the TiVo — not copied, and not with their quality being lowered — they have to be in a video format that the TiVo can play natively and well. My experiments have shown that some files stream properly and some don't, and the difference can have to do with arcane things like what advanced options were used during MPEG-4/H.264 encoding. Copying and quality-lowering both cause the video to pass through FFmpeg on the Mac and get transcoded to MPEG-2 en route to the TiVo, which avoids the need for the TiVo to do much at its end.

Hope all this helps...

Eric

DEWidi said...

I have been converting my DVD files (Video .TS) via Handbrake to .264, but I am unable to load the .mp4 files into the pyTivoX window. When I try to use the add button it shows the files in gray. Should I be using the FFMpeg setting instead? I have been searching the web looking for more information about this, but I'm coming up blank.
If anyone has a simple workflow solution that will allow me to do this correctly I would really appreciate it.
Thanks.

eric said...

DEWidi said...

I have been converting my DVD files (Video .TS) via Handbrake to .264, but I am unable to load the .mp4 files into the pyTivoX window. When I try to use the add button it shows the files in gray. Should I be using the FFMpeg setting instead? I have been searching the web looking for more information about this, but I'm coming up blank.

If anyone has a simple workflow solution that will allow me to do this correctly I would really appreciate it.


DEWidi,

I hope I'm not misunderstanding your question, but the solution to your problem may be a simple one.

If I understand you correctly, you are trying to designate h.264 files in pyTivoX. That won't work, because pyTivoX wants you to designate directories, i.e., folders, not files. These "shared directories" are also known as "video shares," and they contain the files you want to stream or push or pull to your TiVo.

They can also contain subfolders, nested to any desired level, that contain the actual video files.

If you designate a video share folder and click on the Apply button in pyTivoX on your Mac, you should be able to scroll down in your TiVo's Music, Photos, & Showcases menu to find the entry representing your Mac, and then use that entry's own menu hierarchy to drill down and find any particular one of your actual video files, which you can then play via the Streambaby streaming interface that is contained in pyTivoX.

On my Mac, I give my Handbrake h.264 output files the .m4v filename extension, not .mp4, by the way. I don't know if it makes any difference.

I have also found that some Handbrake output files I have created don't play well on my older TiVo HD and TiVo Series 3 boxes, when streamed/pushed/pulled via pyTivoX. There are too many permutations to go into here, but various exact Handbrake settings I have used with various versions of Handbrake have caused various playback problems with certain movies. If you run into specific problems along these lines, I will be happy to try to work with you to address them ... but I make no guarantees that there is a real, general solution here!

Best of luck,
Eric

Anonymous said...

what a fantastic way to get my home library transferred to my tivo. i used to burn dvd's just to convert things to mpeg2 and then extract the files with mpeg steamclip and then use tivo desktop to get them on my tivo.

this is just totally amazing. pytivo just works! when i think about the hours i spent getting tivo desktop to work on my macs...

Chaim Galfand said...

I think my problem is even simpler than DEWidi - apologies if it's so obvious. You note that you must first designate a video share folder. I've done that & have tried filling that folder with individual files (avi, & even mpeg2) and filling it with subfolders with content - and the main video share folder shows up in the NPL on my TiVo HD. Selecting it in the NPL *should* bring up a list of that folder's files, but the video share folder appears empty. In other words, files and subfolders appear in the main folder on my Mac yet they do not appear in that folder on the TiVo. Simple solution? I've tried restarting the mac, the tivo & t pytivox. Thanks!

eric said...

Ravmocha said...

I think my problem is even simpler than DEWidi - apologies if it's so obvious. You note that you must first designate a video share folder. I've done that & have tried filling that folder with individual files (avi, & even mpeg2) and filling it with subfolders with content - and the main video share folder shows up in the NPL on my TiVo HD. Selecting it in the NPL *should* bring up a list of that folder's files, but the video share folder appears empty. In other words, files and subfolders appear in the main folder on my Mac yet they do not appear in that folder on the TiVo. Simple solution? I've tried restarting the mac, the tivo & t pytivox. Thanks!

Ravmocha,

I am not clear as to whether the subfolders of your main share folder fail to show up on your TiVo, or whether it's just your video files inside those subfolders that are missing.

Nor am I clear whether you are trying to use pyTivoX's classic pyTiVo interface or its Streambaby interface. I'll assume Streambaby.

So, on your TiVo, I'd like to be sure you are using the TiVo's Music, Photos, & Showcases menu, within which should be a pyTivoX item. It is in that pyTivoX menu item that you should be finding the share folders and subfolders and the contained video files. If you don't see a pyTivoX menu item in the TiVo's Music, Photos, & Showcases menu, then the problem would be that pyTiVoX's Streambaby interface isn't being seen by your TiVo for some reason.

If you can see pyTiVoX in the Music, Photos, & Showcases menu and if your share folders and subfolders are visible there, then I assume the problem is that the video files themselves are invisible to the TiVo for some reason. The reason could be that the files don't have filename extensions like .TiVo, .mpg, and .m4v which pyTivoX recognizes.

If on the other hand you are trying to use the classic pyTivo interface of pyTivoX, you would expect to see all of your share folders and subfolders, along with their video file contents, in the Now Playing List itself. If the main share folders are showing up but not their subfolders, I'm baffled. I have no idea why that might happen. The only thing I can think of is that maybe the subfolders are considered "hidden" by Mac OS X. (Are you using Snow Leopard? I use Leopard. Possibly pyTivoX is not compatible with Snow Leopard?)

If you are seeing the subfolders but not the files in the classic pyTiVo interface of pyTiVoX, then again I'd like to be sure you are using filename extensions pyTiVoX recognizes.

Good luck debugging your issue ...

Eric