PDA

View Full Version : H.264/x264 Transcode



Quantumstate
December 21st, 2008, 11:23 PM
I've just about figured out how to transcode a movie and cut commercials, but I want it to transcode from ATSC mpeg2 to H.264/AVC Bluray format.

I've set transcode High mode to mpeg4, but no clue if this is the x264 codec?

I transcoded one clip, but it only went from 1.6GB to 1.3GB. Considering the commercials removed this sure isn't much of an improvement, and I suspect it is still mpeg2. How can I check what format the clip is in?

Also the only options for sound are mp3 or uncompressed. Neither is compatible with Bluray players. Does Bluray use AAC or AC-3? How do I make whichever of these available to Myth transcode?

I am willing to compile the Myth SVN, if it is necesary to get these functions built-in.

ian dobson
December 22nd, 2008, 08:27 AM
Hi,

Looking at a transcoded recording I have (using GSpot http://gspot.headbands.com/) it looks as if the file is a MPEG4 stream in a NUV container.

Transcoding to H264 may not be possible, but exporting using nuvxport should be possible but don't expect it to be very quick. My quad core backend can just about transcode MPEG2 to H254 in realtime using 4 threads and wind from behind :)

Regards
Ian Dobson

zagor
December 22nd, 2008, 02:00 PM
I'm very much satisfied with the mythnuv2mkv (http://web.aanet.com.au/~auric/?q=node/6)script, added as a user job.
It outputs a very nice .mkv file in ~30min for a 25min recording (quality=med settings) on my dual core.

Try it out.
The guy there is also very friendly and will help you if you need.

Quantumstate
December 22nd, 2008, 04:41 PM
But the goal is to transcode ATSC mpeg2 to a format that Bluray can play, including audio in 5.1 or 7.1. It seems clear that H.264/AVC by x264 is best for video format, but I don't know how to automate that. I'll study the recommended apps.

And audio is a real question. I believe ATSC sends audio in stereo, 5.1 or 7.1, and maybe this is encoded with AC-3? How can I transcode audio while preserving stereo, 5.1 or 7.1? Into E-AC3, or something else? What would be compatible with Bluray players?

How do I make x264 available to Myth? How do I make the proper audio codec(s) available to Myth?

I believe that archiving things into Bluray standards has the best chance of long-term compatibility.

zagor
December 22nd, 2008, 05:47 PM
But the goal is to transcode ATSC mpeg2 to a format that Bluray can play
Yes, I know. I don't know anything on BluRay, but I've seen the best H.264 out there produced by the script I've pointed you at.
It also gives audio aac by default.
And the author knows pretty much about this stuff: I believe you can ask him directly on his site if he knows how to give a bluray-compatible output file.

Most of the scripts rely on mencoder, so the real question here will be if mencoder can produce a bluray video with consistent audio.

As for the codecs, again, check out Auric's blog: there's a nice list of "must have" applications

Hope I've been of any help...

Quantumstate
December 22nd, 2008, 10:09 PM
OK, before I use the script, I have to import the commercial flags into the cutlist. Unsure how to do that automatically.

Also the script crashes and burns. No idea what's wrong; the directory certainly exists, and mythconverg is there as Myth works:
# /usr/local/bin/mythnuv2mkv.sh --copydir /media/media/Media/Videos --starttime=20081214220000 --quality=high
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
22/12,13:05 [12938] ERROR Skipping /media/media/Media/TV/Recorded/--copydir does not exist.
--------------------------------------------------------------------------------
22/12,13:05 [12938] ERROR Skipping /media/media/Media/Videos does not exist.
--------------------------------------------------------------------------------
22/12,13:05 [12938] ERROR Skipping 20081214220000. chanid not specified.
--------------------------------------------------------------------------------
22/12,13:05 [12938] INFO Changed to high quality.
22/12,13:05 [12938] INFO Exiting. Errored.
22/12,13:05 [12938] ERROR This error could be for many reasons. Mythtv will report unable to find executable, this is incorrect.

zagor
December 23rd, 2008, 10:27 AM
I guess you already have checked the permission in the output directory, right? I did forget this the first time I set it up...
Don't know how to address your first main error:

ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
I think it's misunderstanding the filename, for it's looking for a recording named "--copydir":

22/12,13:05 [12938] ERROR Skipping /media/media/Media/TV/Recorded/--copydir does not exist.
so chances are that the following might help.
I've found out that the "=" sign is needed when using the CLI, while it seems it doesn't always matter from a user job. Haven't done a real debug, though, just observations.
And the order of the options used to be important.

My suggestion here is to change your command line into:

# /usr/local/bin/mythnuv2mkv.sh --quality=high --copydir=/media/media/Media/Videos --chanid=xxxx --starttime=20081214220000

Note also that you must pass the chanid.
At the beginning of the script, in the instructions area, you'll find:

Must have either --chanid=chanid and --starttime=starttime or a plain filename. These can be mixed. e.g. -
mythnuv2mkv.sh --chanid=1232 --starttime=20071231235900 video1 video2 --chanid=1235 --starttime=20071231205900

What I do is the following:
Edit the cut list in mythtv.
Queue a lossless transcoding to cut out commercials.
Queue a UserJob with mythnuv2mkv

In the userJob I have:

/usr/local/bin/mythnuv2mkv.sh --jobid=%JOBID% --quality=med --copydir=/var/lib/mythtv/videos/converted --chanid=%CHANID% --starttime=%STARTTIME%
I also have another user job with --quality=high

Cut lists should be automatically honored, still I prefer to run it separately.

If you happen to prefer using CLI, I'd suggest using Auric's instruction for file rename and than call the filename itself, instead of chanid and starttime: it's easier to check if you are doing it properly

What I do in this case is:

#/home/zagor/mythrename.pl --link --format %T-%S --underscores --verbose
#/usr/local/bin/mythnuv2mkv.sh --quality=high --copydir=/var/lib/mythtv/videos/converted /var/lib/mythtv/recordings/show_names/filename.mpg

Hope it helps.

Quantumstate
December 25th, 2008, 07:45 PM
I guess I'm lost. I don't know where or how to edit a cutlist, and I don't know where or how to get the channel id. And I don't know how to do a sequence of actions like you describe here:
What I do is the following:
Edit the cut list in mythtv.
Queue a lossless transcoding to cut out commercials.
Queue a UserJob with mythnuv2mkv

I can manually run jobs by arrow, Job. I'll only want to transcode a certain few programs for archiving, not all of them.

But it seems like this might be a dealkiller:
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)

