# PyTivo and anamorphic SD



## larrs (May 2, 2005)

I just started using pyTivo after using Tivo Desktop Plus for a number of years due to issues with TDT and my Premieres. I like it a lot and it seems rock solid. However, I am getting video format that is different than TDT and I want to know if there is a solution.

With TDT, if I copy a DVD video (1.85 or 2.35 OAR) and save as an mpg or vob file, I will get a full amamorphic 16X9 video which fills my screen (or has black bars top and bottom just like the DVD if 2.35) when I play it back on my tivos. However, with pytivo and the same video, I am getting a "window boxed" video with black bars at the top and bottom as well as the sides. If i zoom the Tivo, it fills the screen just like TDT but it looks noticably softer to me. 

Am I doing something wrong?


----------



## Iluvatar (Jul 22, 2006)

larrs said:


> I just started using pyTivo after using Tivo Desktop Plus for a number of years due to issues with TDT and my Premieres. I like it a lot and it seems rock solid. However, I am getting video format that is different than TDT and I want to know if there is a solution.
> 
> With TDT, if I copy a DVD video (1.85 or 2.35 OAR) and save as an mpg or vob file, I will get a full amamorphic 16X9 video which fills my screen (or has black bars top and bottom just like the DVD if 2.35) when I play it back on my tivos. However, with pytivo and the same video, I am getting a "window boxed" video with black bars at the top and bottom as well as the sides. If i zoom the Tivo, it fills the screen just like TDT but it looks noticably softer to me.
> 
> Am I doing something wrong?


Can I assume you are using a recent developer snapshot and not something really old that does not support the Premiere like rdian06's Windows Installer? This generally is the first issue that comes up with an old version.


----------



## wmcbrine (Aug 2, 2003)

Yeah, it sounds like a pre-Premiere version, which basically falls back to treating the Premiere as a Series 2 since it doesn't recognize it.


----------



## larrs (May 2, 2005)

wmcbrine said:


> Yeah, it sounds like a pre-Premiere version, which basically falls back to treating the Premiere as a Series 2 since it doesn't recognize it.


That may be it. Is there a proper version with a Windows installer package?


----------



## Iluvatar (Jul 22, 2006)

larrs said:


> That may be it. Is there a proper version with a Windows installer package?


No. They were created by other users but were never maintained properly. Follow the directions on the wiki to find and use a new development snapshot.


----------



## larrs (May 2, 2005)

Iluvatar said:


> No. They were created by other users but were never maintained properly. Follow the directions on the wiki to find and use a new development snapshot.


Thanks. I am well along into the process but I am stuck on the configuration. I can't get to the web configuration screen. I get "IE cannot display the web page".

Any thoughts?

EDIT- Found the issue, I made a mistake when renaming the pytivo.conf file. I will test further and see if it is all working. Man, the Wiki helps and thanks for the replies.


----------



## Iluvatar (Jul 22, 2006)

larrs said:


> Thanks. I am well along into the process but I am stuck on the configuration. I can't get to the web configuration screen. I get "IE cannot display the web page".
> 
> Any thoughts?
> 
> EDIT- Found the issue, I made a mistake when renaming the pytivo.conf file. I will test further and see if it is all working. Man, the Wiki helps and thanks for the replies.


Glad to see you got it working. Need help just ask..


----------



## larrs (May 2, 2005)

Iluvatar said:


> Glad to see you got it working. Need help just ask..


Thanks. I will.

Question number one. I haven't set up pyTivo for pushes. It seems unneeded for me. Is there some benefit from pushes over pulls from the tivo?


----------



## Iluvatar (Jul 22, 2006)

larrs said:


> Thanks. I will.
> 
> Question number one. I haven't set up pyTivo for pushes. It seems unneeded for me. Is there some benefit from pushes over pulls from the tivo?


Potentially easier and faster. Depending on how far your computer is from your couch and what types of videos you have.

Instead of requesting the video from your TiVo (a pull) you can use the webadmin interface of pyTivo to send the files to your TiVo that way instead (a push).

