Skip to content

Commit

Permalink
Add conf parameters for all ffmpeg template settings
Browse files Browse the repository at this point in the history
  • Loading branch information
wgw committed Mar 9, 2008
1 parent d701b66 commit e40c8f2
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 68 deletions.
87 changes: 83 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,29 @@ def getOptres():
def get(section, key):
return config.get(section, key)

def getFFMPEGTemplate(tsn):
def getFFmpegTemplate(tsn):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'ffmpeg_prams', raw=True)
return config.get('_tivo_' + tsn, 'ffmpeg_tmpl', raw=True)
except NoOptionError:
pass
try:
return config.get('Server', 'ffmpeg_prams', raw=True)
return config.get('Server', 'ffmpeg_tmpl', raw=True)
except NoOptionError: #default
return '-vcodec mpeg2video %(video_fps)s -b %(video_br)s -maxrate %(max_video_br)s -bufsize %(buff_size)s %(aspect_ratio)s -comment pyTivo.py -ab %(audio_br)s %(audio_fr)s %(audio_codec)s -f vob -'
return '%(video_codec)s %(video_fps)s %(video_br)s %(max_video_br)s \
%(buff_size)s %(aspect_ratio)s -comment pyTivo.py %(audio_br)s \
%(audio_fr)s %(audio_ch)s %(audio_codec)s %(ffmpeg_pram)s %(format)s'

def getFFmpegPrams(tsn):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'ffmpeg_pram', raw=True)
except NoOptionError:
pass
try:
return config.get('Server', 'ffmpeg_pram', raw=True)
except NoOptionError:
return None

def isHDtivo(tsn): # tsn's of High Definition Tivo's
return tsn != '' and tsn[:3] in ['648', '652']
Expand Down Expand Up @@ -237,6 +250,72 @@ def getMaxAudioBR(tsn = None):
except NoOptionError:
return int(448) #default to 448

def getAudioCodec(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'audio_codec')
except NoOptionError:
pass
try:
return config.get('Server', 'audio_codec')
except NoOptionError:
return None

def getAudioCH(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'audio_ch')
except NoOptionError:
pass
try:
return config.get('Server', 'audio_ch')
except NoOptionError:
return None

def getAudioFR(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'audio_fr')
except NoOptionError:
pass
try:
return config.get('Server', 'audio_fr')
except NoOptionError:
return None

def getVideoFPS(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'video_fps')
except NoOptionError:
pass
try:
return config.get('Server', 'video_fps')
except NoOptionError:
return None

def getVideoCodec(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'video_codec')
except NoOptionError:
pass
try:
return config.get('Server', 'video_codec')
except NoOptionError:
return None

def getFormat(tsn = None):
if tsn and config.has_section('_tivo_' + tsn):
try:
return config.get('_tivo_' + tsn, 'force_format')
except NoOptionError:
pass
try:
return config.get('Server', 'force_format')
except NoOptionError:
return None

def str2tuple(s):
items = s.split(',')
L = [x.strip() for x in items]
Expand Down
9 changes: 6 additions & 3 deletions plugins/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ def Admin(self, handler, query):
t.container = cname
t.server_data = dict(config.items('Server', raw=True))
t.server_known = ["port", "guid", "ffmpeg", "beacon", "hack83", "debug", \
"optres", "audio_br", "video_br", "max_video_br", "width",\
"height", "ffmpeg_prams", "bufsize", "precache"]
"precache", "optres", "video_fps", "video_br", "max_video_br", \
"bufsize", "width", "height", "audio_br", "max_audio_br", \
"audio_fr", "audio_ch", "audio_codec", "ffmpeg_pram"]
t.shares_data = shares_data
t.shares_known = ["type", "path", "auto_subshares"]
t.tivos_data = [ (section, dict(config.items(section, raw=True))) for section in config.sections() \
if section.startswith('_tivo_')]
t.tivos_known = ["aspect169", "audio_br", "video_br", "width", "height", "ffmpeg_prams", "shares"]
t.tivos_known = ["aspect169", "audio_br", "video_br", "video_fps", "width",\
"height", "audio_br", "max_audio_br", "audio_fr", "audio_ch",\
"audio_codec", "ffmpeg_pram", "shares"]
handler.wfile.write(t)

def UpdateSettings(self, handler, query):
Expand Down
150 changes: 124 additions & 26 deletions plugins/admin/templates/settings.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ settings in the conf file as a maximum. If the video to be transcoded
has smaller dimensions that are closer to other acceptable TiVo
dimensions then pyTivo will use these dimensions. This allows for
faster transcoding and small files when the initial video is a lower
quality.<br>
quality. pyTivo uses the same resolution as the source file on
HD Tivos for optimal transcoding efficiency. It is not necessay to
to set this option with HD TiVos unles you wish to force pyTivo to change
the resolution to an "S2 compatible" resolution.<br>

<strong>Example Settings:</strong> True/False </p>

Expand All @@ -577,7 +580,8 @@ quality.<br>
<p align="center"><strong>audio_br</strong>
</p>

<p> <strong>Default Setting:</strong> 192K<br>
<p> <strong>Default Setting:</strong> 192K for SD TiVo's,
384K for HD TiVo's<br>

<strong>Valid Entries:</strong> Any valid Bit rate.
Up to 384K for SD TiVos. Up to 448K for HD TiVos.<br>
Expand All @@ -587,7 +591,7 @@ Up to 384K for SD TiVos. Up to 448K for HD TiVos.<br>
<strong>Skill:</strong> Advanced<br>

