Upgrade / compile ffmpeg?

DLNA, AirPlay, Chromecast, PS3, XBOX, iTunes, & other media players
moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Upgrade / compile ffmpeg?

Post by moleculezz » Mon May 02, 2011 4:24 am

Hello,

I was trying to install serviio as DLNA server, but I ran into issues with ffmpeg. I understood that some people compiled from source and others used ipkg install.
So I have a couple of questions, because I could not get it to work properly. I have a TS-459 Pro+ updated firmware 3.4.2 Build 0331T

1. Do I have to remove the supplied ffmpeg before compiling/installing new one? Or can/should I run them both?
2. Should I use ipkg or compile from source?
3. Do I have to create symlinks for the new version? And does it survive reboot?

I hope someone here can help.

Here is the process I did before, which didn't work.

Code: Select all

ipkg install nano
ipkg install yasm
ipkg install lame
ipkg install optware-devel
wget http://download.serviio.org/opensource/ffmpeg-26303.tar.gz
tar xvzf ffmpeg-26303.tar.gz
mv ffmpeg-26303 /share/MD0_DATA/.qpkg/ffmpeg
nano /share/MD0_DATA/.qpkg/ffmpeg/configure

modified line:

Code: Select all

if ! check_cmd type mktemp; then

to:

Code: Select all

if true; then

Code: Select all

./configure --arch=x86_64 --enable-ssse3 --prefix=/opt --extra-cflags='-I/opt/include' --extra-ldflags='-L/opt/lib' --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame
make
make install
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Mon May 02, 2011 11:01 pm

I compile ffmpeg a lot for my forked-daapd project. I'm doing it using a cross-compiler, but there's absolutely no reason you can't compile it natively on your machine.

First off you should not remove the mktemp call from the ./configure script. I know that the mktemp that ships with the QNAP doesn't work, but there's one available via ipkg that does work. All you should need to do is install it via ipkg and then change the bare mktemp calls to /opt/bin/mktemp. Then preface your call to configure with something like this:

Code: Select all

export PATH=/opt/bin:/opt/sbin:$PATH; ./configure ...


This will make the configure script look for for compile tools in /opt/bin and /opt/sbin before the QNAP directories.

ANSWERS:
1. You should not remove the ffmpeg in /usr/bin. serviio should have a configure option telling it where to look for ffmpeg. You should be able to point it at your ffmpeg in /opt/bin.
2. You could try the ipkg ffmpeg first and see if it works for you. It looks like the serviio guys have a specific ffmpeg source that they want you to use with their product. (I hate this because it forces people into weird setups with multiple ffmpegs installed for different programs.) You'll probably have to use the ffmpeg source that the serviio guys recommend. Too bad they just give the entire source and not the patch so you could apply it to whatever ffmpeg you wanted to use.
3. If you put it in /opt then it will survive a reboot. Of course if you already have an ffmpeg installed via ipkg you'll overwrite it when you install your ffmpeg via source.

UNSOLICITED ADVICE:
Make sure you have the headers for LAME if you're going to be enabling LAME support in ffmpeg.
Be sure that you're architecture is 64-bit since you're specifying it with --arch=x86_64. You can check with:

Code: Select all