Quantumstate
December 25th, 2008, 08:04 PM
Maybe chanid is the first four:

# mythnuv2mkv.sh --quality=med --copydir=/media/media/Media/Videos --chanid=2072 --starttime=20081219073000
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
25/12,11:02 [29430] INFO Changed to med quality.
25/12,11:02 [29430] INFO AVI will be located in /media/media/Media/Videos.
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
25/12,11:02 [29430] ERROR Skipping 2072 20081219073000. Did not match a recording.
--------------------------------------------------------------------------------
25/12,11:02 [29430] INFO Exiting. Errored.
25/12,11:02 [29430] ERROR This error could be for many reasons. Mythtv will report unable to find executable, this is incorrect.
#

EasyRiderOnTheStorm
December 27th, 2008, 09:23 PM
I guess I'm lost. I don't know where or how to edit a cutlist, and I don't know where or how to get the channel id. And I don't know how to do a sequence of actions like you describe here:
What I do is the following:
Edit the cut list in mythtv.
Queue a lossless transcoding to cut out commercials.
Queue a UserJob with mythnuv2mkv

You can edit a mythtv recording within the mythtv player, while you are playing it. Just call up the menu ('M') during playback, the first menu item should be "Edit..". Then you can move around the paused video an mark cut points. Also, you can "import" any commercial flagging if it has been done previously as an instant cutlist by pressing 'Z'.

Lossless transcoding (only to apply a cutlist to a recording) should be possible if you check the "lossless" checkbox under the "recording groups" setup, for one of the listed transcoders there. I've never tried it though...


But it seems like this might be a dealkiller:
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)

That probably is your problem; It strikes me though that 'mythconverg' is not the name of a host but the name of the MySQL database. Something seems seriously screwed there config-wise if it tries to use that as a host name. You might try to check your mysql.txt (~mythtv/.mythtv/mysql.txt)...

Strangely enough, the script mostly works for me (but gets the audio sync wrong), except can't find any recording. If I run it with "--findtitle", it finds the recording(s) beautifully - then when I run it with the found chanid/starttime it can't find the recording (which exists named as exactly the former 'chanid_starttime.nuv'). Run with that explicit filename it just works. Go figure...

Quantumstate
January 3rd, 2009, 11:37 PM
OK, mythnuv2mkv.sh is busted AFAIC. Does anyone know of another way to transcode using x264?


