<H2><A NAME="ss23.14">23.14</A> <A HREF="mythtv-HOWTO.html#toc23.14">What is this transcoder thing, and how do I use it?</A>
</H2>

<P>MythTV's built-in transcoder re-encodes recordings from one
codec/format to another.  Transcoding is most commonly used to allow
users with hardware encoders (PVR cards, DVB cards, ATSC HD, etc.) or
systems that can only record in RTjpeg due to performance reasons
(multiple capture cards, slow system, etc) to create MPEG-4 streams to
save space.  However, with the addition of HD sources transcoding has
come to be used to transcode and resize HD MPEG-2 recordings into
MPEG4 files to be played on systems too slow to deal with the original
HD recordings.  There are even more uses for transcoding though,
including the ability to fix up MPEG2 recordings or remove commercials
without transcoding at all.
<P> The original file is actually removed when the transcoding process
is complete.  Unless you're sure that you will be satisfied with the
result you may want to enable the mythv-setup option which causes
mythbackend to keep the original after transcoding.  This option is on
the second page of the General section in mythtv-setup.  Enabling this
allows you to compare the two files and restore the original if you
like.  Outside of the initial setup phase, it usually isn't neccesary
to leave this option enabled.
</P>

<P>A recording can be transcoded in two ways:
<UL>
<LI>Automatically transcode the file once it has completed
recording.</LI>
<LI>Manually choosing to transcode a recording, usually after
importing a cutlist or manually marking commercials to be
removed.</LI>
</UL>

<P>The second method can be used on files that have already been
transcoded (or files which were are already in the desired format), so
only the frames immediately following a cut section will be
re-encoded, resulting in a very minimal loss of quality when removing
commercials.</P>

<P>The current transcoding system has a lot flexibility, but there are
a number of steps involved in setting it up.  In order to
automatically transcode a given recording you must do the following:</P>
<OL>
<LI>Configure recording profile for your capture source and enable
transcoding on one or more profiles.</LI>
<LI>Configure one or more transcoding profiles.</LI>
<LI>Create or alter existing scheduled recordings to enable
transcoding for that recording.</LI>
</OL>

<H3>Configuring Recording Profiles to Allow Transcoding</H3>

<P>Enter the Utilities/Setup,Setup,TV Settings,Recording Profiles
section in mythfrontend.  Choose the option that corresponds with your
capture source (ignore the Transcoders for now.)  Choose the quality
profile you are interested in enabling auto-transcode for.  Make sure
"Enable auto-transcode after recording" is checked.  This option might
ought to be called "allow auto-transcode" as we'll soon see though.
You might want to verify that the other settings for this profile are
correct while your here.</P>

<H3>Configure Transcoding Profiles</H3>

<P>Enter the Transcoders section under Recording Profiles.  There are
three quality settings to choose from and a two special Autodetect
settings.  Later, when scheduling recordings you'll have to choose one
of Autodetect, High, Medium, and Low Quality transcode settings in
addition to the recording profile we set up above.  If you choose the
Autodetect transcoding profile for a recording, MythTV will use the
"Autodetect from RTjpeg/MPEG4" profile for recordings which are
RTjpeg/MPEG4 files.  Otherwise, it will use the "Autodetect from
MPEG2" provided it's an MPEG-2 recording.  If you choose one of the
others (High, Med. Low) it will use the settings in that profile
regardless of the codec of the original recording.</P>

<P>There are a myriad of options for transcoding but the simplest
setting is to enable lossless transcoding (the first option) as this
removes all other options. Enabling lossless encoding simply removes
commercials (if you've marked them) and attempts to clean up MPEG2
streams.  Note: with this option MythTV will not apply denoise filters
or anything of the sort.  It only attempts to massage the stream into
something cleaner and less likely to have trouble with other less
forgiving MPEG2 hardware/software (including players, video editors,
etc.)</P>

<P>If you enable resizing of the recording the next page has the
settings for choosing the final resolution.  Note: MythTV will scale
the video as appropriate not crop it to this resolution.</P>

<P>The final two pages allow configuration of the video and audio
codecs.  Although RTjpeg is an option for video codec I can think of
no reason you'd want to transcode to that format.  It produces larger
files than MPEG4 <i>and</i> the recording will take <i>more</i> CPU
power to play back.  The MPEG4 settings are not exactly
self-explanatory but you can judge for yourself the effects on the
final file and it's easy to expirement with until you achieve a good
compromise between size and quality. For those who've messed up their
MPEG4 transcoding profile, the defaults from memory are Bitrate:
2200-2500, MaxQ: 2, MinQ: 15, MaxQDiff: 3, and "Scale bitrate for
frame size" is enabled.  The other options are unchecked.  If you're
getting weird results from MPEG4 transcoding try setting as above and
go from there.</P>

<H3>Create/Alter Scheduled Recordings to Enable Transcoding</H3>

<P>Transcoding is actually enabled on a per-recording basis.  Two
things must be true before any given recording will be
auto-transcoded, however.  The first is that the recording must have
been made with a recording profile that has auto-transcode enabled.
Under "Storage Options" for the recording you must set the "Record
using the "X" profile" to the profile you configured in the first
step.  In addition, under the "Post Recording Options" section of the
recording you must also set "Transcode new recordings." This is also
where you specify the Transcoding profile to use (Auto, High, Medium,
Low.)</P>

<P>It may not be obvious from above but the flexibility of this system
is primarily to make it possible to auto-transcode a show recorded via
one source (ie: pcHDTV 3000), and not transcode that same show if it's
recorded on another kind of card (ie: PVR-250.)  There are other uses
however.  You could have a PVR-250 and a V4L card.  You may want to
transcode the MPEG2 from the PVR-250 but there is no need to transcode
the recordings made with the V4L card, as it's already likely to be
MPEG4.</P>

<P>As an example, you could configure the Default profile for
"Hardware DVB Encoders" (the profile group used for DVB cards,
including the ATSC HD type cards like pcHDTV 3000) to "Enable
auto-transcoding."  In the Default profile for MPEG-2 Encoders (PVR
cards) you'd leave "Enable auto-transcoding" unchecked.  For programs
that are available on both kinds of cards (think Law & Order, which is
available on virtually every channel) you'd set the recording profile
to Default and enable auto-transcoding in the record settings.  Then
you pick your transcoding profile.  When Law & Order plays on your DVB
card, it will get transcoded.  When it plays on a channel available
via your PVR card, it won't be.</P>

<P>Manually transcoding a recording is also possible.  It can be
activated while watching a show by hitting 'x', or from the OSD menus
by choosing the Transcode option, or by choosing Job Options/Transcode
from the info menu accessed from the Watch or Delete Recordings
screens.  The transcoding profile used for manual transcoding is
whatever you set when you originally configured this recording, even
if you didn't enable auto-transcoding.  The only way to change what
transcoding profile will be used is to alter the transcoder column in
the recorded table in the database.  This makes it difficult to decide
after the fact whether or not to simply remove commercials or
transcode to MPEG4.</P>