Page 1 of 2

MythTV, Handbrake and Android conversions

Posted: Sat Mar 06, 2010 12:56 pm
by axe
Hi again all.

A while back I heard on the podcast, Pat say Linc (I think it was) had a handbrake CLI command that would convert Mythtv MPEG2s into files the Android could watch. I used to have Handbrake 0.93 working fantastic doing these conversions, until v.93 didn't work on Ubuntu 9.10...

I found a preset for the GUI Handbrake 0.94 and ubuntu 9.10, but I'd love to get back to using the CLI app since I have a conversion script written and I tend to convert several MPG at a time.

Can the command line be posted here please?
thanx much
AXE

--
BTW the CLI 0.93 command I used is here:
HandBrakeCLI -i "$1" -t 1 -c 1-25 -o "$2.mp4" -f mp4 -w 480 -l 320 --deinterlace="slow" -e x264 -x cabac=0:deblock=1,0:analyse=0x1,0x111:bitrate=416:psy_rd=1.0,0.0:chroma_me=1:chroma_qp_offset=-2:threads=3:nr=0:keyint=250:keyint_min=25:scenecut=40:bitrate=416:ratetol=1.0:qcomp=0.60:qpmin=10:qpmax=51:qpstep=4:cplxblur=20.0:qblur=0.5 -a 1 -E faac -B 96 -R 44.1 -6 stereo -D 1 -v -2 -T -S $3
$1 = filename.mpg (from Myth)
$2 = destination.mp4 (Android file)
$3 = maximum size of file
- I've run AVIs through this successfully too, which is why I didn't preset the extension through the routine.

Re: MythTV, Handbrake and Android conversions

Posted: Mon Mar 08, 2010 6:02 am
by Patrick
Got some excellent results re-encoding video for the Nexus1 via 2 pass ffmpeg (via x264 encoder):
First pass:
ffmpeg -i filein.mpg -aspect 3:2 -s 800x480 -vcodec libx264 -b 480k -r 23.976 -acodec libfaac -ab 128k -sameq -pass 1 fileout.mp4
2nd pass:
ffmpeg -i filein.mpg -aspect 3:2 -s 800x480 -vcodec libx264 -b 480k -r 23.976 -acodec libfaac -ab 128k -sameq -pass 2 fileout.mp4

4.1 gig HD 1 hour recording comes out as a 332meg file with very good looking video. Gonna tweak it some more and combine the 2 lines into one command.

Re: MythTV, Handbrake and Android conversions

Posted: Mon Mar 08, 2010 10:25 am
by kwisher
It would be great if the forum members here can post their scripts for converting MythTV recordings to various formats for various devices. I have lost the ability to use Nuvexport after enabling the Myth repos that were mentioned a few shows ago. I have been trying to get MythExport to work but have had no luck yet. I want to have the option to setup whatever conversion process as a user job in MythTV.

Any help would be appreciated.

Re: MythTV, Handbrake and Android conversions

Posted: Mon Mar 08, 2010 10:32 am
by Patrick
kwisher wrote:I have been trying to get MythExport to work but have had no luck yet. I want to have the option to setup whatever conversion process as a user job in MythTV.
As soon as I have my ffmpeg settings down the next step will be getting it into a profile in MythExport. Once I have a working profile I'll forward it to the MythExport dev for inclusion as a default profile.

Re: MythTV, Handbrake and Android conversions

Posted: Tue Mar 09, 2010 5:54 am
by Patrick
Interestingly enough changing the aspect to 16:9 from 3:2 doesn't seem to make a difference. Upping the video rate to 1000k does almost double the size of the file. The highest frame rate I've gotten is about 17 fps while my first entry does 12 fps. So any of the following work pretty well. All 3 versions do a 2 pass encode in one line now:

Very Good:
ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 outputfile.mp4

Better(bigger file):
ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 768k -r 25 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 768k -r 25 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 outputfile.mp4

Best(largest file):
ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 1000k -r 50 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && ffmpeg -i inputfile.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 1000k -r 50 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 outputfile.mp4


I think my first entry gives you the best in a relatively small file size with very good quality.

Update: I tested my videos on a co-worker's Motorola Droid and they played back fine. I bet if we lowered the resolution to 320x240 it would work fine for most of the older Android phones (G1, Mytouch3g, HTC Hero, Eris, etc..). I also emailed John Baab (Mythexport developer) my settings to add as a default profile in MythExport.

Re: MythTV, Handbrake and Android conversions

Posted: Sat Mar 13, 2010 12:32 pm
by kwisher
Pat,

Have you setup these ffmpeg scripts/commands in Mythexport? I am having no luck whatsoever at getting Mthexport to successfully export anything. Right now I am just executing them from the terminal. Do your scripts honor the commercial cut list?

TIA

Re: MythTV, Handbrake and Android conversions

Posted: Sat Mar 13, 2010 12:52 pm
by Patrick
kwisher wrote:Pat,
Have you setup these ffmpeg scripts/commands in Mythexport? I am having no luck whatsoever at getting Mthexport to successfully export anything. Right now I am just executing them from the terminal. Do your scripts honor the commercial cut list?
TIA
Been in contact w/John Baab to get these settings working in Mythexport. Hopefully we'll have a working profile real soon. Right now Mythexport nor this script honors the cutlist. I think nuvexport is the only one that does and that's been neglected for a while now.

