Llink:sources: Difference between revisions

From Lundman Wiki
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Transcoding ==
== Compiling Instructions ==


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.
When compiling llink you need to chose if you want to use '''OpenSSL''', '''libdvdread''' and '''libdvdcss'''. Generally we have no reason to use SSL with '''link''' so I will skip this compile time step.


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''.
=== Unix, OsX and other native compiles ===


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.
The default should work.


So, a '''TRANSCODE''' line might look something like:
# ./configure --without-openssl
# make
# file src/llink


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 -
The '''file''' command is not necessary, but it shows you where we expect the binary to end up.


In this case, we detect a PS3 if the ''User-Agent:'' tag contains "playstation" anywhere in it (case-insensitive).
# ./configure --without-openssl
We only change files of ''.mkv'' type.
# make
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 -'''
If you want to build libdvdcss in statically (so there is just one binary, no shared library dependencies)


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.
# cd libdvdcss-1.2.10
# ./configure --enable-static
# make
# cd ../
# cd llink-2.2.0
# ./configure --without-openssl --with-dvdcss-tree=`pwd`/../libdvdcss-1.2.10/
# make


'''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.''' Note that stderr would end up in the stream too, so with ffmpeg we use '''-d''' to make it completely silent.
=== Windows ===


If you wish to see what ''User-Agent:'' headers your device send, use
Download Visual Devstudio C++ 2010 from [http://msdn.microsoft.com/en-us/vstudio/dd582936.aspx Microsoft] and install.


./llink -d -v 16
Download the OpenSSL for Windows '''dev''' package. [http://www.slproweb.com/products/Win32OpenSSL.html]  Install it, usually at C:/OpenSSL but you can pick any place.  
[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.
Setup a new Environment Variable, usually done in "My Computer / Properties / Advanced / Environment Variables". Create a new variable called '''SSL''', and set it to the location of your OpenSSL install. Ie, '''C:/OpenSSL/'''.


Download source package, and load the '''llink.vcproj''' inside "win32/" directory. Change the default project from '''libdirlist''' to '''llink''' and hit compile.


To test your own transcoding argument, I would recommend running the command line yourself, like this:
All file paths '''should''' be relative, but sometimes they are not :(


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


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).
For example when compiling for the PCH A-100, you download the toolchain that applies to your arch. In this case, it installs into '''/usr/local/mips/''' with a '''gcc''' binary named as '''/usr/local/mips/bin/mipsel-linux-gcc'''.


Then simply test-play the file "test-encode.mpg" on your device to make sure it is ok.
First make sure your PATH is updated so that it can find the executable.


In my tests, I am using:
# export PATH=$PATH:/usr/local/mips/bin/
# which mipsel-linux-gcc
/usr/local/mips/bin/mipsel-linux-gcc


ffmpeg version 0.8.4
Great. If you want to have '''libdvdcss''' we need to compile that first. If you do not, you can skip this step.


Below, insert any good transcoding options you might find.
# cd src/libdvdcss-1.2.10/
# ./configure --host=mipsel-linux-uclibc --enable-static
# make
# file src/.libs/libdvdcss.*
src/.libs/libdvdcss.a:        current ar archive
src/.libs/libdvdcss.so.2.0.8: ELF 32-bit LSB shared object, MIPS, version 1 (SYSV), not stripped
(a few other files, but at least one shows its compiled as MIPS)


=== Playstation 3 ===


Change MKV to MPG, appears to work for Scene standard tv.
Note that we have to use the full path '''/home/lundman/src/''' to get to the '''libdvdcss-1.2.10/src''' includes.  
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 -


'''Compiling llink'''. Now it is time to compile '''llink''' itself. The version number might change of course.


=== XBox 360 ===
# cd src/llink-2.2.0/
# ./configure --host=mipsel-linux --enable-static --without-openssl  --with-dvdcss-tree=/home/lundman/src/libdvdcss-1.2.10/
# make
# file src/llink
src/llink: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), statically linked, not stripped


Naturally, if you do not want '''libdvdcss''' go with the shorter line:


=== Apple ipad ===
# ./configure --host=mipsel-linux --enable-static --without-openssl
# make


=== Known Compiling Issues ===


=== Apple ipad 2 ===
The main binary is linked against '''libdvdcss''' if requested, even though it need not be. You can omit "-ldvdcss" on the linking line of llink if it affects you.


On C200, if you compile -static, it will product the error:


=== Apple iphone ===
../sysdeps/unix/sysv/linux/ia64/getpagesize.c:35: __getpagesize: Assertion `_rtld_global_ro._dl_pagesize != 0' failed.


So don't compile statically on C200.


=== Google Android ===
Some systems get:
: undefined reference to `pthread_mutex_init'


Tested with ''Softmedia Player Trial'' and ''Mirage''.
and similar errors, change directory into the '''undvd''' directory, and copy'paste the final linking line and add "-lpthread" to it. This will be fixed in future.


  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 -
On ReadyNAS, it will appear to hang after:
Almost works, plays fine for a while, but drops to 5 fps or so at times. Appears not to recover.
  [root] listing '/c/media/' with flags 11


 
This is actually the 2nd process libdirlist core-dumping, in the call to getpwnam(). If llink is compiled statically. Please drop the -static.
=== 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

Latest revision as of 06:30, 12 July 2012

Compiling Instructions

When compiling llink you need to chose if you want to use OpenSSL, libdvdread and libdvdcss. Generally we have no reason to use SSL with link so I will skip this compile time step.


Unix, OsX and other native compiles

The default should work.

# ./configure --without-openssl
# make
# file src/llink

The file command is not necessary, but it shows you where we expect the binary to end up.

# ./configure --without-openssl 
# make

If you want to build libdvdcss in statically (so there is just one binary, no shared library dependencies)

# cd libdvdcss-1.2.10
# ./configure --enable-static
# make
# cd ../
# cd llink-2.2.0
# ./configure --without-openssl --with-dvdcss-tree=`pwd`/../libdvdcss-1.2.10/
# make

Windows

Download Visual Devstudio C++ 2010 from Microsoft and install.

Download the OpenSSL for Windows dev package. [1] Install it, usually at C:/OpenSSL but you can pick any place.

Setup a new Environment Variable, usually done in "My Computer / Properties / Advanced / Environment Variables". Create a new variable called SSL, and set it to the location of your OpenSSL install. Ie, C:/OpenSSL/.

Download source package, and load the llink.vcproj inside "win32/" directory. Change the default project from libdirlist to llink and hit compile.

All file paths should be relative, but sometimes they are not :(

Cross Compile

For example when compiling for the PCH A-100, you download the toolchain that applies to your arch. In this case, it installs into /usr/local/mips/ with a gcc binary named as /usr/local/mips/bin/mipsel-linux-gcc.

First make sure your PATH is updated so that it can find the executable.

# export PATH=$PATH:/usr/local/mips/bin/
# which mipsel-linux-gcc
/usr/local/mips/bin/mipsel-linux-gcc

Great. If you want to have libdvdcss we need to compile that first. If you do not, you can skip this step.

# cd src/libdvdcss-1.2.10/
# ./configure --host=mipsel-linux-uclibc --enable-static
# make
# file src/.libs/libdvdcss.*
src/.libs/libdvdcss.a:        current ar archive
src/.libs/libdvdcss.so.2.0.8: ELF 32-bit LSB shared object, MIPS, version 1 (SYSV), not stripped
(a few other files, but at least one shows its compiled as MIPS)


Note that we have to use the full path /home/lundman/src/ to get to the libdvdcss-1.2.10/src includes.

Compiling llink. Now it is time to compile llink itself. The version number might change of course.

# cd src/llink-2.2.0/
# ./configure --host=mipsel-linux --enable-static --without-openssl  --with-dvdcss-tree=/home/lundman/src/libdvdcss-1.2.10/
# make
# file src/llink
src/llink: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), statically linked, not stripped

Naturally, if you do not want libdvdcss go with the shorter line:

# ./configure --host=mipsel-linux --enable-static --without-openssl
# make

Known Compiling Issues

The main binary is linked against libdvdcss if requested, even though it need not be. You can omit "-ldvdcss" on the linking line of llink if it affects you.

On C200, if you compile -static, it will product the error:

../sysdeps/unix/sysv/linux/ia64/getpagesize.c:35: __getpagesize: Assertion `_rtld_global_ro._dl_pagesize != 0' failed.

So don't compile statically on C200.

Some systems get:

: undefined reference to `pthread_mutex_init'

and similar errors, change directory into the undvd directory, and copy'paste the final linking line and add "-lpthread" to it. This will be fixed in future.

On ReadyNAS, it will appear to hang after:

[root] listing '/c/media/' with flags 11

This is actually the 2nd process libdirlist core-dumping, in the call to getpwnam(). If llink is compiled statically. Please drop the -static.