If you have a recent pyTivo build from your developer of choice you may be able to push the files to the TiVo as is without the time consuming transcode. Tivo compatible files such as .tivo or .mp4 files can typically be sent straight to the TiVo saving a great deal of time. Some files (such as MKV) that have compatible h264/(ac3 or aac) codecs will be quickly remuxed into a compatible MP4 and then sent. If you really get heavy into pushing files you should look at the different developers in what they offer, many of the extra customizations are in this area.

You only need to add your tivo.com username and password to your pyTivo.conf. Use the webadmin interface under 'Web Configuration' -> 'Global Server Settings'.


----------



## wmcbrine (Aug 2, 2003)

Well, a .TiVo file can always be sent without a transcode (except HD to Series 2).  But the handling of MP4 is the key difference between "push" and "pull", aside from the interface. Pulled MP4s always have to be transcoded; pushed MP4s often don't.


----------



## Iluvatar (Jul 22, 2006)

wmcbrine said:


> Well, a .TiVo file can always be sent without a transcode (except HD to Series 2).


...ahem...yes. Not sure where my head was this morning.


----------



## larrs (May 2, 2005)

wmcbrine said:


> Well, a .TiVo file can always be sent without a transcode (except HD to Series 2).  But the handling of MP4 is the key difference between "push" and "pull", aside from the interface. Pulled MP4s always have to be transcoded; pushed MP4s often don't.


Gotcha. I have been doing everything in mpeg2 so that wouldn't matter. I did that primarily to keep the DD5.1 audio with Tivo Desktop Plus and since I had an 8GB RAID array, size wasn't too critical.

With pyTivo, can I push mp4 files with 5.1 audio (either DD or another format)? That might make me rethink going forward. I have an HT Server and access to that computer in most rooms so pushing would be easy.


----------



## Iluvatar (Jul 22, 2006)

larrs said:


> With pyTivo, can I push mp4 files with 5.1 audio (either DD or another format)? That might make me rethink going forward. I have an HT Server and access to that computer in most rooms so pushing would be easy.


The TiVo supports native audio formats for MP4 video files of: AC-3 up to 5.1 640kbps (Premiere) and AAC LC up to 2 channels (not sure of akbps, but works for everything I have thrown at it). Native video format for MP4 that is supported is h.264/AVC <= Level 4.1. It also supports VC-1 type video files but I am not certain of the audio codecs that go with that file format.

If you have a MKV or other file that is sporting completely compatible audio and video then the wmcbrine branch will remux this to a MP4 on the fly and transfer it to your TiVo.


----------



## lrhorer (Aug 31, 2003)

The size savings is significant, no two ways about it. I have an 18T RAID6 array with 4.9T free, but if I were not recoding my MPEG-II files to h.264, I would have little or no free space at all. More important for me, however, is the transfer speed, especially for 720p content. Although the Premier can usually transfer even 720p content in better than real time, the S3 cannot. Even very high bandwidth 1080i content sometimes has trouble transferring without a few pauses unless one allows a few minutes of buffering, and that is on an original S3. On a THD, it's even worse. On a THD, 720p content transfers as much as 4x faster when encoded as h.264, and even a THD should not encounter buffering issues when being pushed h.264 content.


----------



## lrhorer (Aug 31, 2003)

larrs said:


> With pyTivo, can I push mp4 files with 5.1 audio (either DD or another format)?


Yes.



larrs said:


> That might make me rethink going forward. I have an HT Server and access to that computer in most rooms so pushing would be easy.


Using vidmgr, the question is moot, since vidmgr initiates pushes from the TiVo remote itself. Vidmgr's interface is also vastly superior to the NPL UI.


----------



## Phantom Gremlin (Jun 20, 2002)

lrhorer said:


> The size savings is significant, no two ways about it. I have an 18T RAID6 array with 4.9T free, but if I were not recoding my MPEG-II files to h.264, I would have little or no free space at all.


Okay, I know that this thread isn't about recoding, but I can't resist saying "huh?". I recently used Handbrake to convert the NFC championship from MPEG-II to h.264. My sizes were:

NFC championship (Fox 720p) 28.55 GB --> 24.7 GB (high preset)

Superbowl (NBC 1080i) 27.51 GB --> about 24 GB (high preset)

It was only when I changed resolution from 1080i to 720p output on the Superbowl that I got down to 14.69 GB.

