Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
muirhejs
Visitor

Tivo + Kmttg w/ biftool

Just in case anyone else is looking to use their Tivo shows with RoksBox, MyMedia, or similar. I've had great success with kmttg, but the one thing that was troubling me a bit was that when fast forwarding / rewinding, I didn't get any previews of where in the show it was. So I've put together a really simple Windows batch file to be used with kmttg's "custom command" option, i.e. "C:\Users\Home\Tivo\bifcreate.cmd [encodeFile]" in my case...

Here it is for anyone interested. Be warned that the sync between the video and the preview images is not great, but likely passable if you're not too picky!


@echo off
set BIFTOOL="C:\Users\Home\Tivo\roku\biftool.exe"
set FFMPEG="C:\Users\Home\Tivo\ffmpeg\ffmpeg.exe"
set TIVODATA="C:\Users\Home\Tivo\Data"
set TIVOFILE=%1

cd %TIVODATA%

for %%i in (%TIVOFILE%) do set NEWFOLDER="%%~ni"
echo Processing %TIVOFILE% into %NEWFOLDER%...

mkdir %NEWFOLDER%
echo %FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%010.jpg
%FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%08d.jpg
cd %NEWFOLDER%
cd ..
%BIFTOOL% -t 10000 %NEWFOLDER%
del %TIVODATA%\%NEWFOLDER%\*.jpg
rmdir %NEWFOLDER%


- John
0 Kudos
6 REPLIES 6
renojim
Community Streaming Expert

Re: Tivo + Kmttg w/ biftool

The reason the sync isn't so great is probably because ffmpeg seems to duplicate the first two frames. You need to delete one of them and then renumber/rename the rest.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
muirhejs
Visitor

Re: Tivo + Kmttg w/ biftool

Thanks JT.

Yuck.... because simply deleting the first .jpg that ffmpeg doesn't seem to work with biftool. Limited by Windows, this means we have a major hack job since natively there is no easy way I can think of to do the rename. We'll bring in Python to help, stealing some very simple code I googled for:


import glob
import string
import os

#get all the jpg file names in the current folder
files = glob.glob("*.jpg")
#sort the list
files.sort()
count = -1
# and rename each file
for f in files:
count = count + 1
n = string.zfill(count,4) + ".jpg"
print f, n,
try:
os.rename(f, n)
print
except:
print "error: didn't rename"


Now we can just delete the "00000001.jpg" file that ffmpeg creates and invoke our renamer script to handle the rest. This seems to produce some good results!!!

Updated 'bifcreate.cmd' file:

@echo off
cls
set BIFTOOL="C:\Users\Home\Tivo\roku\biftool.exe"
set FFMPEG="C:\Users\Home\Tivo\ffmpeg\ffmpeg.exe"
set JPGRENAMER="C:\Users\Home\Tivo\jpgrenamer.py"
set TIVODATA="C:\Users\Home\Tivo\Data"
set TIVOFILE=%1

cd %TIVODATA%

for %%i in (%TIVOFILE%) do set NEWFOLDER="%%~ni"
echo Processing %TIVOFILE% into %NEWFOLDER%...

mkdir %NEWFOLDER%
echo %FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%010.jpg
%FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%08d.jpg
cd %NEWFOLDER%
del 00000001.jpg
%JPGRENAMER%
cd ..
%BIFTOOL% -t 10000 %NEWFOLDER%
del %TIVODATA%\%NEWFOLDER%\*.jpg
rmdir %NEWFOLDER%


- John
0 Kudos
gonzotek
Visitor

Re: Tivo + Kmttg w/ biftool

"muirhejs" wrote:
Just in case anyone else is looking to use their Tivo shows with RoksBox, MyMedia, or similar. I've had great success with kmttg, but the one thing that was troubling me a bit was that when fast forwarding / rewinding, I didn't get any previews of where in the show it was. So I've put together a really simple Windows batch file to be used with kmttg's "custom command" option, i.e. "C:\Users\Home\Tivo\bifcreate.cmd [encodeFile]" in my case...

Here it is for anyone interested. Be warned that the sync between the video and the preview images is not great, but likely passable if you're not too picky!


@echo off
set BIFTOOL="C:\Users\Home\Tivo\roku\biftool.exe"
set FFMPEG="C:\Users\Home\Tivo\ffmpeg\ffmpeg.exe"
set TIVODATA="C:\Users\Home\Tivo\Data"
set TIVOFILE=%1

cd %TIVODATA%

for %%i in (%TIVOFILE%) do set NEWFOLDER="%%~ni"
echo Processing %TIVOFILE% into %NEWFOLDER%...

mkdir %NEWFOLDER%
echo %FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%010.jpg
%FFMPEG% -i %TIVOFILE% -r .1 -s 320x240 %NEWFOLDER%\%%08d.jpg
cd %NEWFOLDER%
cd ..
%BIFTOOL% -t 10000 %NEWFOLDER%
del %TIVODATA%\%NEWFOLDER%\*.jpg
rmdir %NEWFOLDER%


- John
What are you using for the encoding parameters? I ended up with a/v sync drift the last time I used kmttg (and ffmpeg by itself) to do the encoding. Also, what's your ffmpeg version(any special build tweaks?)? I'd love to use kmttg for prepping files for roku!
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
muirhejs
Visitor

Re: Tivo + Kmttg w/ biftool