<strong>Description:</strong> This allows you to
choose the default server audio bit rate used in transcoding. The
choose the default audio bit rate used in transcoding. The
default is likely fine for most users. Users with HD units and high
quality videos to transcode will want to use higher value. Higher
values may slow down transcoding and will increase the file size.
Expand Down Expand Up @@ -727,37 +731,48 @@ longer to transfer over the network.<br>

</div>

<div id="help-ffmpeg_prams" style="position: absolute; overflow: scroll; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>ffmpeg_prams</strong>
<div id="help-ffmpeg_pram" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>ffmpeg_pram</strong>
</p>

<p> <strong>Default Setting:</strong> -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 -<br>
<p> <strong>Default Setting: </strong> blank<br>

<strong>Valid Entries:</strong> A valid ffmpeg command<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Very Advanced<br>

<strong>Description:</strong> This allows you to
control the parameters passed to ffmpeg. Most users will be just fine
with the default setting. Some HD users are experimenting with the
following line:<br>

-vcodec mpeg2video -maxrate %(max_video_br)s -qscale 1.2 -bufsize
%(buff_size)s -comment pyTivo.py -acodec ac3 -ab %(audio_br)s -ar 48000
-f vob -<br>

The major difference is that this does not alter the dimensions of the
video. The native height and width setting of the video used to
transcode the video. This will only work for HD and S3 units. So far
there has not been any report of dimensions which the HD units will not
accept. Additionally this line increases the audio frequency setting to
48000 too. <strong>Example Settings:</strong> See Above
and the forum. </p>
<strong>Description:</strong> This allows you to append
additional raw ffmpeg commands to the ffmpeg template. For example,
you would enter '-threads 2' here if you have multiple processors
and want ffmpeg to use both processors to speed up transcoding.<br>

<strong>Example Settings:</strong> -threads 2</p>

</div>

<div id="help-ffmpeg_tmpl" style="position: absolute; overflow: scroll; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>ffmpeg_tmpl</strong>
</p>

<p> <strong>Default Setting:</strong> "%(video_codec)s %(video_fps)s
%(video_br)s %(max_video_br)s %(buff_size)s %(aspect_ratio)s -comment
pyTivo.py %(audio_br)s %(audio_fr)s %(audio_ch)s %(audio_codec)s
%(fmpeg_pram)s %(format)s<br>

<strong>Valid Entries:</strong> A valid ffmpeg command<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Very Advanced<br>

<strong>Description:</strong> This is a template used by pyTivo
to control the parameters passed to ffmpeg. It should
not be necessary to modify this template unless there is a particular
parameter you do not wish ffmpeg to use and it cannot be overridden
by specifying that parameter in the pyTivo.conf file.<br>
<strong>Example Settings:</strong> See Above and the forum. </p>

</div>

Expand Down Expand Up @@ -908,10 +923,93 @@ longer needed.<br>
<strong>Description:</strong> Most TiVos, even S2,
can handle 16:9 videos perfectly. Some S2s are known not to handle 16:9
and will default to false in this setting. If you are experiencing
major distortion you can try setting this to false. Likely mos users
major distortion you can try setting this to false. Likely most users
will not have to mess with this.<br>

<strong>Example Settings:</strong> True/False </p>
</div>

<div id="help-video_fps" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>video_fps</strong>
</p>

<p> <strong>Default Setting:</strong> 29.97 for S2 Tivo, blank for S3/HD TiVo<br>

<strong>Valid Entries:</strong> 29.97, 23.98, 25, 59.94<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Advanced<br>

<strong>Description:</strong> Sets the frame rate used by ffmpeg.
pyTivo uses 29.97 for S2's, and uses the same frame rate as the source
on HD TiVos. The default setting should work fine for most transfers.<br>

<strong>Example Settings:</strong> 29.97, 23.98, 25, 59.94 </p>

</div>

<div id="help-audio_fr" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>audio_fr</strong>
</p>

<p> <strong>Default Setting:</strong> 48000<br>

<strong>Valid Entries:</strong> 44100, 48000<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Advanced<br>

<strong>Description:</strong> Sets the audio sampling frequency.
Defaults to frequency of the source file for better audio sync if
it is 44100 or 48000. Otherwise 48000 is used.<br>

<strong>Example Settings:</strong> 44100, 48000 </p>

</div>

<div id="help-audio_ch" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>audio_ch</strong>
</p>

<p> <strong>Default Setting:</strong> 2 for S2 TiVo, blank for S3/HD TiVo<br>

<strong>Valid Entries:</strong> any number compatible with ffmpeg and the audio codec selected<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Advanced<br>

<strong>Description:</strong> Sets the number of audio channels
used by ffmpeg. The default setting should work fine for most transfers
unless the default audio_codec is changed.<br>

<strong>Example Settings:</strong> 2, 6 </p>

</div>

<div id="help-audio_codec" style="position: absolute; left: 0px; top: 0px; visibility: hidden;">
<p align="center"><strong>audio_codec</strong>
</p>

<p> <strong>Default Setting:</strong> mp2 for S2 TiVo, ac3 for S3/HD TiVo<br>

<strong>Valid Entries:</strong> mp2, ac3<br>

<strong>Required:</strong> No<br>

<strong>Skill:</strong> Advanced<br>

<strong>Description:</strong> Sets the audio codec used by ffmpeg.
pyTivo checks the audio codec and bitrate of the source and uses
-acodec copy if it is compatible. Otherwise the Default Setting is
used. Allowing pyTivo to select -acodec copy whenever possible
will generally produce the best results. This will also prevent the
center audio channel from being moved to the right front speaker
by ffmpeg when transferring some mkv's and xvid's.<br>

<strong>Example Settings:</strong> mp2, ac3 </p>

</div>

Expand Down
Loading

0 comments on commit e40c8f2

Please sign in to comment.