Log in

View Full Version : suggestions for TiVo HD->x264 encoding


jdratlif
26th August 2010, 23:11
I'm trying to reencode videos from my TiVo to reduce filesize using h.264 video and ogg/vorbis audio. I would also like to cut the commercials out.

I've been using comskip to find the commercials. It creates edl files, which can be used with mplayer or mencoder.

I would like to use x264 and oggenc with audio/video piped from mplayer (to take advantage of scaling, deinterlacing, edl list). So I've been trying this:

mkfifo audio_fifo.wav video_fifo.y4m
oggenc -q 4 audio_fifo.wav -o audio.ogg &
x264 --crf 25 --threads auto video_fifo.y4m -o video.264 &
mplayer hd1080i_ntsc.mpg -ao pcm:file=audio_fifo.wav -vo yuv4mpeg:file=video_fifo.y4m -edl commercials.edl -vf pp=lb,scale=960:540
MP4Box -fps 29.97 -add video.264 -add audio.ogg hd1080i_ntsc.mp4

I got the idea from http://sites.google.com/site/linuxencoding/x264-encoding-guide

But the audio/video isn't quite in sync. It's just a little off.

I don't know what options to pass to mencoder to use it. Maybe someone could tell me what to fill in the x264encopts for the x264 High Profile Level 3.1 from the most recent x264. If I just used crf=25:threads=auto, would that work? Is it the same or am I leaving out things?

I'm open to other suggestions as well. I was thinking I could use mencoder to cut the video, and then something else to encode it.

I tried to use ffmpeg without cutting the commercials, but it gave me a broken file. It worked for the first 35 minutes, but was unplayable after that. I wasn't sure if it was because the video dimensions changed (comcast digital cable seems to do that a lot during the commercials) or if there was another reason.

jdratlif
8th September 2010, 01:52
I found a program called h264enc which is a huge interactive bash script that runs with mencoder, so I took some cues from it and wrote my own script.

The A/V sync is sometimes a little off for a second or two after the commercial cuts, but the problem doesn't persist.

Here is the script (http://code.technoplaza.net/tivo/tivo-encode.sh). It's GPL2 if anyone wants to use it. I've used it to encode a dozen HD movies and at least 20 HD TV shows, which have all worked pretty well.

The t2extract.sh script can be found at http://code.google.com/p/kmttg/wiki/linux_installation. It's just a wrapper for wine to run t2extract.exe, which pulls closed captions into an SRT subtitle format file. ccextractor doesn't seem to work very reliably with TiVo files.

I'm not sure why, but muxing the srt file into the matroska container produces broken files. mplayer plays them fine, but smplayer doesn't (weird). An annoying situation, but not sure how to fix it right now.

The script supports all three TiVo video formats (480i, 720p, and 1080i). If there is a matching EDL file, it will use it to make cuts. It extracts closed captions to an SRT file using t2extract with Wine.