Re: MythTV, Handbrake and Android conversions

Posted: Tue Mar 16, 2010 10:00 am
by Patrick
If anybody can try my settings and let me know if they work for you? Obviously you need the packages for libx264 and libfaac installed on your system.

Re: MythTV, Handbrake and Android conversions

Posted: Tue Mar 16, 2010 12:03 pm
by lobosolo
noob question.

how do i identify the recording i want to rip by the name ? i am looking in var/lib/mythtv/recordings (mythtbuntu9.10) but all the file names are just numbers. is there an easier way to do this ?

Re: MythTV, Handbrake and Android conversions

Posted: Tue Mar 16, 2010 12:26 pm
by Patrick
lobosolo wrote:noob question.

how do i identify the recording i want to rip by the name ? i am looking in var/lib/mythtv/recordings (mythtbuntu9.10) but all the file names are just numbers. is there an easier way to do this ?
Not until it's integrated into Mythexport. The file names are basically timestamps. The easiest way to identify what show is what is by looking at the timestamps in the recordings section of mythweb.

Re: MythTV, Handbrake and Android conversions

Posted: Wed Mar 17, 2010 6:34 am
by lobosolo
Patrick wrote:If anybody can try my settings and let me know if they work for you? Obviously you need the packages for libx264 and libfaac installed on your system.
i tried the "Very Good:" setting on a 30 minute show ,standard def from a PVR-150. the file was 996mb to start and ripped down to 129mb. i transferred it to my Droid and gave it a go. it was watchable but a little blocky/choppy . nothing major, but noticeable.

i will try the other 2 settings you have listed and see which one i like.

Re: MythTV, Handbrake and Android conversions

Posted: Wed Mar 17, 2010 8:09 pm
by pla
Patrick wrote:If anybody can try my settings and let me know if they work for you? Obviously you need the packages for libx264 and libfaac installed on your system.
Below are my results using Pat Davila's "Very good" version.

ffmpeg job started: Tue Mar 16 20:33:19 EDT 2010
ffmpeg job finished: Wed Mar 17 00:19:58 EDT 2010

Input file description: 1 hr HD episode of "Chuck" recorded via HDHomerun over the air (OTA)
Input file size: 6.1GB
Input video: mpeg2video, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 15100 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
Input audio: ac3, 48000 Hz, stereo, s16, 384 kb/s

Output file size: 287MB
Output video: h264, yuv420p, 800x480, 13 tbr, 13 tbn, 26 tbc
Output audio: Audio: aac, 48000 Hz, stereo, s16

Here is the complete command I used:

Code: Select all

ffmpeg -i Chuck_2010-03-15_8-00_PM_Chuck_Versus_the_Tic_Tac.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null && ffmpeg -i Chuck_2010-03-15_8-00_PM_Chuck_Versus_the_Tic_Tac.mpg -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -acodec libfaac -ab 128k -ac 2 -sameq -pass 2 Chuck_2010-03-15_8-00_PM_Chuck_Versus_the_Tic_Tac.mp4
Playback on my Nexus One looked great. The quality is much better than my single pass version. Thanks Pat Davila!

Rock on, PLA

Re: MythTV, Handbrake and Android conversions

Posted: Wed Mar 17, 2010 8:26 pm
by pla
lobosolo wrote:noob question.

how do i identify the recording i want to rip by the name ? i am looking in var/lib/mythtv/recordings (mythtbuntu9.10) but all the file names are just numbers. is there an easier way to do this ?
I use the mythrename.pl perl script. It creates human readable symbolic links in directory /var/lib/mythtv/pretty to the files in /var/lib/mythtv/recordings.

So instead of a file name of 2053_20100310233000.mpg you get a file name of The_Colbert_Report_2010-03-10_11-30_PM_Sean_Carroll.mpg.

Here is the user job command syntax i use:

Code: Select all

perl /usr/share/doc/mythtv-backend/contrib/user_jobs/mythrename.pl --underscores --link /var/lib/mythtv/pretty  --format %T_%Y-%m-%d_%g-%i_%A_%S
Rock on, PLA

Re: MythTV, Handbrake and Android conversions

Posted: Thu Mar 18, 2010 5:42 am
by Patrick
Ok I have a working Mythexport profile. In the Mythexport setup select 'custom' and name it 'Android'. This will create a skeleton entry in '/etc/mythtv/mythexport/mythexport_settings.cfg'. Add the following to the ffmpegArgs line:

Code: Select all

ffmpegArgs=-aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -deinterlace -acodec libfaac -ab 128k -sameq -pass 1 -f rawvideo -an -y /dev/null | -aspect 16:9 -s 800x480 -vcodec libx264 -b 480k -r 13 -deinterlace -acodec libfaac -ab 128k -ac 2 -sameq -pass 2
I added the deinterlace flag. Not sure if it makes much of a difference. I also bumped up the audio bitrate a bit. This will create a file with a human readable file name (Channel+Showname+EpidsodeTitle+timestamp). Please feel free to tweak and improve it. Please share your results with the rest of us.

Re: MythTV, Handbrake and Android conversions

Posted: Thu Mar 18, 2010 11:50 am
by lobosolo
any chance of getting a show-me -do episode of this ? mythexport is still a mystery to me. i have it installed but never seem to be able to get it working properly.