# pyTivo & Subtitles - possible solution



## mdbundy (Oct 5, 2005)

At the risk of posting yet another redundant message, I thought I'd share that I seem to have found a solution to displaying subtitles (.srt, .ssa, etc.) dynamically with pyTivo / Tivo.Net -- i.e., without re-encoding the video to "burn" the subtitles on (for Windows, at least).

The solution is pretty simple... It requires AviSynth with the FFmpegSource and VSFilter filters.

1. Create a text file with an .avs extension (i.e., "movie.avs"), with the following content (using the appropriate file names/paths)

LoadPlugin("c:\...\ffmpegsource.dll")
LoadPlugin("c:\...\vsfilter.dll")
FFMpegSource(source="c:\...\movie.avi")
TextSub("c:...\movie.srt")

2. Configure pyTivo / Tivo.Net to look for .avs files

That's it!

Note that I am using FFMpegSource, b/c it should work with any files that FFMpeg itself works with (MKV), but there are plenty of filters/plugins that AviSynth supports... 

I haven't figured out yet how to read subtitle streams from MKV files directly, but will update the thread if/when I do...


----------



## gonzotek (Sep 24, 2004)

mdbundy said:


> At the risk of posting yet another redundant message, I thought I'd share that I seem to have found a solution to displaying subtitles (.srt, .ssa, etc.) dynamically with pyTivo / Tivo.Net -- i.e., without re-encoding the video to "burn" the subtitles on (for Windows, at least).
> 
> The solution is pretty simple... It requires AviSynth with the FFmpegSource and VSFilter filters.
> 
> ...


This method 'burns' the subs onto the picture as it is sent out to the TiVo, correct? So a user could choose to transfer the .avi, which would send an un-subbed picture, or the .avs, which would have the subs?

I wonder if it would be possible to enable the same thing with the new streaming solutions...does VLC have avisynth hooks like ffmpeg?


----------



## mdbundy (Oct 5, 2005)

gonzotek said:


> This method 'burns' the subs onto the picture as it is sent out to the TiVo, correct? So a user could choose to transfer the .avi, which would send an un-subbed picture, or the .avs, which would have the subs?


Correct. I actually name my .avs "Movie - Subbed.avs" so that I can distinguish from the NPL.

One more note -- I didn't notice the first time, but using FFMPegSource creates cache files, which takes a long time. I think you can prevent the (large) audio cache file from being created if you pull the audio from the source rather than AviSynth, but that would require a second ffmpeg configuration in pyTivo.

As an alternative, I'm installing a newer codec pack (I think it's called CCCP) to see if DirectShowSource will work with my source content.


----------



## wmcbrine (Aug 2, 2003)

gonzotek said:


> I wonder if it would be possible to enable the same thing with the new streaming solutions...does VLC have avisynth hooks like ffmpeg?


VLC handles subtitles itself. I haven't explored that, though.


----------



## mdbundy (Oct 5, 2005)

As suggested, I installed the "Combined Community Codec Pack" and have had better results (no pre-caching required) when using DirectShowSource rather than FFMpegSource. It's working with the few MKV files I tried as well, though there doesn't appear to be a way to extract subtitles from MKV on the fly (might have to try building an AviSynth plugin).

Updated script is as follows:

LoadPlugin("c:\...\vsfilter.dll")
DirectShowSource("c:\...\movie.mkv")
TextSub("c:\...\movie.srt")

Note that I'm getting a slight audio delay which I don't seem to get when playing the mkv directly in media player; forcing a framerate appears to fix the problem:

DirectShowSource("c:\...\movie.mkv",fps=25,convertfps=true)


----------



## pmack (Jan 10, 2007)

Can someone point me in a direction where I might find a solution to the problem I encountered using this method?

I tried this using directshow. The first time I tried it, pytivo transferred an error message:

"DirectshowSource could not open as video or audio. DirectDhowSource couldn't open file x.avi. An invalid media type was specified."

Later I got "No combination of filters could be found to render the stream"