/media/media/TV/Recorded # /usr/local/bin/mythnuv2mkv.sh --quality=high --copydir=/media/media/Videos --findtitle=3111_20090101182600.mpg
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)
03/01,14:39 [29859] INFO Changed to high quality.
03/01,14:39 [29859] INFO AVI will be located in /media/media/Videos.
ERROR 2005 (HY000): Unknown MySQL server host 'mythconverg' (1)

03/01,14:39 [29859] INFO Exiting. Successfull.

/media/media/TV/Recorded #
(No, it wasn't "successfull")

blackoper
January 6th, 2009, 12:00 AM
script worked fine for me. I think your hostname is wrong.. mythconverg should be the database.. localhost or whatever your server name is should be the hostname

Quantumstate
January 9th, 2009, 05:16 PM
Hostname is localhost. I have mysql listening only there for security, and wish I could figure out how to make Myth listen only to localhost.

I simply can not figure out how to make this script work, despite all efforts.

Isn't there any other option, for converting mpeg2 to H.264 in Myth?

blackoper
January 10th, 2009, 05:18 PM
I gave up messing with internal transcoders in myth for now. Instead I'm using AutoMKV on a windows box to convert it to WMV -VC1 with 5.1 audio (this is for releasing stuff and that format works on pc, xbox 360 and ps3)

lokimon
March 14th, 2009, 09:38 PM
I gave up messing with internal transcoders in myth for now. Instead I'm using AutoMKV on a windows box to convert it to WMV -VC1 with 5.1 audio (this is for releasing stuff and that format works on pc, xbox 360 and ps3)

i want to do the same thing, and i went about it by installing HandBrakeCLI, which can do very nice rips to just about any format.

i have a bunch of HD content that i want to transcode down to x264/mp4 content preferably with ac3 audio.

i am using this command successfully on the command line to get a bitrate of 1000 and resolution of 624x352:


HandBrakeCLI -i /path/to/recording.mpg -o /path/to/output.mp4 -e x264 -w 624

however when i insert that command as a user job as follows the job stays queued but does not run:


HandBrakeCLI -i %FILE% -o /path/to/destination/%TITLE%%SUBTITLE%.mp4 -e x264 -w 624

any ideas about what i might be doing wrong?

nickrout
March 15th, 2009, 12:17 AM
maybe you need to include the full path to the handbrake command? like:


/usr/local/bin/HandBrakeCLI

etc

nickrout
March 15th, 2009, 12:21 AM
deleted incorrect post

theophile
March 15th, 2009, 03:11 AM
I tried Handbrake to transcode HD recordings but was never happy with the output. After a lot of trial and error and numerous test encodes, I finally came up with a mencoder bash script that produces files with size and quality on par with the 720p files that can be obtained via popular p2p protocols.

I don't run it automatically for a couple of reasons. First, I always spot-check the commercial detection. It's usually right, but I don't want to risk it. Second, this script takes about 13-14 hours to encode a 1 hour (43 minute) episode using both passes. I prefer to schedule the encodes for times when I won't be using the backend for that long.

One other caveat. HD comes off my cable box over firewire at 60fps (59.94fps). If your source is not 60/59.94fps, you'll have to adjust the -fps argument or else the speed of the encoded video will be off.

Anyway, here's the script. Hope others find it useful.


#!/bin/bash
until [ "$*" = "" ]
do
file_name="$1"
out_name=$(basename "$1" '.mpg').mkv
mencoder -vf hqdn3d=2:1:2,framestep=2,softskip,harddup -fps 60000/1001 -ofps 30000/1001 -aspect 1.7778 -of rawvideo -o /dev/null -nosound -ovc x264 -x264encopts bitrate=3250:pass=1:subq=1:frameref=1:turbo=2:bfra mes=3 "$1" -nosound
mencoder -vf hqdn3d=2:1:2,framestep=2,softskip,harddup -fps 60000/1001 -ofps 30000/1001 -aspect 1.7778 -of rawvideo -o autox264.h264 -nosound -ovc x264 -x264encopts bitrate=3250:threads=auto:pass=2:bframes=3:partiti ons=i4x4,i8x8,p8x8,b8x8:8x8dct:me=hex:subq=6:turbo =2:frameref=3:deblock=-1,-1:weight_b:trellis=1:mixed_refs:level=4.1:vbv_maxr ate=50000:vbv_bufsize=50000:qblur=0.5 "$1"
mkvmerge --default-duration 0:30000/1001fps -o "${out_name}" autox264.h264 -D "$1"
rm autox264.h264 divx2pass.log
shift
done

lokimon
March 15th, 2009, 05:34 AM
maybe you need to include the full path to the handbrake command? like:


/usr/local/bin/HandBrakeCLI

etc

yeah i put the full paths in, and the job still just sits in the queue and doesn't get done.

i don't see any mention of it in the mythbackend log, don't know what other log to check for errors on user jobs.

nickrout
March 16th, 2009, 01:45 AM
yeah i put the full paths in, and the job still just sits in the queue and doesn't get done.

i don't see any mention of it in the mythbackend log, don't know what other log to check for errors on user jobs.

I am wondering if your destination filename is giving problems. %TITLE%%SUBTITLE% potentially has spaces, so may need to be quoted. You may need to play around with exactly where to put the quotes.

lokimon
March 16th, 2009, 05:08 PM
I am wondering if your destination filename is giving problems. %TITLE%%SUBTITLE% potentially has spaces, so may need to be quoted. You may need to play around with exactly where to put the quotes.

ah, gotcha.

will try "%TITLE%"."%SUBTITLE%" tonight and see if that works.

thanks!

i would be curious to hear about the issues that theophile encountered with handbrake. what sort of things bothered you about the quality? for me, even at only 624x352 most shows look fine to me (on a 42" aquos.) - by "fine" i mean that although if i stand close to the tv i can see artifacts, but it doesn't bother me to watch it.

for stuff i want in HQ i go with 960x540 and 2400 bitrate, which seems great, and i don't notice much in the way of artifacts.

lokimon
March 18th, 2009, 05:45 PM
ok, tried "%TITLE%"."%SUBTITLE%" as well as "%TITLE%%SUBTITLE%", but neither worked.

does anyone know where myth would store the log files for this stuff? i think the errors would help a lot.



ah, gotcha.

will try "%TITLE%"."%SUBTITLE%" tonight and see if that works.

thanks!

i would be curious to hear about the issues that theophile encountered with handbrake. what sort of things bothered you about the quality? for me, even at only 624x352 most shows look fine to me (on a 42" aquos.) - by "fine" i mean that although if i stand close to the tv i can see artifacts, but it doesn't bother me to watch it.

for stuff i want in HQ i go with 960x540 and 2400 bitrate, which seems great, and i don't notice much in the way of artifacts.

nickrout
March 18th, 2009, 07:25 PM
in the backend log I think.

lokimon
March 24th, 2009, 03:35 PM
weird. i see the commercial flagging jobs in the backend log, but this job never shows up, just sits in the queue.

don't know where else to look for the error. this is weird, because the job works fine on the command line.

zagor
March 25th, 2009, 09:15 AM
Lokimon, I remember in the past I've read somewhere that HandBrake cannot be used in a mythjob because it doesn't take the usual %TITLE% and so as arguments.
Instead, you should pass the full filename.
This is actually why I'm using HB (with the gui, recently) as a standalone process and mythnuv2mkv as a mythjob.

Maybe someone who knows how to program, can write a script to be used as a job that:
1. check the filename of the recording
2. check title-subtitle in the database and set a human-readable output filename
3. pass the full HB command with all the options needed
4. keep track of those steps in the frontend joblog.

Anyone volunteers?


(note: should I find the page where I've read about HB and mythjob, I'll post it)

lokimon
March 31st, 2009, 09:48 PM
Lokimon, I remember in the past I've read somewhere that HandBrake cannot be used in a mythjob because it doesn't take the usual %TITLE% and so as arguments.
Instead, you should pass the full filename.
This is actually why I'm using HB (with the gui, recently) as a standalone process and mythnuv2mkv as a mythjob.

Maybe someone who knows how to program, can write a script to be used as a job that:
1. check the filename of the recording
2. check title-subtitle in the database and set a human-readable output filename
3. pass the full HB command with all the options needed
4. keep track of those steps in the frontend joblog.

Anyone volunteers?


(note: should I find the page where I've read about HB and mythjob, I'll post it)

thanks, that was the crucial bit of info i was missing.

i had gone to the trouble of installing HB, and had actually been able to archive some stuff, so i didn't want to install a different archival tool, and risk breaking HB (as long as i could manage to automate it, that is.)

seems like i should just follow the thread instructions and see if that works for me.

i noticed that this thread has been around since before the current mythbuntu release. read the whole thing looking for updated instructions but if they are in there i missed them.

so, as far as i can tell, even with the latest mythbuntu, i still need to follow all the steps in this thread?

thanks for all the help.