Llink:transcoding

From Lundman Wiki
Revision as of 08:27, 29 September 2011 by Lundman (talk | contribs)

Transcoding

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.

TRANSCODE|FFMPEG=./ffmpeg

So, a TRANSCODE line might look something like:

TRANSCODE|SERVER=*playstation*|ext=*.mkv|newext=.mpg|args=-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 SERVER: 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 -

As you can see, llink will add "-d -i $url" to the start, and " - " to the end, when it executes ffmpeg. (FIXME, what if users want to run something other than ffmpeg?, let users use -i %s for input).

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.


Below, insert any good transcoding options you might find.

Playstation 3

Change MKV to MPG, appears to work for Scene standard tv.

TRANSCODE|SERVER=*playstation*|ext=*.mkv|newext=.mpg|args=-threads 4 -vbsf h264_mp4toannexb -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -ac 2 -vcodec copy -async 2


XBox 360

Apple ipad

Apple ipad 2

Apple iphone

Google Android

Tested with Softmedia Player Trial and Mirage.

TRANSCODE|USERAGENT=*android*|ext=*.avi|newext=.mpg|args=-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.


More here