The file is an xvid avi, and can be transferred (sans subtitles) without a problem.

My script file:

LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\vsfilter.dll")
DirectShowSource("x.avi")
TextSub("x.srt")

I thought the problem was that I used relative paths for the movie and subtitles, so I changed it to actual paths. Now pytivo reports that the recording can't be transferred due to copyright restrictions.

Updated script file:

LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\vsfilter.dll")
DirectShowSource("e:\Other_Video\x.avi")
TextSub("e:\Other_Video\x.srt")

I am using wgw 2008.10.15 RC1

Any suggestions? 

Thanks in advance.


----------



## mikel_b (Mar 14, 2009)

I am trying to get this working and I think I am getting the same error as you.

I created a .avs file with:

LoadPlugin("C:\Program Files\Combined Community Codec Pack\Filters\vsfilter.dll")
DirectShowSource("...\S01E02 - 46 Long.avi")
TextSub("...\Sopranos - 1x02.EN.srt")

The paths are correct.

I added .avs to video.ext

The log has:
2009-03-13 23:24:15,960 DEBUG pyTivo.video.transcode: failed at vCodec
2009-03-13 23:24:15,960 DEBUG pyTivo.video.transcode: failed at vWidth/vHeight
2009-03-13 23:24:15,970 DEBUG pyTivo.video.transcode: failed at vFps
2009-03-13 23:24:15,980 DEBUG pyTivo.video.transcode: failed at kbps
2009-03-13 23:24:15,980 DEBUG pyTivo.video.transcode: failed at aKbps
2009-03-13 23:24:15,990 DEBUG pyTivo.video.transcode: failed at aCodec
2009-03-13 23:24:15,990 DEBUG pyTivo.video.transcode: failed at aFreq
2009-03-13 23:24:16,000 DEBUG pyTivo.video.transcode: failed at mapVideo
2009-03-13 23:24:16,000 DEBUG pyTivo.video.transcode: failed at mapAudio
2009-03-13 23:24:16,009 DEBUG pyTivo.video.transcode: aFreq=None; vFps=; kbps=None; mapAudio=[('', '')]; vWidth=; vCodec=; Supported=False; millisecs=0; aKbps=None; par2=None; par1=None; dar2=None; mapVideo=None; vHeight=; dar1=None; aCodec=None
2009-03-13 23:24:16,009 DEBUG pyTivo.video.transcode: FALSE, file not supported ...\Subtitled\S01E02 - 46 Long.avs
2009-03-13 23:24:19,694 DEBUG pyTivo.hack83: =========================================================================
2009-03-13 23:24:19,694 DEBUG pyTivo.hack83: new request ------------------------
2009-03-13 23:24:19,694 DEBUG pyTivo.hack83: TiVo request is: 
{'Container': ['My Videos/The Sopranos/Subtitled'], 'AnchorOffset': ['-1'], 'Filter': ['x-tivo-container/tivo-videos,x-tivo-container/folder,video/x-tivo-mpeg,video/*'], 'Command': ['QueryContainer'], 'SortOrder': ['!CaptureDate'], 'AnchorItem': ['/My%20Videos/The%20Sopranos/Subtitled/S01E02%20-%2046%20Long.avs'], 'ItemCount': ['1']}
2009-03-13 23:24:19,704 DEBUG pyTivo.hack83: queryAnchor:My Videos/The Sopranos/Subtitled/S01E02 - 46 Long.avs 
leftAnchor:My Videos/The Sopranos/Subtitled
rightAnchor: S01E02 - 46 Long.avs
2009-03-13 23:24:19,704 DEBUG pyTivo.hack83: our saved request is: 
{'Filter': ['x-tivo-container/tivo-videos,x-tivo-container/folder,video/x-tivo-mpeg,video/*'], 'Container': ['My Videos/The Sopranos/Subtitled'], 'ItemCount': ['8'], 'Command': ['QueryContainer'], 'SortOrder': ['!CaptureDate']}
2009-03-13 23:24:19,704 DEBUG pyTivo.hack83: requested a file
2009-03-13 23:24:19,704 DEBUG pyTivo.hack83: Tivo said: My Videos/The Sopranos/Subtitled || Hack said: My Videos/The Sopranos/Subtitled
2009-03-13 23:24:20,305 DEBUG root: CACHE HIT! ...\Subtitled\S01E02 - 46 Long.avs
2009-03-13 23:24:20,315 DEBUG pyTivo.video.transcode: FALSE, file not supported ...\Subtitled\S01E02 - 46 Long.avs
2009-03-13 23:24:20,526 DEBUG root: ffmpeg output=FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al.

configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilter-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --enable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enable-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --cpu=i686 --extra-ldflags=-static

libavutil version: 49.6.0

libavcodec version: 51.54.0

libavformat version: 52.13.0

libavdevice version: 52.0.0

built on Apr 2 2008 22:35:11, gcc: 4.2.3

[avs @ 00AA6C70]AVIFileOpen failed with error -2147221164.../Subtitled/S01E02 - 46 Long.avs: Error while opening file

2009-03-13 23:24:20,536 DEBUG pyTivo.video.transcode: failed at vCodec
2009-03-13 23:24:20,536 DEBUG pyTivo.video.transcode: failed at vWidth/vHeight
2009-03-13 23:24:20,546 DEBUG pyTivo.video.transcode: failed at vFps
2009-03-13 23:24:20,565 DEBUG pyTivo.video.transcode: failed at kbps
2009-03-13 23:24:20,565 DEBUG pyTivo.video.transcode: failed at aKbps
2009-03-13 23:24:20,565 DEBUG pyTivo.video.transcode: failed at aCodec
2009-03-13 23:24:20,575 DEBUG pyTivo.video.transcode: failed at aFreq
2009-03-13 23:24:20,575 DEBUG pyTivo.video.transcode: failed at mapVideo
2009-03-13 23:24:20,575 DEBUG pyTivo.video.transcode: failed at mapAudio
2009-03-13 23:24:20,585 DEBUG pyTivo.video.transcode: aFreq=None; vFps=; kbps=None; mapAudio=[('', '')]; vWidth=; vCodec=; Supported=False; millisecs=0; aKbps=None; par2=None; par1=None; dar2=None; mapVideo=None; vHeight=; dar1=None; aCodec=None
2009-03-13 23:24:20,585 DEBUG pyTivo.video.transcode: FALSE, file not supported .../Subtitled/S01E02 - 46 Long.avs
2009-03-13 23:26:33,096 INFO pyTivo.hack83: Hack83 is enabled.
2009-03-13 23:26:33,127 INFO pyTivo: pyTivo is ready.

Any clues?

Thanks!


----------



## Iluvatar (Jul 22, 2006)

Can you get those ffmpeg commands to work with your avs file without using pytivo first? Just to see if it is pytivo or ffmpeg.


----------



## rambler (Dec 3, 2005)

I just use pocketdivx to make an avi with subtitles burned on it, then transfer with pytivo.


----------



## txporter (Sep 18, 2006)

rambler said:


> I just use pocketdivx to make an avi with subtitles burned on it, then transfer with pytivo.


I do this now as well, but with .mp4 (h.264) files using Handbrake or XVID4PSP. I can then _push _the mp4 files with pytivo to my TivoHD without needing to transcode.

Jason


----------



## mikel_b (Mar 14, 2009)

Iluvatar said:


> Can you get those ffmpeg commands to work with your avs file without using pytivo first? Just to see if it is pytivo or ffmpeg.


Sorry, I'm new to this whole thing, so I'm not sure how to do that. Do I just call ffmpeg and use those options as command line switches somehow or is there a way to make it read the .avs file?

Thanks


----------



## ebf (Mar 21, 2005)

Hey Mikel_b, not sure if you gave up on this, but I got it working after reading this thread at the pyTiVo forum.


----------

