Note for transcode patch

1. Options

This patch supports transcoding for both Video and Audio using mencoder/ffmpeg as transcoder.
Also other encoders can be used using shell script.

Though this patch has default parameters for mencoder and ffmpeg, it is possible to
specify other parameters using option setting in config file(minidlna.conf).

Current version supports options for 60Hz(NTSC) based system and 50Hz(PAL) based system respectively.

Example of options are described in sample "minidlna.conf".

For 60Hz(NTSC) client, it is enough to set "transcode_video_transcoder=" and
"transcode_video_mencoder_options=". It is OK to disable option for PAL as following.
transcode_video_mencoder_options_pal=DISABLE

For 50Hz(PAL) client, try to set all of 4 parameters, because most these clients support 60Hz(NTSC) also.
transcode_video_transcoder=
transcode_video_mencoder_options=
transcode_video_transcoder_pal=
transcode_video_mencoder_options_pal=

----
In option, left parameters of in the following lines are replaced with right values.

$SOURCE : source path/filename
$STARTPOSITION : start time (position) in second
$DURATION : duration in second

----
Following is an example to use shell script.

transcode_video_transcoder=./transcode.sh
transcode_video_options=$SOURCE $STARTPOSITION $DURATION


transcode.sh:
--
#!/bin/sh

SOURCE=$1
STARTPOSITION=$2
DURATION=$3
echo $0 $SOURCE $STARTPOSITION $DURATION 1>&2

#for mencoder 60Hz(NTSC)
exec mencoder -ss $STARTPOSITION -endpos $DURATION -msglevel all=-1 -really-quiet \
-oac lavc -of mpeg -mpegopts format=mpeg2:muxrate=8000:vbuf_size=1194:abuf_size=64 \
-vf scale=720:480,harddup -ovc lavc -channels 2 -lavdopts debug=0 -lavcopts \
autoaspect=1:vcodec=mpeg2video:vbitrate=8000:acodec=ac3:abitrate=128:keyint=18:vqscale=1:vqmin=2 \
-subdelay 20000 -ofps 30000/1001 -mc 0 -noskip -af lavcresample=48000 -srate 48000 \
-o - "$SOURCE"
--


----
Though it is not recomended, following also works.

transcode_video_transcoder=
transcode_video_options=/usr/bin/ffmpeg -ss $STARTPOSITION -t $DURATION -i $SOURCE -v 0 -loglevel quiet -target ntsc-dvd pipe:1


====================
2. How this patch works.
    This patch uses multiple <res> elements. It means minidlna present multiple media format for one stream.
    For example, in case source stream is H.264/AAC, minidlna presents both H.264/AAC and MPEG2/AC3.
    If a client (TV) supports only MPEG2/AC3, it select MPEG2/AC3 stream.
    All the Video stream can be transcoded to MPEG2/AC3 (DVD) stream.
    All the Audio stream can be transcoded to LPCM or MP3 stream.


Following is a response example for request of ContentDir from client:
The title for "Movie1". Following message is displayed when minidlna is executed with "-d" option.
Following is modified from actual message to be read easily.

----------
&lt;dc:title&gt;Movie1&lt;/dc:title&gt

&lt;res size="1491284170" duration="2:05:59.993" nrAudioChannels="2" resolution="480x360"
protocolInfo="http-get:*:video/avi:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000"&gt;
http://192.168.2.24:8200/MediaItems/145.avi&lt;/res&gt;

&lt;res duration="2:05:59.993" nrAudioChannels="2" resolution="720x480"
protocolInfo="http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01500000000000000000000000000000"&gt;
http://192.168.2.24:8200/MediaItems/TranscodeVideo/NTSC/145.avi&lt;/res&gt;

&lt;res duration="2:05:59.993" nrAudioChannels="2" resolution="720x576"
protocolInfo="http-get:*:video/mpeg:DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_OP=10;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=01500000000000000000000000000000"&gt;
http://192.168.2.24:8200/MediaItems/TranscodeVideo/PAL/145.avi&lt;/res&gt;
----------


====================
3. force transcoding
  Some clients do not work "multiple <res> elements".
  Some contents are not suitable for "multiple <res> elements".
  In order to force transcoding, two methods are prepared.

  1) contents(stream files) which name include "FORCETRANSCODE", <res> of original(non transcoded) is not presented.

  2) contents(stream files) which path include "FORCETRANSCODE", <res> of original(non transcoded) is not presented.
     It means, place contents in the directory under "FORCETRANSCODE", <res> of original(non transcoded) is not presented.


====================
4. SHOUTcast/icecast (internet radio, audio streaming)
  SHOUTcast/icecast (internet radio) is supported.

  Following is how to listen SHOUTcast/icecast.

  Get playlist file(s) from SHOUTcast/icecast, and put them under audio scanned directory.
  The filename is used for title name.

  Basically, streams are transcoded into LPCM or MP3.
  Transcode setting for streaming is the same as audio transcode.
  Audio transcode setting is described in sample minidlna.conf.


  Because getting stream is done by ffmpeg, many protocols are supported.
  If a service uses rtsp, just describe playlist as follows.

AudioStreaming.pls
--------------------
[playlist]
numberofentries=1
File1=rtsp://audio.streaming.service.sdp
Title1=audiostreamingservice
Length1=-1
Version=2
--------------------



AudioStreaming.m3u
--------------------
rtsp://audio.streaming.service.sdp
--------------------


====================
5. Video streaming
  Video streaming is experimentally supported. This works on some clients, 
  URL is specified using PLS or M3U playlist format file, which is usually used for audio.

  If the server URL is "rtsp://video.streaming.service.sdp", playlist should be as follows.

VideoStreaming.pls
--------------------
[playlist]
numberofentries=1
File1=NETTV-rtsp://video.streaming.service.sdp
Title1=videostreamingservice
Length1=-1
Version=2
--------------------


VideoStreaming.m3u
--------------------
NETTV-rtsp://video.streaming.service.sdp
--------------------


Put the playlist file under "audio" scanned directory.
The filename is used for title name.


Basically, streams are transcoded using ffmpeg.

If transcode setting is mencoder, transcode options for streaming is default.
If transcode setting is ffmpeg, transcode options for streaming is the same setting described in minidlna.conf file.

