PDA

View Full Version : Video transcoders- any ideas?



cowman
03-29-2012, 11:06 PM
Without typing a book.. I use a PVR system called Mythtv (http://Mythtv.org) on my linux server. The recording device is a Hauppauge HD-PVR recording via component input from a satellite receiver @ 720p.

The nice thing about MythTv is it uses a client/server model and can be viewed on any *nix or OSX system with either the mythtv client installed or support for upnp/dlna video playback(PS3s, other devices). Also with a plugin via a web browser I can direct download or stream to any machine on my LAN. Recently, I've obtained an appletv2 and jailbroken it, and got XBMC installed. XBMC nicely supports myth's playback system and commercial skipping features. Just one little issue...

The appletv2 doesn't have the hardware to handle the recordings I'm throwing it. Yeah it supports 720p but my recording device records at 68.76fps at about 3.6Mb/s bitrate... hardware encoded to h.264. I've had the same issue on just about any device that doesn't have either a higher end CPU or a GPU with hardware decoding features. :(

SO, the solution is transcode it down to a slightly easier to play format so all the devices I want to use work with it. I've been able to do this with handbrake with great success but that's a manual process- I want it to do this automatically. Myth sort of supports this- you can have it run a command/script after it finishes a recording, passing in parameters to transcode (also cut commercials out if you want but that's another project). The key is getting a command line utility to do it. The generally approved linux command line video utility is ffmpeg. After experimentation, I've found this produces a playable recording:

ffmpeg -i [input filename] -threads 4 -f mp4 -vcodec libx264 -maxrate 5500k -b 2750k -bufsize 4096k -acodec libfaac -ab 160k -async 1 -s 1280x720 -r 29.97 [output file]

This makes a playable recording that sounds good, has perfect audio sync, just as sharp of a picture... and sadly slightly choppy motion which bugs me because I'm a perfectionist for this shit. The key parameter is the -r, cutting the framerate back down seems to make for the choppiness. The videos I've trans coded with handbrake are 30fps and they look fine. Unfortunately ffmpeg has about a billion parameters and I'm not sure what to tweak to try to get this sorted out.

Oh, for the fun of it... here are the particulars that ffmpeg tells me about my input files..

Input #0, mpegts, from '1249_20111005210000.mpg':
Duration: 00:29:50.08, start: 2.477711, bitrate: 3648 kb/s
Program 1
Stream #0.0[0x1011]: Video: h264 (Main), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 68.76 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0.1[0x1100]: Audio: aac, 48000 Hz, stereo, s16, 120 kb/s


Anyway I think there are some people on here who play with video too..... any ideas?

unixdude
03-29-2012, 11:49 PM
Sorry, but I'm not going to be much help for your issue, but I am curious about your "Hauppauge HD-PVR". Is this supported by the a standard out-of-the-box kernel, or do you have to roll your own?

cowman
03-29-2012, 11:55 PM
There's a driver that is in the kernel on most distributions. I had to roll my own the last couple of times because the USB device ID hadn't been added to the driver so I had to download the source, add it in, compile&install the driver.

http://www.hauppauge.com/site/products/data_hdpvr.html device in question
http://www.mythtv.org/wiki/Hauppauge_HD-PVR some info on getting it going under linux.

TDSP
03-31-2012, 01:09 AM
I don't know how to do it on ffmpeg, but I know how to do it on TMPGenc.... I'm not finding a Linux port of it on Synaptic. Is your main box beefy enough to WINE it?

cowman
03-31-2012, 03:00 AM
It is, but doing video transcoding in an emulator isn't my first choice.

There's almos certainly a switch or parameter or something to make it work but ffmpeg is a pretty versitle(complex) tool and I don't have a clue what that would be....

cowman
04-01-2012, 11:20 PM
Aha!

Turns out there's a command line version of handbrake! I am still testing this but I put a really short script together that I think is going to do the trick.




#!/bin/sh
#Script to convert mythtv recordings to appletv 2 format

FILE=$1
TEMPFILE=/tmp/`date +%d%H%M%s`.mp4

moveFile()
{
mv $TEMPFILE $FILE
}

nice /usr/bin/HandBrakeCLI -i $FILE -o $TEMPFILE --preset="AppleTV 2"


if [ $? = 0 ]
then moveFile
fi



I found this guy converting for iphone/ipod touch and modified what he was doing for my own needs..
http://www.pcmediacenter.com.au/forum/topic/44458-mythtv-recordings-download-to-your-iphoneipod-via-wifi/