[mythtv] transcoding with cutlist

Geoffrey Hausheer ou401cru02 at sneakemail.com
Thu Aug 14 10:25:35 EDT 2003


On Wed, 13 Aug 2003 21:49:36 -0500, "Geoffrey Hausheer
ou401cru02-at-sneakemail.com |mythtv/1.0-Allow|"
<khm9hhqgzu0t at sneakemail.com> said:
> On Wed, 13 Aug 2003 18:47:09 -0700, "Chris Petersen
> lists-at-forevermore.net |mythtv/1.0-Allow|"
> <o8f8hesx3k0t at sneakemail.com> said:
> > > The only solution seems to require a muxed stream, which sucks.
> > 
> > Or you could just not use a fifo/pipe for the audio.  My svcd encoder
> > just write the audio to a file while it encodes the video that mplayer
> > puts into a fifo for me (I use mplayer to decode nuv to yuv, rather than
> > doing a stream copy into an avi).  Then again, 600 megs or so of audio
> > data sitting on my drive for an hour or two while the video encodes
> > isn't a big deal to me.
> The problem is that since mplayer reads the -audiofile at an irregular
> rate, it is possible for it to reach the end of the audio-file, in which
> case it detects it as eof, and the rest of the encoding is done with no
> audio (in fact, this isn't just possible, it happens to me every time)
> 
> So I'm still out of ideas.  I think it is particularly painful when using
> raw video, because of the huge discrepency in size between the video and
> audio frames.  Thus it is hard to cache enough video to get a decent
> audio buffer.  Oh well.
****** THIS PATCH WILL CAUSE YOUR COMPUTER TO EXPLODE---DO NOT USE
*******
As always, I spoke  a little too soon.  Here is a crude patch that lets
mythtranscode write to 2 fifos, that (sort of) works with mencoder.  it
dynamically allocates buffers for audio or video data to keep the fifos
from blocking, so if the rates are wrong, either audio or video will
consistantly require more buffers, and you'll eventually run outof RAM.

However, it appears to work acceptably once you get the rates set right. 
YOU WILL NEED THE CVS VERSION OF MPLAYER.

The patch overrides the 'keep all frames' flag in mythtranscode to mean
'write to fifos'
first create two fifos 'audout' and 'vidout' in the directory of your
choosing:
mkfifo audout
mkfifo vidout

in the directory with the fifos, run mythtranscode, use a command line
like:
mythtranscode -c 2036 -s 2003-08-08-11-00-00 -p Transcode -k
it should say 'CreatedThreads' and then sit there. I think there is still
a race in the code, so if it segfaults, just try again.  You can use the
'-l' switch to parse the cutlist, but DO NOT use the '-d' switch, or else
your nuv file will get deleted by mythbackend.

In another window, start mencoder as:
mencoder -audiofile audout -audio-demuxer 20 -rawaudio rate=32000
-rawvideo on:w=640:h=480:fps=29.97 -ovc lavc -oac mp3lame -o foo.avi
vidout
(point vidout and audout to the directory of the fifos you created).  The
above assumes your stream is 640x480:ntsc with audio at 32kps, change as
needed.

in the mythtranscode window you should see messages like:
allocating additonal buffer for : video(11)
allocating additonal buffer for : video(12)
For a while, then they should stop (probably around 50 for video, 20 for
audio, with the above settings).  If one or the other continuously climbs
throughout the encoding, your rates are wrong.

mencoder will run a bit slower than using files.  I haven't really looked
into it, but it probably has to do with the threading solution.  It
should be able to do the whole thing in a single thread using select(),
which will probably help.

As a side note, if you need to stop encoding, hit ctrl-c in the
mythtranscode window, NOT the mencoder window.  Otherwise the transcoder
will runaway and fill up all your ram.

For those wondering, this could probably be used for mplayer, but I doubt
it would be efficient.  The goal I am trying to achieve is to have the
fewest data-processing steps between going from nuv to avi/whatever,
while allowing the flexibility of processing cutlists.  the solution
providied in this patch allows to go from nuv to avi with one decode and
one encode of both audio and video.  I think I can get that down to only
an audio decode/encode when the nuv is in mpeg4, which should preserve
the best quality.  In theory if cutlists aren't being used, it would be
possible to go from nuv to avi using this method with no quality loss of
audio or video, but I'm not sure how realistic any of that is yet.

Obviously, this patch is very crude, doesn't clean up after itself, and
is, in general, not good.  But if someone else could try it out, and
confirm it works okay, I'll work on the audio-sync issues, and make it
presentable.  Also, make sur eto check the avi. I've noticed that
sometimes mencoder starts off a half frame off on the video, which leads
to a black line down the middle of the picture.  I'm not sure when this
happens, but it seems to happen mostly if I didn't stop mythtranscode
first in the previous run.

.Geoff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mythencode.patch
Type: application/unknown
Size: 4376 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20030814/51c799b4/mythencode.bin


More information about the mythtv-dev mailing list