Transcoding with llink is a relatively new features (as of llink-2.3.2) which still needs a fair bit of work. Each device will need its own settings, and tweaks.
As an example, Playstation 3 can not play .mkv files (as of 3.70 anyway). So we ask llink to change any file ending with .mkv into a different format. Since it is streaming (not writing the whole encoded file on disk before sending) what we send to the PS3 has to be a format capable of streaming. Like that of MPEG-TS. So we convert the file into a .mpg file, or rather, .mkv.mpg.
To detect that it is a PS3 that is talking to llink, and not a player that CAN handle .mkv files, we need to make some match rules. Usually, these operate on the User-Agent header in HTTP requests, or the SERVER: tag in UPNP's BrowseDirectChildren.
To define where to find the transcode binary, I have been using ffmpeg, but other programs could probably be used. In fact, one day one might be able to pass it to a "transcode -for ps3" program, wouldn't that be nice.
So, a TRANSCODE line might look something like:
TRANSCODE|USERAGENT=*playstation*|ext=*.mkv|newext=.mpg|args=./ffmpeg -d -i "%s" -threads 4 -vbsf h264_mp4toannexb -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -ac 2 -vcodec copy -async 2 -
In this case, we detect a PS3 if the User-Agent: tag contains "playstation" anywhere in it (case-insensitive). We only change files of .mkv type. We will produce new files of .mpg type. (MIME type is then based on .mpg and becomes video/mpeg.) llink will execute
./ffmpeg -d -i "http ://localhost:8001/path/to/video.mkv" -threads 4 -vbsf h264_mp4toannexb -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -ac 2 -vcodec copy -async 2 -
The important parts here is -i "%s" would specify input file, in this case llink will replace %s with the actual URL to play. Note that ffmpeg appears to be very picky with argument order. Ie, specifying -i "%s" at the end will not work.
The final minus "-" is important. It tells ffmpeg to send the stream to stdout. Which is why you have to use -f mpegts to set the output format. If you use mencoder, use -o - to send stream to stdout. mencoder generally requires the use of -really-quiet as to not to pollute stdout.
If you wish to see what User-Agent: headers your device send, use
./llink -d -v 16 [skin] checking for matching transcoders to user-agent 'Platinum/0.5.3.0, DLNADOC/1.50' [skin] matches '*latinum*' (ext '*.avi')
As far as transcoding goes, we do almost none. Video codec (h264) and audio of the .mkv file is copied without changing. We are just changing transport encapsulation from .mkv to mpeg-ts. Very low CPU in this case.
To test your own transcoding argument, I would recommend running the command line yourself, like this:
./ffmpeg -i "http ://localhost:8001/path/to/video.mkv" -threads 4 -vbsf h264_mp4toannexb -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -ac 2 -vcodec copy -async 2 - > test-encode.mpg
I removed the -d so you now get stderr output and can see any encoding errors. I keep the "-" to send to stream, and sent it to a file "> test-encode.mpg". This is to make sure you are using stream, and not doing formats that can not stream. (Like mp4).
Then simply test-play the file "test-encode.mpg" on your device to make sure it is ok.
In my tests, I am using:
ffmpeg version 0.8.4
Below, insert any good transcoding options you might find.
ffmpeg Change MKV to MPG, appears to work for Scene standard tv. Almost plays 720p for me with 4 cores. Almost.
TRANSCODE|USERAGENT=*playstation*|ext=*.mkv|newext=.mpg|args=./ffmpeg -y -i "%s" -threads 4 -vbsf h264_mp4toannexb -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -ac 2 -vcodec copy -async 2 -
mencoder Change MKV to MPG, appears to work for Scene standard tv.
TRANSCODE|USERAGENT=*|ext=*.mkv|newext=.mpg|args=./mencoder "%s" -really-quiet -oac lavc -ovc lavc -of mpeg -lavcopts vcodec=mpeg2video:keyint=1:vbitrate=200000:vrc_maxrate=9000:vrc_buf_size=1835:threads=4 -mpegopts muxrate=12000 -vf harddup -o -
Apple ipad 2
Tested with Softmedia Player Trial and Mirage.
TRANSCODE|USERAGENT=*android*|ext=*.avi|newext=.mpg|args=./ffmpeg -d -i "%s" -acodec libmp3lame -ar 48000 -ab 128k -ac 2 -s 720x480 -vcodec libx264 -b 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 3 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 1200k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -r 30 -g 90 -async 2 -f mpegts -
Almost works, plays fine for a while, but drops to 5 fps or so at times. Appears not to recover.
User-Agent: Eyecon ControlPoint 2.0 | DMC/1.0
Absolutely nothing :(
USER-AGENT: Darwin/11.0.0 UPnP/1.0 DLNADOC/1.50
USER-AGENT: iPad/4.3.2, UPnP/1.0, PlugPlayer/3.8.0
User-Agent: Platinum/0.5.3.0, DLNADOC/1.50
X-AV-Client-Info: av=5.0; cn="Sony Computer Entertainment Inc."; mn="PLAYSTATION 3"; mv="1.0"; User-Agent: UPnP/1.0 DLNADOC/1.50
Sony Bravia TV
X-AV-Client-Info: av=5.0; cn="Sony Corporation"; mn="BRAVIA KDL-46EX700/W"; mv="1.7";