So without reducing resolution the size change from MPEG-II to h.264 was minimal.

So, when you are _"recoding my MPEG-II files to h.264"_ are you also reducing resolution? Or are you using a better transcoder than the free Handbrake?


----------



## txporter (Sep 18, 2006)

Phantom Gremlin said:


> Okay, I know that this thread isn't about recoding, but I can't resist saying "huh?". I recently used Handbrake to convert the NFC championship from MPEG-II to h.264. My sizes were:
> 
> NFC championship (Fox 720p) 28.55 GB --> 24.7 GB (high preset)
> 
> ...


What are you using for the quality setting (CRF)? Seems like you are using a setting that is too high (CRF number too low).

Handbrake uses x264 as its h.264 transcoder.

I transcode all of my video with avisynth and x264. If I take a 1hr 1080i show (~4.5GB after commercial removal) and transcode to 720p24 H.264, I usually end up in the 800MB territory. I use CRF of 21 for HD shows and 19 for SD.

If you don't reduce resolution, you should still see 30-50% file size reduction.


----------



## larrs (May 2, 2005)

lrhorer said:


> Yes.
> 
> Using vidmgr, the question is moot, since vidmgr initiates pushes from the TiVo remote itself. Vidmgr's interface is also vastly superior to the NPL UI.


This sounds promising. Is there a link to a download and maybe a Wiki for vidmgr? OK, I found someone's thread over in the Developer's thread and it really does look amazing- think the family would love it and it would cut my file sizes to boot. I will give installing a try. It looks as if the OP in that thread had all the questions I might have.

You guys willing to help an almost clueless dolt? I'll look for tips in that thread (wmcbrine, lrhorer, Iluvatar)...


----------



## larrs (May 2, 2005)

Phantom Gremlin said:


> Okay, I know that this thread isn't about recoding, but I can't resist saying "huh?". I recently used Handbrake to convert the NFC championship from MPEG-II to h.264. My sizes were:
> 
> NFC championship (Fox 720p) 28.55 GB --> 24.7 GB (high preset)
> 
> ...


