# Should pyTivo be able to stream in realtime?



## grahamg (Aug 18, 2006)

First a really BIG thank you to the people working on this application!

PC HP a1540n AmD 64, XP pro 3gb ram
pyTivo ver 208
Tivo series 2 ver 9.1
Tivo wireless G USB adapter

I have a couple of questions. pyTivo is running as a service and is looking great, but I am curious if I am getting the best performance in terms of transcoding a movie and getting it into my Tivo. I have found that if I select and play a movie while it is transferring to the Tivo the transfer is slightly slower than real time. But I have read somewhere that it should be better than realtime.

The wifi signal strength is 60 - 70%, but I don't know what the transfer bit rate is. ffmpeg_mp2.exe when trans coding is taking 6-10% CPU and the 100mbs PC to wireless LAN adapter is utilizing about 3%. If I ping my wireless LAN adapter its average round trip is 25ms, If I ping the Tivo its average is 120ms.

I would just like to know what, if anything, is the likely weak link in the system, unfortunately the Tivo wifi can't be avoided, running a cable would be a nightmare. I might be persuaded to purchase a powerline network adapter.

Minor quirks noticed.

1. If a file transfer is interrupted it wont resume
2. If a partial file is on the Tivo it won't delete from the Now Playing List. But it can be deleted by playing it advancing to the end and then deleting.
3. The To Do list got confused and I was not able to cancel a transfer. The solution is to restart the Tivo.

Great work, keep it up!


----------



## dlfl (Jul 6, 2006)

My impression is that most people get speeds better than realtime. With a wired connection and a series 2 I get about 30&#37; better. It does depend on what bit rate you have pyTivo configured for. I'm using the default 4096kbps (or 4 Mi) video_br. The network speed it takes to go realtime is proportional to video_br. If you are close to realtime there's probably nothing wrong.


----------



## Dan203 (Apr 17, 2000)

The big question is what series is your TiVo and what wifi adapter are you using? The 540 series S2 units, the silver ones with the night light or Toshiba/Humax DVD units, are particularly slow when it comes to all things networking. So if you have one of those there is only so much performance you can get. Also the TiVo brand wireless adapter is considerably faster then any other USB wifi adapter available. If you want to make sure that your network is going as fast as it possibly can then make sure you're using a TiVo brand wifi adapter. Other then that it could be PC performance depending the quality setting you're using and other available resources on the PC. It could also be congestion and/or interference with your wifi network. If you have a 2.4GHz phone or a neighbor with a wifi network you may want to try changing the channel on your wifi access point and see if that helps.

Dan


----------



## grahamg (Aug 18, 2006)

Dan203 said:


> The 540 series S2 units, the silver ones with the night light or Toshiba/Humax DVD units, are particularly slow when it comes to all things networking. So if you have one of those there is only so much performance you can get.
> 
> Also the TiVo brand wireless adapter is considerably faster then any other USB wifi adapter available.
> 
> Dan


Hi Dan, Well sadly I do have a model TCD540040. I am using a kosher Tivo brand wifi adapter. My Linksys wifi router is setup to look for and select the optimum wifi channel.

I think the PC is well up to it being a dual core Athlon 64 X2 4200+ 2.2 GHz during transcoding the ffmpeg_mp2.exe is only using 6-10% CPU.

I am about to do a few tests and I will post them on dlfl's message to me when I complete them a bit later.

Thanks!


----------



## grahamg (Aug 18, 2006)

dlfl said:


> My impression is that most people get speeds better than realtime. With a wired connection and a series 2 I get about 30% better. It does depend on what bit rate you have pyTivo configured for. I'm using the default 4096kbps (or 4 Mi) video_br. The network speed it takes to go realtime is proportional to video_br. If you are close to realtime there's probably nothing wrong.


Dan mentioned the series2 model 540 model is bad, what model do you have?

I have just done an experiment. I installed Videora and converted a 1hr 640x352 132kbps AVI file to Tivo Native mpg. It took 24 minutes, running at about 4400 kbps

I then used PyTivo to play that file on the Tivo. The results are that this JUST keeps up with realtime, but certainly not 30% better.