uname -a
(Maybe you already did this.)
Where's the config.log or config.error file? If you had failures that's surely the best way to find out where you went wrong. (I suspect not giving configure a way to make temp directories was a huge reason you weren't successful.)

Hope this helps.

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Tue May 03, 2011 12:35 am

ADoko wrote:then change the bare mktemp calls to /opt/bin/mktemp. Then preface your call to configure with something like this:

Code: Select all

export PATH=/opt/bin:/opt/sbin:$PATH; ./configure ...


I'm not that familiar with Linux, so could you explain the above?

ADoko wrote:Make sure you have the headers for LAME if you're going to be enabling LAME support in ffmpeg.

Don't know how to set the headers for lame. Don't really know what it means either.

ADoko wrote:Be sure that you're architecture is 64-bit since you're specifying it with --arch=x86_64. You can check with:

Code: Select all

uname -a
(Maybe you already did this.)

I just checked using uname -a and got the following:

Code: Select all

Linux nas 2.6.33.2 #1 SMP Thu Mar 31 00:13:21 CST 2011 i686 unknown

Not sure what this means
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Tue May 03, 2011 1:40 am

So I gave a bit of wrong advice above. You shouldn't need to modify the ./configure script if you use the export command like I showed. Eg:

Code: Select all

export PATH=/opt/bin:/opt/sbin:$PATH; ./configure --arch=x86_64 --enable-ssse3 --prefix=/opt --extra-cflags='-I/opt/include' --extra-ldflags='-L/opt/lib' --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame


In Linux and unix in general there is the concept of an environment variable. These variables have information in them and they are accessible by the shell (in QNAP's case a variant of the Bourne-Again Shell aka "bash"). One of these variables is the PATH variable. When you type a command in linux the shell searches a the list of directories in the PATH variable in the order they are specified. (Actually it searches the current working first and then the PATH.) So the code I showed you above sets the /opt/bin and /opt/sbin directories to be first in your path. However it only does it for the ./configure command immediately following it. (Notice the semi-colon in between the export command and the ./configure.) The means that the ./configure command will have /opt/bin and /opt/sbin first in its path when it executes. This is important because this means the ./configure script will find and use the mktemp program in /opt/bin BEFORE it finds the QNAP version of mktemp in /usr/bin.

When you compile C/C++ and your are linking against an external library like LAME you need to provide the compiler with a path to that library's header file. A library is merely a collection of functions that are bundled together with an index. The compiler needs the header file so it can know the parameter count, parameter types and return type of the function. Since you want to link against the LAME library you need to also give the compiler the location of the LAME header file(s). Typically if you installed lame in /opt/bin then the headers for it should be in /opt/include. I don't remember how ipkg does things, but some distributions of linux bundle the library in one package and the headers in a another "-dev" pacakge. This is to save space as only people compiling against the library will ever need the headers.

Usually you'll see something in the string returned from uname -a that tells you that you're on 64bit linux. I don't see that. I wasn't aware of any QNAP shipping with 64 bit linux, but then again, I haven't been checking. I'd suggest compiling for a 32 bit architecture and see if that works. There's no harm in running a 32bit app on a 64bit OS.

maurice1
Getting the hang of things
Posts: 56
Joined: Tue Oct 13, 2009 8:34 pm
Location: Ireland

Re: Upgrade / compile ffmpeg?

Post by maurice1 » Wed May 04, 2011 7:13 am

interesting reply, thank you

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Wed May 04, 2011 10:27 pm

Ok... So I tried to implement what you adviced.
I did a little searching and found out that i686 is actually 32bit. So I fixed that.

Code: Select all

ipkg install mktemp
export PATH=/opt/bin:/opt/sbin:$PATH; ./configure --arch=x86 --enable-ssse3 --prefix=/opt --extra-cflags='-I/opt/include' --extra-ldflags='-L/opt/lib' --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame


Also, thanks for the mktemp tip. That also fixed the issue I had before. I was wondering though, do I have to export the path everytime I reboot the system, or was that a one time thing?

So now I think that it is setup correctly, I am still having issues with serviio. I get error code 1. From the serviio forums they say that the user running serviio might not have permissions to execute ffmpeg. But don't quite understand how that can be since I did everything using the admin.
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Thu May 05, 2011 1:35 am

Exporting the PATH was only for the ./configure command. This is a temporary way to work around the PATH not being in the order you want. You can make the changes to the path permanent, but I wouldn't advise doing that. It can have unintended consequences. It's best to leave the path the way that QNAP sets it up.

I'd be surprised if it's a user permissions issue on QNAP. QNAP is pretty old school and most services run as admin (which is technically root). What you can do is look at the serviio process using:

Code: Select all

ps -waux | grep -i serviio

This will tell you who the process is running as.

Then you can also look at your ffmpeg and make sure that it can be run:

Code: Select all

ls -rlt /opt/bin/ffmpeg


You should see:

Code: Select all

-rwxr-xr-x    1 admin    administ   100788 May  2 20:24 /opt/bin/ffmpeg*


The "rwx" is for read/write/execute. The first three are for the owner of the file. The second is for members the group and the third is for "others" (which are neither the owner or members of the group). In this case the file can be read/written/executed by the owner. It can be read and executed by members of the group and by anyone else.

The "admin" and "adminst" are the owner and the group. ("administ" is actually truncated and is really "administrators".)

If you don't see that it's owned by admin then you'll need to do this:

Code: Select all

chown admin:administrators /opt/bin/ffmpeg


If you don't see that it has execute permissions you'll need to do this:

Code: Select all

chmod 755 /opt/bin/ffmpeg


It's also possible that you're serviio isn't pointed at the ffmpeg in your /opt/bin directory. You'll need to find the configuration file and make sure that serviio knows where to find ffmpeg.

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Thu May 05, 2011 2:45 am

These are my results... everything seems fine.

Code: Select all

[/] # ps -waux | grep -i serviio
29269 admin      1216 S   /bin/sh /share/MD0_DATA/.qpkg/serviio/bin/serviio.sh start
29274 admin     48372 S   /usr/local/jre/bin/java -Xmx384M -Djava.net.preferIPv4Stack=true -Dderby.system.home=/share/MD0_DATA/.qpkg/serviio/
29411 admin       572 R   grep -i serviio
[/] # ls -rlt /share/MD0_DATA/.qpkg/ffmpeg/ffmpeg
-rwxr-xr-x    1 admin    administ  6397352 May  3 21:53 /share/MD0_DATA/.qpkg/ffmpeg/ffmpeg*


ADoko wrote:It's also possible that you're serviio isn't pointed at the ffmpeg in your /opt/bin directory. You'll need to find the configuration file and make sure that serviio knows where to find ffmpeg.

I compiled ffmpeg in /share/MD0_DATA/.qpkg/ffmpeg folder.
I used the following in the serviio.sh to point to the compiled ffmpeg. Someone in the serviio forums added "-Dffmpeg.location" to the JAVA_OPTS variable, not sure if it is correct though.
Is it possible to figure out which version serviio is using for sure?

Code: Select all

JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Dderby.system.home=$SERVIIO_HOME/library -Dserviio.home=$SERVIIO_HOME -Dserviio.remoteHost=192.168.2.150 -Dffmpeg.location=/share/MD0_DATA/.qpkg/ffmpeg/ffmpeg"
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Thu May 05, 2011 3:02 am

What does this command return?

Code: Select all

ldd /share/MD0_DATA/.qpkg/ffmpeg/ffmpeg

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Thu May 05, 2011 3:18 am

ADoko wrote:What does this command return?

Code: Select all

ldd /share/MD0_DATA/.qpkg/ffmpeg/ffmpeg


Code: Select all

 # ldd /share/MD0_DATA/.qpkg/ffmpeg/ffmpeg
        linux-gate.so.1 =>  (0xb77a6000)
        libmp3lame.so.0 => /usr/lib/libmp3lame.so.0 (0xb7726000)
        libm.so.6 => /lib/libm.so.6 (0xb7701000)
        libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0xb76f1000)
        libz.so.1 => /lib/libz.so.1 (0xb76db000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xb76c4000)
        libc.so.6 => /lib/libc.so.6 (0xb7590000)
        /lib/ld-linux.so.2 (0xb77a7000)
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Thu May 05, 2011 3:34 am

Okay, it looks like it linked fine. Can you execute it?

Code: Select all

share/MD0_DATA/.qpkg/ffmpeg/ffmpeg -version


BTW, this is my last sanity check. If this works then it's looking more like a serviio configuration issue.

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Thu May 05, 2011 4:10 am

ADoko wrote:Okay, it looks like it linked fine. Can you execute it?

Code: Select all

share/MD0_DATA/.qpkg/ffmpeg/ffmpeg -version


BTW, this is my last sanity check. If this works then it's looking more like a serviio configuration issue.


Code: Select all

/share/MD0_DATA/.qpkg/ffmpeg/ffmpeg -version
FFmpeg version UNKNOWN, Copyright (c) 2000-2011 the FFmpeg developers
  built on May  3 2011 21:53:02 with gcc 4.2.1
  configuration: --arch=x86 --enable-ssse3 --prefix=/opt --extra-cflags=-I/opt/include --extra-ldflags=-L/opt/lib --enable-s                      tatic --disable-shared --disable-ffplay --disable-ffserver --enable-libmp3lame
  libavutil     50.36. 0 / 50.36. 0
  libavcore      0.16. 0 /  0.16. 0
  libavcodec    52.108. 0 / 52.108. 0
  libavformat   52.92. 0 / 52.92. 0
  libavdevice   52. 2. 3 / 52. 2. 3
  libavfilter    1.72. 0 /  1.72. 0
  libswscale     0.12. 0 /  0.12. 0
FFmpeg UNKNOWN
libavutil     50.36. 0 / 50.36. 0
libavcore      0.16. 0 /  0.16. 0
libavcodec    52.108. 0 / 52.108. 0
libavformat   52.92. 0 / 52.92. 0
libavdevice   52. 2. 3 / 52. 2. 3
libavfilter    1.72. 0 /  1.72. 0
libswscale     0.12. 0 /  0.12. 0


Man, this is driving me nuts, been wanting to have the NAS running serviio for a couple of weeks now.
TS-459 Pro+ || TS-419P II

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Thu May 05, 2011 4:23 am

Well at this point it looks like ffmpeg is in working order. The only advice I can offer is to see if you can turn on as much logging as possible in serviio. That way you might be able to comb through the log files and see if there are any messages that give a better clue as to why ffmpeg isn't working.

EDIT
Actually here's a piece of advice:

Looking at this page:
http://forum.serviio.org/viewtopic.php?f=5&t=1241

I see that serviio at least tells you the command it tried to send to ffmpeg. You should try command from your log yourself and see what is the output from ffmpeg.

EDIT2
Or do what the response in the thread suggests.

User avatar
ADoko
Easy as a breeze
Posts: 270
Joined: Wed Dec 01, 2010 1:08 am

Re: Upgrade / compile ffmpeg?

Post by ADoko » Thu May 05, 2011 4:32 am

More info for you (after I saw your post on the serviio forums):

http://stackoverflow.com/questions/3774 ... -permitted

https://roundup.libav.org/issue807

In short... the ffmpeg that serviio uses has a bug. They should upgrade their version or at least provide a patch. The patches are freely available in the second link so there's no excuse.

moleculezz
Know my way around
Posts: 108
Joined: Sat Nov 21, 2009 5:56 am

Re: Upgrade / compile ffmpeg?

Post by moleculezz » Thu May 05, 2011 5:11 am

ADoko wrote:More info for you (after I saw your post on the serviio forums):

http://stackoverflow.com/questions/3774 ... -permitted

https://roundup.libav.org/issue807

In short... the ffmpeg that serviio uses has a bug. They should upgrade their version or at least provide a patch. The patches are freely available in the second link so there's no excuse.


Thanks for all the help, I'm very greatfull for your help.
So I guess my next move is to compile the latest ffmpeg and retry. Will try that and report back.

Also after trying to stream a movie using serviio I get a lot of these in the system logs:

Code: Select all

The system is unable to save your settings (file = [/etc/storage.conf], section = [VOLUME 3], field = [status], value = [0]) due to insufficient ramdisk space. If restarting the server does not solve the problem please contact support for further assistance.
TS-459 Pro+ || TS-419P II

Post Reply

Return to “Media Streaming”