I am using VideoRedo for my mpeg2 files and I get a substantially smaller file. Your settings must be off. I use 70% in VideoRedo (which is similar to Handbrake's CRF settings) and cannot tell the difference. The file is almost 50% smaller, usually.


----------



## Phantom Gremlin (Jun 20, 2002)

txporter said:


> What are you using for the quality setting (CRF)? Seems like you are using a setting that is too high (CRF number too low).
> ...
> I use CRF of 21 for HD shows and 19 for SD.


Just to clarify, I'm using the default presets in Handbrake 0.95. E.g. for "Apple TV 2" it uses Constant quality RF: 20 (and sets max of 1280x720, so 1080i material will be downrezzed). The "Regular, High Profile" setting also uses RF:20. No doubt that if I fiddle with RF I could get smaller transcodes.

I haven't tried any Handbrake nightlies. From briefly scanning their forums I gather that a new "official" release is coming soon.

I've been meaning to try VideoRedo. I think it's great when companies make available their software for free trials. Unfortunately I know it will be more hassle for me to try this than the for average guy, since I'd have to do it under VMware Fusion.


----------



## txporter (Sep 18, 2006)

I will admit to never transcoding sports event, but the compression sounds awful. If you can cut a ~1-2 min clip from one of those, I would be willing to tinker with it.


----------



## lrhorer (Aug 31, 2003)

You've had a couple of days to tinker with vidmgr, now. How are you liking it?


----------



## martyscholes (Apr 29, 2009)

I apologize for taking this thread even further off its tracks, but...

The transcoding discussion is right in line with a question I have. I feed a HD Tivo from a Solaris box running Streambaby and PyTivo. I recently started transcoding vob files to mp4 using the medium (whatever that means) ffmpeg command line from kmttg, ending up with a mp4 file about 40% the original size.

This is doing wonders for storage and streaming speed to the Tivo, but I have noticed that the video sometimes will not allow me to "instant replay" back 5 seconds, and rewinding makes the Tivo think for a little while before it backs up.

Is this normal for mp4 files? Is there some voodoo setting I should be using when encoding? The actual command line I use is:

nice ffmpeg -y -i "${src_fn}" -threads 4 -vcodec libx264 -coder 0 -level 41 -sameq -subq 6 -me_range 16 -qmin 10 -qmax 50 -g 300 -bufsize 14745k -b 2000k -maxrate 16000k -bug "+autodetect+ms" -me_method epzs -trellis 2 -mbd 1 -acodec copy -f mp4 "${dst_fn}"

Any advice appreciated,
Marty


----------



## wmcbrine (Aug 2, 2003)

martyscholes said:


> Is this normal for mp4 files?


Sadly yes. But maybe someone will have a fix?


----------



## martyscholes (Apr 29, 2009)

wmcbrine said:


> Sadly yes. But maybe someone will have a fix?


That was a scary-fast response. Many thanks! So, it's an mp4 thing at the Tivo? Is there another container that works, or this is just something that we live with? Does the Premiere have this feature?

Thanks again.


----------



## wmcbrine (Aug 2, 2003)

The Premiere definitely handles MP4 better than the S3, but it still has issues. I've had no luck trying to insert h264 video into a TiVo using a different container.


----------



## martyscholes (Apr 29, 2009)

wmcbrine said:


> The Premiere definitely handles MP4 better than the S3, but it still has issues. I've had no luck trying to insert h264 video into a TiVo using a different container.


Ok. Many thanks.


----------



## Iluvatar (Jul 22, 2006)

martyscholes said:


> That was a scary-fast response. Many thanks! So, it's an mp4 thing at the Tivo? Is there another container that works, or this is just something that we live with? Does the Premiere have this feature?
> 
> Thanks again.


It seems to be issues with the key frames and how the original video stream was encoded.

Discussion here: http://www.tivocommunity.com/tivo-vb/showthread.php?p=8799167#post8799167

I would use handbrake for future encodes and change the mentioned settings based on the frame rate of the video.


----------



## txporter (Sep 18, 2006)

Iluvatar said:


> It seems to be issues with the key frames and how the original video stream was encoded.
> 
> Discussion here: http://www.tivocommunity.com/tivo-vb/showthread.php?p=8799167#post8799167
> 
> I would use handbrake for future encodes and change the mentioned settings based on the frame rate of the video.


Yes, it is most likely the key frame interval.

You can look here to see how to map various x264 commands into ffmpeg.

On your command line, you could add something like -g 50 -keyint_min 25 (or -g 25 -keyint_min 12). For FILM rate material here in the states, there are ~24 frames per second. For PAL material, there are 25. For telecined, there are ~30. So a key frame setting of 50 will give you a keyframe about every 2s. Default for x264 and ffmpeg is 250 for keyframe, you were setting it to 300. When your Tivo decodes the video, it needs to seek back to the nearest keyframe to start decoding since the P-frames and B-frames are based on keyframes.

Even with that, seeking on H.264 encoded files will not be as good as MPEG2, but it will be better.


```
ffmpeg -y -i "${src_fn}" -threads 4 -vcodec libx264 -coder 0 -level 41 -sameq -subq 6 -me_range 16 -qmin 10 -qmax 50 [B][COLOR="Red"]-g 50 -keyint_min 25[/COLOR][/B] -bufsize 14745k -b 2000k -maxrate 16000k -bug "+autodetect+ms" -me_method epzs -trellis 2 -mbd 1 -acodec copy -f mp4 "${dst_fn}"
```
P.S. You can probably shorten your commandline quite a bit. And I would recommend using a quality based encoding profile rather than a fixed bitrate. But whatever works for you.

Possible encoding profile (not sure if you really need the buffer size and max bitrate setting or not):

```
ffmpeg -y -i "${src_fn}" -threads 4 -vcodec libx264 -vpre medium -crf 19 -g 50 -keyint_min 25 -acodec copy -f mp4 "${dst_fn}"
```


----------



## larrs (May 2, 2005)

lrhorer said:


> You've had a couple of days to tinker with vidmgr, now. How are you liking it?


Love it. Works great and worth every penny.. 

And, again, thanks for the help in the developer's thread getting it going. And thanks to wmcbrine as I am using his pyTivo work as well...


----------