I would like to play a bit with the ffmpeg settings, but don't understand a few things.

a). what is the default PyTivo resolution? is it 480x480? I know video default is 4096k and audio 192k audio, 29.97 fps

I found the following on a website 
quote

TiVo video is recorded at 2/3 D1 (480x480) resolution at 29.97 frames per second with constant-bitrate MPEG-2 at one of four bitrates:

Setting Bitrate
Best 5.8 Mbps
High 3.5 Mbps
Medium 2.6 Mbps
Basic 1.47 Mbps

Regardless of video bitrate, audio is sampled at 32 kHz and always recorded with constant-bitrate MPEG-1 Layer 2 at 192 kbps

unquote

The following is copied from the pyTivo config file.

#Output Pixel Width: if you have an HDTV you might want to try 720 or 704
#Valid: 720, 704, 544, 480, 352
#width=1440
#height=720

#If you want to use 16:9 or 4:3 on this tivo
#aspect169=true
#width=1440
#height=720
#audio_br=320K
#video_br=12Mi
#ffmpeg_prams=-i %(in_file)s -vcodec mpeg2video -r 29.97 -b %(video_br)s -maxrate %(max_video_br)s -bufsize %(buff_size)s %(aspect_ratio)s -comment pyTivo.py -ac 2 -ab %(audio_br)s -ar 44100 -f vob -

I don't understand how pixel width relates to resolution, if these are valid pixel widths #Valid: 720, 704, 544, 480, 352. What are valid pixel heights ? What is the 44100 number? What is bufsize - maybe I can increase it? I tried to find some online help about the ffmpeg command line but failed.

Sorry this has gone on a bit, but any help would be appreciated. I am driving a 50" Plasma with Svideo (dont laugh) but the results are quite good.


----------



## grahamg (Aug 18, 2006)

Dan203 said:


> The big question is what series is your TiVo and what wifi adapter are you using? The 540 series S2 units, the silver ones with the night light or Toshiba/Humax DVD units, are particularly slow when it comes to all things networking. So if you have one of those there is only so much performance you can get. Also the TiVo brand wireless adapter is considerably faster then any other USB wifi adapter available. If you want to make sure that your network is going as fast as it possibly can then make sure you're using a TiVo brand wifi adapter. Other then that it could be PC performance depending the quality setting you're using and other available resources on the PC. It could also be congestion and/or interference with your wifi network. If you have a 2.4GHz phone or a neighbor with a wifi network you may want to try changing the channel on your wifi access point and see if that helps.
> 
> Dan


I have had some success speeding up file transfer to the Tivo. I replaced the supplied ffmpeg_mp2 + pthreadGC2.dll with newer version r10464. With the supplied ffmpeg the transcoding to the PC was happening either at or slightly less than realtime.

The r10464 version is now converting at 10-30% quicker than realtime. I just transfered a 45 minute program and played it at the same time. The downloading was finished with the player about 50% into the program. The ffmpeg processes CPU time has gone from 6-10% CPU to 15-20%.

Anyway this works for me, I just pass it on for info.


----------



## schwingle (Nov 7, 2007)

I don't know that including my config will help much, but here goes. 

I'm running python 2.51, pytivo 2.08 on a P3 700 Mhz with 348MB RAM, XPSP2. This is my media server. It also runs Tivo Desktop Plus with a key so it is the paid version and it runs SnapStream's Beyond Media. It uses a wired gigabit card on a gigabit D-Link gaming router. The Tivo is a refurb dual tuner series 2 that I bought about a month ago and it is running on wired cat5 and is plugged into the same router. I doubt it is getting better than 100Mbit as I don't think these have gigabit cards in them. Anyway, I normally stream my Battlestar Gallactica episodes in AVI format (about 370MB) up to the tivo and I don't wait more than about 15 seconds between starting the transfer and watching the show. By the time I'm about 15 minutes into the show, the entire episode has transferred to the tivo.


----------



## grahamg (Aug 18, 2006)

