Llink:transcoding: Difference between revisions

From Lundman Wiki
mNo edit summary
No edit summary
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
<google uid="C01">Unix</google>
== Transcoding ==


[[FXP.One]] - FXP.One project, engine daemon, clients, protocol API etc.
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.


[[UFxp]] - Ultimate++ GUI client for the FXP.One engine
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''.


[[LiON]] Lundman's Input Output Library.
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''.


[[L4IP]] Software load-balancer, health-check daemon for IP Filter.
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.


[[LundFTPD]] The famous single process FTP daemon.
So, a '''TRANSCODE''' line might look something like:


[[SSL-lbnc]] FTP bnc/relay program with SSL.
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 -


[[llink]] Media Streamer for Media Players. SSDP/UPNP/HTTP
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


[[rbl-add-ip]] Perl program to modify BDBHPT driver for DLZ+named.
'''./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 -'''


[[DLZUtil]] Perl script to run a generic DLZ BDBHPT (not customised for RBL)
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.


[[TeraStation]] My own programs and hacks for the Buffalo TeraStation RAID NAS.
'''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.


[[LimHD200i]] My attempts to improve things on Tomacros HD player.
If you wish to see what ''User-Agent:'' headers your device send, use


[[NetworkedMediaTank]] My attempts to improve things on Syabas' Networked Media Tank (popcornhour etc)
./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')


[[Dune HD Center]] My attempts to improve things on HDI's media player, Dune HD Center / Dune BD Prime
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.


[[librarchy]] Interposing libc calls to add direct streaming from RAR archives.


[[ZFS_RAID|ZFS RAID]] Home build ZFS RAID running Open Solaris.
To test your own transcoding argument, I would recommend running the command line yourself, like this:


[[OsX_Spaces|OsX Spaces]] Attempting to remove the Spaces switch-transition-animation
./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


[[mediainfo-rar]] Wrote a little front-end to MediaInfo to handle content in RAR archives.
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).


[[android]] Section for Android apps and games
Then simply test-play the file "test-encode.mpg" on your device to make sure it is ok.


In my tests, I am using:


[[Tokyo]] Places to go to with kids.
ffmpeg version 0.8.4


[[Amiga!_DS_Users]] For sharing Friend Codes.
Below, insert any good transcoding options you might find.


[[Personal]] Area for personal stuff, not interesting to anyone.
=== Playstation 3 ===


'''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 -


<paypal></paypal>
'''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 -


[[Donations]] '''Hall of Fame. Seriously appreciated gifts from kind people. Feel free to click on some of the ads too.'''
=== 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=./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.
 
 
=== More here ===
 
EyeCon sends
User-Agent: Eyecon ControlPoint 2.0 | DMC/1.0
 
AcePlayer sends
Absolutely nothing :(
 
MLPlayer Lite
USER-AGENT: Darwin/11.0.0 UPnP/1.0 DLNADOC/1.50
 
PlugPlayer
USER-AGENT: iPad/4.3.2, UPnP/1.0, PlugPlayer/3.8.0
 
YXPlayer
User-Agent: Platinum/0.5.3.0, DLNADOC/1.50
 
Playstation 3
 
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

Latest revision as of 12:27, 6 October 2011

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.

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.

Playstation 3

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 -

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=./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.


More here

EyeCon sends

User-Agent: Eyecon ControlPoint 2.0 | DMC/1.0

AcePlayer sends

Absolutely nothing :(

MLPlayer Lite

USER-AGENT: Darwin/11.0.0 UPnP/1.0 DLNADOC/1.50

PlugPlayer

USER-AGENT: iPad/4.3.2, UPnP/1.0, PlugPlayer/3.8.0

YXPlayer

User-Agent: Platinum/0.5.3.0, DLNADOC/1.50

Playstation 3

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