Activar Transcode para Mediatomb (Ingles)

This document describes how to test the transcoding feature with the current
MediaTomb SVN code.

1. check out the latest development code from SVN:
   svn co [url]https://svn.mediatomb.cc/svnroot/mediatomb/trunk/mediatomb[/url] mediatomb

2. make sure you have automake (at least 1.9) and autoconf (at least 2.59)
   installed and run the following command in order to generate the configure
   script: autoreconf -i

3. make sure you have all requried dependencies, take a look at the section 2
   of the documentation to find out what you need:
   [url]http://mediatomb.cc/pages/documentation[/url]

   if you want to be minimalistic just install sqlite3-devel and file-devel

4. in case you already have an existing MediaTomb installation, it is a good
   idea to keep this testing install separate, I suggest you pick a directory
   in your home, in below example we will assume that you will do your test
   install in /home/user/test

   so, run the configure script:
   ./configure --prefix=/home/user/test --enable-transcoding

5. build MediaTomb and install it - it will be put in the /home/user/test
   directory: make && make install

6. create a separate configuration (i.e., in order not to mess up your default
   installation); the easiest way to do it is to run MediaTomb, specifying an
   alternative configuration directory:
   /home/user/test/bin/mediatomb -m /tmp -f testinstall

7. press CTRL-C to terminate the server, verify that a fresh config.xml and a
   new database have been created in the /tmp/testinstall directory.

8. now comes the tricky part; as you probably read from the news, the current
   transcodin that accepts an input file and is capable of outputting the
   transcoded stream to a FIFO.

   that also means, that you can test your transcoder independently of
   MediaTomb, before adding it to the configuration. some transcoders, like
   ffmpeg will require wrapper scripts, because they seem to have problems
   writing to a FIFO.

   so, before we add our profiles to MediaTomb, we will do some testing in the
   terminal. of course I could simply tell you what already works and give you
   a predefined setup, however I want you to understand the idea behind the
   external transcoding feature.

   first example:
   let's assume that you want to transcode flac files to PCM, this can
   be achieved with the help of the ogg123 application.

   create a FIFO for testing:
   mkfifo /tmp/mytest

   run ogg123, specifying the input file and telling it to output the data to
   your test FIFO:
   ogg123 -d wav -f /tmp/mytest /home/mymusic/somefile.flac

   you should see that ogg123 starts up and then keeps waiting. in a different
   terminal, try playing from the FIFO:
   mplayer /tmp/mytest

   you should see that ogg123 starts decoding, and mplayer should play the
   transcoded PCM stream.

   this mens that ogg123 can handle the output to a FIFO and thus will also
   work when called by MediaTomb.

   second example:
   ffmpeg has problems with outputting data to a FIFO, so we need a wrapper
   script, use your favorite text editor to create the following script:

   #!/bin/sh
   exec ffmpeg -i "$1" -b 2000k -me zero -f mpeg -ar 48000 -ac 2 - >"$2"

   this example transcodes to MPEG, of course you can use any ffmpeg
   transcoding options you like. note however, that when transcoding to a video
   format you have to choose one that can be streamed (like MPEG), .AVI will
   not work!

   note, that the script starts ffmpeg using the exec call - this is very
   important, it will ensure that ffmpeg will run with the same process ID as
   the ffmpeg-tr.sh script; this is required so MediaTomb can kill the process
   when playback has been stopped.

   put your script in $PATH (i.e. in a location that is in your $PATH), make
   sure that it is executable (i.e. chmod u+x ffmpeg-tr.sh)

   perform the same test as in the first example:
   ./ffmpeg-tr.sh /home/user/videos/myvideo.avi /tmp/mytest

   try playing from the fifo in a second terminal:
   mplayer /tmp/mytest

   if all works well you can go ahead and add the ffmpeg profile to your
   config.xml

   using vlc is another possibility, actually we had a much better experience
   with it. also, while ffmpeg has problems streaming URLs directly (i.e.
   accessing online content), vlc seems to handle that pretty well. the
   following script worked nicely for transcoding YouTube videos:

   #!/bin/sh

   INPUT="$1"
   OUTPUT="$2"

   exec vlc -I dummy "${INPUT}" --sout \
   "#transcode{venc=ffmpeg,vcodec=mp2v,vb=4096,fps=25,scale=,aenc=ffmpeg,\
   acodec=mpga,ab=192,samplerate=44100,channels=2}:standard{access=file,\
   mux=ps,dst=${OUTPUT}}" vlc:quit \
   >/dev/null 2>&1
   