Thanks for the info, in my case it seems the bottleneck is my series 540 Tivo, and possibly my wifi. But I am pleased to say that same as you I only need to wait 15 seconds or so now before I can watch a streaming program. PyTivo is turning out to be quite excellent. The fact you are using a P3 700mhz helps to confirm that my woes are in the network dept. But a LAN cable to the Tivo is not really practical.

The main reason I have gone down the PyTivo path was because I wanted to watch a BBC program series called Topgear. Which I can get online. I had not heard of Snapstreams product before and it looks pretty good. Is it stable? I have been considering what to do as a follow up to my Tivo2, most recently have looked at using an Xbox as a media center, all in all there seems to be quite a few possibilities other than Tivo, which we still love btw. But we don't want to get into any monthly subscriptions, even the cost of changing our lifetime subscription to a series3 bothers me (cheapskate). I have tried TD plus, but it turned into a nightmare and I have removed it.


----------



## dlfl (Jul 6, 2006)

grahamg said:


> Dan mentioned the series2 model 540 model is bad, what model do you have?


I have a model 649 (Series 2, Dual Tuner)


grahamg said:


> I have just done an experiment. I installed Videora and converted a 1hr 640x352 132kbps AVI file to Tivo Native mpg. It took 24 minutes, running at about 4400 kbps
> 
> I then used PyTivo to play that file on the Tivo. The results are that this JUST keeps up with realtime, but certainly not 30% better.


I suspect it was still being re-encoded by pyTivo because it still didn't meet specs for tivo-compatible mpeg2.


grahamg said:


> I would like to play a bit with the ffmpeg settings, but don't understand a few things.


These is documentation on ffmpeg here although it's not easy to understand.


grahamg said:


> a). what is the default PyTivo resolution? is it 480x480? I know video default is 4096k and audio 192k audio, 29.97 fps


544x480 Most Tivo models will take this and DISPLAY it at 4:3 (640x480) or 16:9 (853x480).


grahamg said:


> I found the following on a website
> TiVo video is recorded at 2/3 D1 (480x480) resolution at 29.97 frames per second with constant-bitrate MPEG-2 at one of four bitrates:
> (...... etc.)


The complete story is more complicated. My series 2 DT will record at
352x240, 352x480 and 480x480, with four different bit rates ranging up to 5800 kbps. Other models will vary.

Then each model has a set of resolutions that it will accept which can be different that what it records at (e.g., 544x480 in my case). In all cases the aspect ratio signalling in the file tells the display device what actual format to display at. There is a tivo web page that gives these specs but I just spent 5 mins trying to find it so ......


grahamg said:


> I don't understand how pixel width relates to resolution, if these are valid pixel widths #Valid: 720, 704, 544, 480, 352. What are valid pixel heights ? What is the 44100 number? What is bufsize - maybe I can increase it? I tried to find some online help about the ffmpeg command line but failed.


For Series 2 the valid height is 480. For the HD models I think 720 or possibly even 1080 are valid heights. In the pyTivo world the program tries to have a set of valid heights and widths built into it and it decides whether to re-encode with ffmpeg or just transfer the file as is based on whether it fits one of these "valid" width/height combos. For a python programmer it is easy to view and modify these internal combinations in the code.

The 44100 is audio sampling rate (samples per sec), which is a different thing than audio bitrate (used for encoding audio).

bufsize is a buffer used by ffmpeg. It always had this parameter but it only got into pyTivo recently when OP started doing high bitrate HD transcoding. Just leave it at the (huge) default setting, 17MB I think. It doesn't hurt anything whether you need it or not.

Sorry but it would take a small book to explain these topics fully and then it would probably have errors in it anyway! Scan the pyTivo wiki for some more discussion of aspect ratio and useful links on that topic.


----------



## schwingle (Nov 7, 2007)

Beyond Media is a decent program. I like it, though it is a bit old. When I bought it, I got the bundle with the remote and my media PC is connected S-Video out to the back of the 2nd tv with a $15 jack from Radio Shack that converts the soundcard out to red and white RCA cables. 

I mostly pull tv shows through torrents and they come down as avi files. They are reasonably sized and beyond media plays them really well. It is a little cludgy with music but that is only because my music collection is unwieldly large. 