I've been tweaking the encoding settings via handbrake/kmttg profiles a very small bit, with many thanks to the previous work of shelleye and txporter link 1 link 2. I've been discussing a bit with shelleye why my I get rebuffering a bit, and we think it's likely to be due to the fact that I'm trying to stream wirelessly. I'm currently using the "hb_roku_720_Detelecine.enc" profile and have reduced the bitrate to 2000.. so far no noticeable difference in quality and we'll see whether or not the rebuffering keeps happening.

So here's my current (work-in-progress) handbrake profile:

# Description (single line, keep short)
<description>
Handbrake tivo hd: mp4 container, h.264 video, aac audio, br2500

# Encode command or script (single line)
# Known keywords: FFMPEG, MENCODER, HANDBRAKE, PERL, INPUT, OUTPUT, PWD, CPU_CORES, SRTFILE
<command>
HANDBRAKE -i INPUT --cpu CPU_CORES -f mp4 --large-file --decomb --detelecine -O --encoder x264 -w 960 -b 1500 -r 29.97 -a 1 --aencoder faac --ab 160 --mixdown dpl12 --arate 48 --drc 0.0 --x264opts ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v -o OUTPUT

# Encoded output file extension
<extension>
m4v
0 Kudos
muirhejs
Visitor

Re: Tivo + Kmttg w/ biftool

Regarding my ffmpeg settings, I'm using the standard version that comes with kmttg. I've not noticed any issues with A/V drift.

FFmpeg version SVN-r21085, Copyright (c) 2000-2010 Fabrice Bellard, et al.  built on Jan  8 2010 06:05:02 with gcc 4.2.4
configuration: --enable-memalign-hack --prefix=/mingw --cross-prefix=i686-mingw32- --cc=ccache-i686-mingw32-gcc --target-os=mingw32 --arch=i686 --cpu=i686 --enable-avisynth --enable-gpl --enable-version3 --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaad --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg --enable-libxvid
--enable-libschroedinger --enable-libx264 --enable-libopencore_amrwb --enable-libopencore_amrnb
libavutil 50. 7. 0 / 50. 7. 0
libavcodec 52.45. 0 / 52.45. 0
libavformat 52.46. 0 / 52.46. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0. 8. 0 / 0. 8. 0


I did upgrade Handbrake from 0.9.4 to 0.95:
C:\Users\Home\Tivo\handbrake>HandBrakeCLI.exe -u
[11:22:20] hb_init: checking for updates
[11:22:20] Using http://handbrake.fr/appcast.xml
[11:22:20] latest: 0.9.5, build 2011010300
[11:22:21] hb_init: checking cpu count
[11:22:21] hb_init: starting libhb thread
HandBrake 0.9.5 (2011010300) - MinGW i386 - http://handbrake.fr
Your version of HandBrake is up to date.
0 Kudos
muirhejs
Visitor

Re: Tivo + Kmttg w/ biftool

Updated the batch file and getting close to being happy with it... it's starting to work pretty well now with Roksbox. The update looks at the show name assuming the format "show name - episode name" and after it's done it's magic, will move all the episode files into a subdirectory named 'show name' (if one exists). Definitely helps with organization.


@echo off
:: bifcreate.cmd v0.1
:: Given an .m4v file, use ffmpeg and biftool to
:: create a bif file for the video, and organize the
:: output if desired
:: Requires python for 'jpgrenamer.py' because I'm lazy

:: Set main directories & files here
set BIFTOOL="C:\Users\Home\Tivo\roku\biftool.exe"
set FFMPEG="C:\Users\Home\Tivo\ffmpeg\ffmpeg.exe"
set JPGRENAMER="C:\Users\Home\Tivo\jpgrenamer.py"
set TIVODATA=C:\Users\Home\Tivo\Data
set TIVOFILE=%1

cd "%TIVODATA%"

:: Extract temporary folder name we'll use
for %%i in (%TIVOFILE%) do set NEWFOLDER=%%~ni

:: Extract the series name so we can place the output into an
:: appropriately named subfolder if necessary
for /f "tokens=1 delims=-" %%a in (%TIVOFILE%) do set SHOWNAME=%%a

:: Extract the name of the BIF file to check and see if it's already been created
for %%i in (%TIVOFILE%) do set BIFFILE=%%~ni.bif
if exist "%BIFFILE%" goto EXIT

echo Processing %TIVOFILE% into %NEWFOLDER%...

mkdir "%TIVODATA%\temp\%NEWFOLDER%"
:: Extract a JPG every 10 seconds and place it in the temp folder we created
%FFMPEG% -v 0 -i %TIVOFILE% -r .1 -s 320x240 "%TIVODATA%\temp\%NEWFOLDER%\%%08d.jpg"

cd "%TIVODATA%\temp\%NEWFOLDER%"

:: FFMPEG duplicates the first file
del 00000001.jpg

:: Now we have to rename all the files to properly align them for BIFTool
%JPGRENAMER%
cd "%TIVODATA%"

:: Run Biftool
%BIFTOOL% -t 10000 "%TIVODATA%\temp\%NEWFOLDER%"

:: Cleanup
del "%TIVODATA%\temp\%NEWFOLDER%\*.jpg"
rmdir "%TIVODATA%\temp\%NEWFOLDER%"

:: Put the episode in a folder for the series if one exists
if exist "%SHOWNAME%" move "%TIVODATA%\%NEWFOLDER%*" "%SHOWNAME%"

:EXIT
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.