[mythtv] [PATCH] Background transcoding

Geoffrey Hausheer ou401cru02 at sneakemail.com
Sun Apr 13 20:33:04 EDT 2003


Here is a working version of my transcoding patch.  It is not ready yet,
as there are still some issue to resolve, and I'd like input on whether
it would be better to use a single recording directory instead of 2
seperate directories.

What it is for:
Allows encoding using high-quality settings that could not normally be
done in real time (due to using two encoder simultaneously on the same
machine perhaps, or for systems that are too slow to encode in mpeg4 at
high resolution)

What it does:

Creates a 'Transcode' parameter in the 'settings' table which will
enable/disable this feature.

Creates a new 'Transcode' recording profile that is a duplicate of the
default profile (but initializes to using MPEG4 encoding).  It is thus
useful for the 'Default' profile to use RTJPEG, since what is the use
otherwise?

It uses a new RecordAltFilePrefix to designate the directroy to transcode
to  you could make this the same as RecordFilePrefix (As long as you
leave the 'unlink' commands commented out), as it transcodes to a tmp
file, and then renames that file to a .nuv.  The end result is that
RecordFilePrefix becomes a temporary directory, with the permanent
location being the new 'Alt' dir.

Transcoding happens as a seperate process (not just a seperate thread),
because libavcodec is not threadsafe.

When mythbackend starts, it will search for any files in
RecordFilePrefixi (and in the recorded db), and  will begin transcoding
them all simultaneously (each transcoding process gets niced to 19).  A
polling thread is then started to deal with deleting the original files,
and to actually spawn new transcoders.  This obviously means thatthe
first time you start mythbackend, it will try to transcode your entire
library.  If you don't want it to do that, comment out the
RestartTranscode command in tv_rec.cpp

When a transcode is finished, it signals that it is done, and the polling
thread will try to delete the original file.  This may not be possible
depending on whether it is being watched at the moment (but the current
code does not check for that yet)

When a recording has finished, a comand is enqueued to begin transcoding.
 The Polling thread will then start the transcoder.  In theory this will
allow control of how many transcoders are running concurrently (though
that is not yet implemented either)

Things that are not done yet:
There is no way to change parameters via the setup menus.

There are no checks for disk-space usage in the new Alt dir.

The Reencoder is still a bit of a hack, and will not work with hardware
mpeg2 encoding, nor can it do rescaling or deinterlacing, and it can do
no audio processing (the audio must be recorded in mp3)

I think the reencoder should be moved down into the nuppeldecoder and
avformatdecoder files, but I haven't really looked into how to do that
yet.

The transcoders cannot be controlled (paused, terminated), and there is
no way to limit the number of them.

Any comments would be appreciated (especially on how to make the
Reencoder more flexible, or opinions on  using two save dirs instead of
one)

Thanks,
.Geoff

The patch is too big for the mailing list (makes my message >40kb) so
fetch it here:
http://www.phracturedblue.com/myth/transcode1.patch
-- 
  Geoffrey Hausheer
  XXXXXXXXXXXXXXXXXXXXX


More information about the mythtv-dev mailing list