Snapstream has another product - Beyond TV which is basically a PC based Tivo style solution for recording shows. They also sell bundled Hauppage cards but when I decided to go with dedicated recording. Anyway, Beyond TV was just recently updated and handles IPod and mpeg formats I believe. I'm hoping that they update Beyond Media next to handle mpeg. It would alleviate my need to convert my .tivo through to .avi though I still might considering the space savings I get by going to avi.


----------



## MasterCephus (Jan 3, 2005)

I upgraded my pyTivo to pyTivo-2007-11-25-subfolders-8.3-10bf9e4e15a51c6a758fabefb75f6502b7809e09 and everything seems to be fine. I transferred a movie and am watching it and it looks good.

I did notice that in the NPL the movie took the name of the folder name it was in and when I click on it, it shows the actual name of the movie under it on the next screen. I imagine that once I put in the txt files for the meta data that will fix that.

I also was able to search through subfolders pretty decently. I have noticed (even in version 201) that the first time I go to a folder with actual content (and no subfolders), I have to go out of the folder and go back in for it to actually show the list...I am thinking it's just taking a bit of time for display the list, not the actual going back out and in to get the list to show.


So, now that there seems to be a handle on how to obtain SeriesIDs, and someone has created a Mac program that can generate pretty much everything else, I wonder how long it will be before someone will be able to make some type of windows GUI that does the same thing?


----------



## grahamg (Aug 18, 2006)

schwingle said:


> I mostly pull tv shows through torrents and they come down as avi files. They are reasonably sized and beyond media plays them really well.


Our Tivo 2 single tuner is still a great box, but I can only drive our 50" Plasma via S-video, I did add a big Hard drive to the Tivo and now everything is done at best quality and it really looks pretty good at 10' or more from the screen. But when we play DVD's the difference in quality really shows itself.

On another post in this chain I made a question about the ffmpeg settings, I am curious what will happen if I use PyTivo to transfer some higher quality material. ie. I dont know whether it is the S-Video connection or the quality of the video stored that is limiting the picture quality of the Tivo.

Your post has got me on the idea of using the PC to record off the air HD content and to transfer it via PyTivo. Fortunately we are only 7 miles line of site from LA's main HD broadcasting site.


----------



## grahamg (Aug 18, 2006)

MasterCephus said:


> I upgraded my pyTivo to pyTivo-2007-11-25-subfolders-8.3-10bf9e4e15a51c6a758fabefb75f6502b7809e09 and everything seems to be fine. I transferred a movie and am watching it and it looks good.
> 
> I did notice that in the NPL the movie took the name of the folder name it was in and when I click on it, it shows the actual name of the movie under it on the next screen. I imagine that once I put in the txt files for the meta data that will fix that.
> 
> ...


I am still on Ver 208. I haven't tried any subfolder versions (didn't know what they were). I know I can try this myself, but do you mean that you can see subfolders on the PC? In my case I am very much in the "download - PyTivo transfer - view - delete mode". I guess my first wish list item would be to be able to delete the PC files from the Tivo. I dont see myself ever wanting to store and catalog videos, I would rather use a DVD, ( we often enjoy the bonus material as much as the main movie).

There are some quirks with V208 and maybe these have been fixed in later versions. I am refering to the problem of sometimes not being able to delete files in the NPL list, even ones that the Tivo has recorded. But I suspect this is mainly a Tivo problem and not the PyTivo server. Unless the PyTivo is giving some wrong file lengths and the Tivo is getting confused. This is not a big problem and I already consider the PyTivo far ahead of Tivo's desktop manager.


----------



## gonzotek (Sep 24, 2004)

dlfl said:


> There is a tivo web page that gives these specs but I just spent 5 mins trying to find it so ......


http://tivosupport2.instancy.com/LaunchContent.aspx?CID=4012D160-79C3-4238-96C8-A27B323D1413

I just use google and search for "tivo.com mpeg" anytime I need this link. They keep futzing with their support links and everytime they redo them, the old ones break (how hard would a re-direct be?).

NOTE: The page hasn't been updated to reflect S3/HD TTG/TTCB functionality. It is possible to transfer HD (and SD) content to them with the most recent service update. If you're an S3 or HD user reading this and looking for specs, ask in the forum, other S3/HD owners are experimenting with what works and what doesn't.