9. the transcoding layout in config.xml goes under the <config> tag, for
   example you can put it right after the </import> tag.

  <transcoding enabled="yes">
    <mappings>
        <mimetype-profile>
            <transcode mimetype="audio/mpeg" using="mp3-pcm"/>
            <transcode mimetype="audio/x-flac" using="oggflac-pcm"/>
            <transcode mimetype="application/ogg" using="oggflac-pcm"/>
            <transcode mimetype="text/plain" using="text-to-speech"/>
            <transcode mimetype="video/x-msvideo" using="ffmpeg-sh"/>
            <transcode mimetype="video/x-flv" using="vlc"/>
        </mimetype-profile>
    </mappings>
    <profiles>
        <profile name="vlc" enabled="yes" type="external">
            <mimetype>video/mpeg</mimetype>
            <accept-url>yes</accept-url>
            <first-resource>yes</first-resource>
            <agent command="vlc-tr.sh" arguments="%in %out"/>
            <buffer size="10485760" chunk-size="131072" fill-size="5242880"/>
        </profile>
        <profile name="ffmpeg-sh" enabled="yes" type="external">
            <mimetype>video/mpeg</mimetype>
            <accept-url>no</accept-url>
            <first-resource>yes</first-resource>
            <agent command="ffmpeg-tr.sh" arguments="%in %out"/>
            <buffer size="10485760" chunk-size="131072" fill-size="5242880"/>
        </profile>
        <profile name="text-to-speech" enabled="yes" type="external">
            <hide-original-resource>yes</hide-original-resource>
            <mimetype>audio/x-wav</mimetype>
            <accept-url>no</accept-url>
            <agent command="espeak" arguments="-f %in -w %out"/>
            <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
        </profile>
         <profile name="oggflac-pcm" enabled="yes" type="external">
            <mimetype>audio/x-wav</mimetype>
            <accept-url>yes</accept-url>
            <first-resource>yes</first-resource>
            <agent command="ogg123" arguments="-d wav -f %out %in"/>
            <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
        </profile>
         <profile name="mp3-pcm" enabled="yes" type="external">
            <mimetype>audio/x-wav</mimetype>
            <accept-url>yes</accept-url>
            <first-resource>yes</first-resource>
            <agent command="mpg123" arguments="--wav %out %in"/>
            <buffer size="1048576" chunk-size="131072" fill-size="262144"/>
        </profile>
    </profiles>
  </transcoding>

  first mimetype to profile mappings are defined - that means, you set which
  transcoding profile will handle a particular mimetype.

  then you define the profiles, each profile defines the mimetype of the
  transcoded stream (or the target mimetype) and specifies how the transcoding
  is done (look at the agent tag). %in and %out are special tokens,
  they will be replaced by the input file name, fifo name or URL and the
  output FIFO name when the transcoder is launched.

  note the buffer setting - you can define the size of the buffer,
  the size of the chunks (i.e. how much data will be read from the buffer at
  once) and the initial fill size of the buffer (at the start of transcoding
  the first data will be sent to the renderer after the buffer is filled up
  to that value)

  there is a special option, if the profile is supposed to handle ogg theora
  but not ogg vorbis files: simply add a empty <theora/> tag under <profile>.

  the values used above are just example settings, you might have to finetune
  them to match the performance of your system. a fast system can usually
  use lower fill-size values, thus having a better response time
  when starting playback.
  on a slower system it might be better to prefill the buffer to some higher
  amount to prevent dropouts.

10. remember, that we created a new configuration in /tmp/testinstall, so,
   edit your and define transcoding. make sure that
   the transcoders are in $PATH

11. start mediatomb, pointing it to your new configuration:
  /home/user/test/bin/mediatomb -c /tmp/testinstall/config.xml

12. go to your renderer and try to play media that is usually unsupported,
  watch the mediatomb console, you should see how it starts the transcoder
  when you press PLAY on your renderer; if your transcoder fails you should
  also see that there, in this case you will have to do some debugging as
  described in 8., also check that you specified all command line arguments
  correctly in the agent tag of your configuration.


KNOWN ISSUES:
obviously, seeking and thus FF/REW will not be possible. pausing may work, but
this depends on how your player implements it; if it simply stops reading the
data but keeps the connection open - pause will work; if it shuts down the
connection when you press pause - resuming from where you paused will not work.

The PlayStation 3 is very eager to enforce the use of various DLNA tags and
will refuse even trying to play the media if it does not like something in the
browse result XML. Currently we have success reports playing transcoded video
streams (to MPEG) on the PS3, but we also have failures to play PCM streams.
This is related to the PS3 firmware and has to be investigated.

We also have success reports of playing transcoded FLAC streams on the
D-Link DSM-510.

Good luck! And let me know if it works/fails.

Jin

for support write to: jin at mediatomb dot cc or drop by in #mediatomb on FreeNode IRC.



Fuente
Para que sirve esto? Es algún método de conversor de vídeo más optimizado?
transcode es poder convertir ficheros .avi codificados con cualquier codec (xvid, divx, etc...) a streams mpg que pueda entender la ps3

La verdad es que es muy interesante. Ya prové el mediatomb y me funcionó a la primera, pero claro, sólo con mpg...lo intentaré!! (a no ser que pongan divx la semana que viene!)
2 respuestas