----------



## schwingle (Nov 7, 2007)

To Grahamg. I keep only tv shows on my media server. Some of the stuff I get is BBC stuff I can't get otherwise and I like rewatching stuff, but yeah, when it comes to movies, I prefer dvd's.


----------



## grahamg (Aug 18, 2006)

Hi, first of all a sincere thank you for taking the time to write this. I am a bit reluctant to ask too many questions. But I find the forum search tools not too great and it's not easy to try to find if previous posts have covered the same ground.



dlfl said:


> 544x480 Most Tivo models will take this and DISPLAY it at 4:3 (640x480) or 16:9 (853x480).


So if I un-comment this config section I may get a higher quality display on the Tivo? If you have any better suggestions let me know.

#If you want to use 16:9 or 4:3 on this tivo
#aspect169=true
#width=1440
#height=720
#audio_br=320K
#video_br=12Mi
#ffmpeg_prams=-i %(in_file)s -vcodec mpeg2video -r 29.97 -b %(video_br)s -maxrate %(max_video_br)s -bufsize %(buff_size)s %(aspect_ratio)s -comment pyTivo.py -ac 2 -ab %(audio_br)s -ar 44100 -f vob -


> The complete story is more complicated. My series 2 DT will record at
> 352x240, 352x480 and 480x480, with four different bit rates ranging up to 5800 kbps. Other models will vary.
> 
> Then each model has a set of resolutions that it will accept which can be different that what it records at (e.g., 544x480 in my case). In all cases the aspect ratio signalling in the file tells the display device what actual format to display at. There is a tivo web page that gives these specs but I just spent 5 mins trying to find it so ......


Thanks I will trawl the Tivo website and try to find the specs on my model 540



> For Series 2 the valid height is 480. For the HD models I think 720 or possibly even 1080 are valid heights. In the pyTivo world the program tries to have a set of valid heights and widths built into it and it decides whether to re-encode with ffmpeg or just transfer the file as is based on whether it fits one of these "valid" width/height combos. For a python programmer it is easy to view and modify these internal combinations in the code.


I can understand why the Tivo can record at a variable set of resolutions/bit rates - to allow the user to choose what he wants ie. quality vs disk space) But I don't get is how the Tivo can get up to 853x480 displayed resolution. I mean if this is the best it can do then presumably it would be the optimum one to choose for the PyTivo files. Not 1440x720 as the above green section. I don't get this right now, maybe I will later after re-reading.



> Sorry but it would take a small book to explain these topics fully and then it would probably have errors in it anyway! Scan the pyTivo wiki for some more discussion of aspect ratio and useful links on that topic.


Thank you again. I am really curious as to what is the limiting factor in getting the best picture on our 50" plasma from the Tivo. I know the real answer is to buy a Tivo3, but right now that's not an option. I think I will try Videora and produce two or three different quality clips taken off a DVD and then transfer them with PyTivo. I can look in the Windows Task manager to see if FFmpeg_mp2 is started, hopefully not as they both seem to use the same FFmpeg encoder. Anyway thats the plan!


----------



## dlfl (Jul 6, 2006)

I'm just guessing here because I don't have a HD TV
recommended settings to try:

aspect169=true
width=720
video_br = 8Mi
buff_size = 17Mi
max_video_br = 11Mi

You do understand that a line starting with '#' is commented out, I hope.
Let the other parameters (height, audio_br) go to their default values, i.e., don't put them in the file or comment them out.

If you do put height in and put it in a per-tivo section, be aware there is a bug in the latest versions. You would need to use height_br instead of height.

This should give you 720x480 video going to your TiVo which I believe is the largest format your model can accept. The 16:9 setting will cause this to be expanded to an effective 853x480 format when it sends it to your TV, assuming you have also set your TiVo for 16:9 (HDTV).

Just FYI, DVD's that are not HDTV (e.g. Blue Ray) are encoded at 720x480 whether they are intended for 16:9 or 4:3 displays. The AR signalling tells the DVD player to stretch/compress the width to either 640 or 853 on playback.

Good luck!


----------



## grahamg (Aug 18, 2006)

dlfl said:


> I'm just guessing here because I don't have a HD TV
> recommended settings to try:
> 
> aspect169=true
> ...


yes I get the comment symbol #

Thanks! I will let you know how I get on. But I am going away for 3 days from tomorrow night. I might try tonight. I have just noticed that the two ffmpeg command lines are slightly different. Now I am wondering what the -i %(in_file)s bit is for. Oh well, try both...

ffmpeg_prams=-vcodec ........
ffmpeg_prams=-i %(in_file)s -vcodec .........


----------



## dlfl (Jul 6, 2006)

grahamg said:


> yes I get the comment symbol #
> 
> Thanks! I will let you know how I get on. But I am going away for 3 days from tomorrow night. I might try tonight. I have just noticed that the two ffmpeg command lines are slightly different. Now I am wondering what the -i %(in_file)s bit is for. Oh well, try both...
> 
> ...


Comment out all ffmpeg_prams lines! The default ffmpeg_prams you then get is all you need.

The -i %(in_file)s is an error, so leave it out if you do use an ffmpeg_prams. I submitted a bug report to the wiki on this.

Unfortunately, the documentation on the config file is poor and probably causes 90% of newbie problems. The example file has problems.


----------



## grahamg (Aug 18, 2006)

dlfl said:


> Comment out all ffmpeg_prams lines! The default ffmpeg_prams you then get is all you need.
> 
> The -i %(in_file)s is an error, so leave it out if you do use an ffmpeg_prams. I submitted a bug report to the wiki on this.
> 
> Unfortunately, the documentation on the config file is poor and probably causes 90% of newbie problems. The example file has problems.


Do you really mean all ffmpeg_prams's? There are only two. The one around line 30 is uncommented, the one around line 48 with -i %(in_file)s in it was commented out.

Sorry, I think you mean just leave the uncommented line 30 one - the default one?


----------



## dlfl (Jul 6, 2006)

grahamg said:


> Do you really mean all ffmpeg_prams's? There are only two. The one around line 30 is uncommented, the one around line 48 with -i %(in_file)s in it was commented out.
> 
> Sorry, I think you mean just leave the uncommented line 30 one - the default one?


No I mean all -- there is an internal default. Probably if you remove the -i %(in_file)s it doesn't make any difference, i.e., then the one(s) in the config file will be identical to the internal default anyway.

Python code is just a text file editable by any text editor (except notepad which may not handle line endings correctly). Thus you can open up config.py in wordpad (or whatever) and at line 79 you find the function that sets up the ffmpeg parameters:


```
def getFFMPEGTemplate(tsn): 
     if tsn and config.has_section('_tivo_' + tsn): 
         try: 
             return config.get('_tivo_' + tsn, 'ffmpeg_prams', raw = True) 
         except NoOptionError: 
             pass 
  
     try: 
         return config.get('Server', 'ffmpeg_prams', raw = True) 
     except NoOptionError: #default 
         return '-vcodec mpeg2video -r 29.97 -b %(video_br)s -maxrate %(max_video_br)s -bufsize %(buff_size)s %(aspect_ratio)s -comment pyTivo.py -ac 2 -ab %(audio_br)s -ar 44100 -f vob -'
```
First it looks for ffmpeg_prams in the tivo-specific section. If not found it looks in the [Server] section. If not found it sets it to what you see in the code. I believe this is identical to the examples in the pyTivo.conf.dist provided you remove the -i %(in_file)s.

At this point you're not that far from making your own code mods! Python is very readable. You do have to remember that indentation is very important. It is used to accomplish grouping that is done by curly braces {} in most other languages.


----------



## grahamg (Aug 18, 2006)

dlfl said:


> No I mean all -- there is an internal default. Probably if you remove the -i %(in_file)s it doesn't make any difference, i.e., then the one(s) in the config file will be identical to the internal default anyway.
> 
> Python code is just a text file editable by any text editor (except notepad which may not handle line endings correctly). Thus you can open up config.py in wordpad (or whatever) and at line 79 you find the function that sets up the ffmpeg parameters:
> 
> ...


Hi Thanks, I am on the road but have time to look at files etc. I looked at my config.py and see that at around line 43, not 79 it contains the definitions. Notice that the code i %(in_file)s is still there in my config.py.


```
def getFFMPEGTemplate(tsn):
    if tsn and config.has_section('_tivo_' + tsn):
        try:
            return config.get('_tivo_' + tsn, 'ffmpeg_prams', raw = True)
        except NoOptionError:
            pass

    try:
        return config.get('Server', 'ffmpeg_prams', raw = True)
    except NoOptionError: #default
        return '-i %(in_file)s -vcodec mpeg2video -r 29.97 -b %(video_br)s -maxrate %(max_video_br)s -bufsize %(buff_size)s %(aspect_ratio)s -comment pyTivo.py -ac 2 -ab %(audio_br)s -ar 44100 -f vob -'
```
I need to find out more about Python because in the next fragment see the two very similar functions, one has the word "to" in it the other not - I wonder why?


```
def getMaxVideoBR():
    try:
        return config.get('Server', 'max_video_br')
    except NoOptionError: #default to 17M
        return '17M'

def getBuffSize():
    try:
        return config.get('Server', 'bufsize')
    except NoOptionError: #default 1024k
        return '1024k'
```
Then I see you used for instance "17Mi" and the file uses "17M", the buffer is 1024k or 1mb so will your line buff_size make it 17mb?

aspect169=true
width=720
video_br = 8Mi
buff_size = 17Mi
max_video_br = 11Mi

Anyway I will assume to delete the "-i %(in_file)s" in config.py, comment out all "ffmpeg_prams" in pytivo.conf and give your suggested values a go! I see pytivo.conf only contains about 6 lines of code, the rest are comments.

i will spend some time looking into Python, it looks interesting, I have just spent 1/2 hour doing a 1st lesson using IDLE (a long way to go!)


----------



## dlfl (Jul 6, 2006)

grahamg said:


> ........... Notice that the code i %(in_file)s is still there in my config.py.


This was an error, which I submitted to the Wiki as a ticket.



grahamg said:


> ........... in the next fragment see the two very similar functions, one has the word "to" in it the other not - I wonder why?


Just a slight grammatical difference in two comments.



grahamg said:


> Then I see you used for instance "17Mi" and the file uses "17M", the buffer is 1024k or 1mb so will your line buff_size make it 17mb?


In the relatively new IEC binary prefix standard, which ffmpeg applies to its parameters:
k = 1000, Ki=1024, M = 10^6, Mi = 2^20 = 1024*1024
Thus Mi is about 5% greater than M, not a significant difference for these parameters.

The default buffer size is 1024k but for high bit rate HD encoding, the 17M seems to be recommended. AFAIK, the higher value carries no penalty unless your pc is memory starved, and is a safety measure. Problems occur if the buffer is too small.


grahamg said:


> Anyway I will assume to delete the "-i %(in_file)s" in config.py, comment out all "ffmpeg_prams" in pytivo.conf and give your suggested values a go! .........i will spend some time looking into Python, it looks interesting, I have just spent 1/2 hour doing a 1st lesson using IDLE (a long way to go!)


Sounds good. Good luck!


----------



## grahamg (Aug 18, 2006)

Just a slight grammatical difference in two comments. 

I didn't catch the "#" now it is obvious!

k = 1000, Ki=1024, M = 10^6, Mi = 2^20 = 1024*1024

This now makes sense, I was thinking 17M and 17Mi were absolute values defined somewhere in the program.

The default buffer size is 1024k but for high bit rate HD encoding, the 17M 

Memory isn't an issue, maybe I can set it higher...

I am looking forward to trying the suggested setting when I get back home. Thanks for your advice. I hadn't heard of Python until a few days ago and I am quite impressed with the low memory footprint and performance.

I used to be pretty good at assembler and and many years ago wrote a C cross compiler for a Z80 CPM system when assembly code was the way to go. Had to keep things lean with 32kb of ram on my machine, later upgraded to 64kb. I still remember the first time I used a 8" floppy drive and was astounded at how quick the editor loaded. Those were the days!

Cheers!


----------

