NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

miip's avatar
miip
Aspirant
Jan 10, 2012

How-to: cross-compile ffmpeg for readynas sparc

Since I really needed ffmpeg I cross-compiled it myself. I didn't do a proper deb, I just used the upstream sources and hacked until it worked. You may follow these instructions to achieve the same:


cross-compile ffmpeg for ReadyNAS NV+ (SPARC) pseudo how-to
v0.01 (2012-01-10)

Because I couldn't find ffmpeg for the ReadyNAS Sparc, I had to figure out how to compile it. I am not an experienced programmer, that's why these instructions are by far not perfect and I do not know a lot better. In addition, I tried several ways and I didn't start over just to test these instructions; therefore there might be some steps missing or not working. If you work through, please add any corrections in comments.

Overview:
- install a sarge chroot
- get the chroot ready
- add the readynas cross-compiler
- get the ffmpeg sources and edit ./configure
- compile
- transfer and install


Details:
Get your hands on a Debian installation. This can be a real or a virtual machine, I think it is mandatory to have a x86 architecture for the ReadyNAS cross-compiler.

1) install a sarge chroot
-------------------------
- Install debootstrap and chroot with:
	apt-get install debootstrap coreutils

- Make a new directory "debian-sarge-cross-chroot":
	mkdir debian-sarge-cross-chroot

- Install Debian in this directory:
	debootstrap --arch i386 sarge debian-sarge-cross-chroot http://archive.debian.org/debian

- Enter the chroot:
	chroot debian-sarge-cross-chroot


2) get the chroot ready
-----------------------
- Edit the package sources:
	nano /etc/apt/sources.list

...and add sarge-backports to list of sources:
	deb-src http://archive.debian.org/debian sarge main contrib non-free

deb http://archive.debian.org/backports.org sarge-backports main contrib non-free
deb-src http://archive.debian.org/backports.org sarge-backports main contrib non-free

(Do not delete the existing line, just add the above lines.)
...save and exit nano (CTRL-X).

- Install some packages:
	apt-get update
apt-get install build-essential less locales wget
apt-get -t sarge-backports install make texi2html

- Add "LC_ALL=en_US.UTF-8" to /etc/environment if nothing for LC_ALL is there.

- Exit and reenter the chroot:
	exit
chroot debian-sarge-cross-chroot


3) add the readynas cross-compiler to your chroot
-------------------------------------------------
- Get the ReadyNAS cross-compiler:
	cd /root
wget http://www.readynas.com/download/development/readynas-cross-3.3.5.tar.gz

- Upack:
	cd /
tar -xvvzf root/readynas-cross-3.3.5.tar.gz

- Since I do not know how to tell ffmpeg to use the right compiler, I cheated like this:
	cd /usr/bin
mkdir x86
for prg in `which $(ls -1 /usr/bin/sparc-linux-* | sed -e "s%^/usr/bin/sparc-linux-%%g")`; do mv -v "$prg" x86/. ; done
for prg in $(ls -1 sparc-linux-* | sed -e "s%^sparc-linux-%%g"); do ln -vs "sparc-linux-$prg" "$prg" ; done

... this moves the original compiler files away and links the sparc-cross-compiler ones in place. Check the result:
	ls -la | grep sparc
resp.
	gcc --version
...should reveal "gcc (GCC) 3.3.5 (Infrant 3.3.5-1)"
(You may undo this with: cd /usr/bin ; for prg in $(ls -1 sparc-linux-* | sed -e "s%^sparc-linux-%%g"); do rm -v "$prg" ; done)


4) get the ffmpeg sources and edit ./configure
----------------------------------------------
- You can't use wget to get the sources. Point your browser to
http://git.videolan.org/?p=ffmpeg.git;a=snapshot;h=HEAD;sf=tgz
and download the file. Transfer it inside your chroot folder
debian-sarge-cross-chroot/usr/src

- Get back into your terminal and change to that location:
	cd /usr/src
- Unpack:
	tar -xvvzf ffmpeg-HEAD-dd3ca3ea.tar.gz 
(Your download might be newer and thus named differently.)

- Enter the newly created directory:
	cd ffmpeg-HEAD-dd3ca3ea

- Unfortunately the configure script compiles for ultrasparc instead of v8 if given the architecture sparc.
I hacked the configure script to not do this. It is not the correct way I did it, but it works.
Create the patch file:
	nano configure.diff

Add the following lines:
--- configure.orig      2012-01-10 02:50:41.000000000 +0000
+++ configure 2012-01-10 13:41:38.519916764 +0000
@@ -2448,6 +2448,12 @@
sparc64)
cpuflags="-mcpu=v9"
;;
+ v7)
+ cpuflags="-mcpu=v7"
+ ;;
+ v8)
+ cpuflags="-mcpu=v8"
+ ;;
esac

elif enabled arm; then
@@ -2891,7 +2897,7 @@
elif enabled sparc; then

enabled vis && check_asm vis '"pdist %f0, %f0, %f0"' -mcpu=ultrasparc &&
- add_cflags -mcpu=ultrasparc -mtune=ultrasparc
+ add_cflags -mcpu=v8 -mtune=v8

elif enabled x86; then



- Save and exit nano (CTRL-X).

- Apply the patch:
	patch -p0 configure configure.diff


5) compile
----------
- Run the configure script:
	./configure --logfile=./build.log --prefix=/usr/local/lib/ffmpeg --arch=sparc --cpu=v8 --disable-vis  --target-os=linux --enable-cross-compile

- Run make:
	make
...wait and then run:
	make install
You will find your newly compiled ffmpeg in /usr/local/lib/ffmpeg.

- Build an archive of your compilation:
	tar -cvvzf /usr/src/ffmpeg-HEAD-dd3ca3ea-sparcv8.tar.gz /usr/local/lib/ffmpeg
cd ..


6) transfer and install
-----------------------
- Tarnsfer your archive file to your ReadyNAS:
	scp ffmpeg-HEAD-dd3ca3ea-sparcv8.tar.gz myreadynas:/root

- SSH into your ReadyNAS and install:
	cd /
tar -xvvzf root/ffmpeg-HEAD-dd3ca3ea-sparcv8.tar.gz

- Put a link in /usr/local/bin for all executables:
	cd /usr/local/bin
ln -s ../lib/ffmpeg/bin/*


That's it. *sigh*

Good luck, Adrian Zaugg.


You can download these instructions from http://ente.limmat.ch/ftp/pub/readynas/ffmpeg/README
where you also find the tar archive.

v0.01 (2012-01-10)

1 Reply

Replies have been turned off for this discussion
  • Just to say, I also recently cross-compiled ffmpeg for my sparc ReadyNas Duo. If someone is looking for a snapshot version that compiles and runs on 4.1.7, I used version 0.10.2. I ran:

    ./configure --arch=sparc --enable-cross-compile --cross-prefix=sparc-linux- --cpu=v8 --target-os=linux
    make

    I also made the CPU edit in the configure script referred to above in order to support the v8 processer, though the line numbers were of course different. In addition, I also added "disable vis" in the same place (this is a v9 instruction set):

    case $cpu in
    niagara|v8|v7)
    cpuflags="-mcpu=$cpu"
    disable vis
    ;;
    sparc64)
    cpuflags="-mcpu=v9"
    ;;
    esac

    There is no need to symlink the cross-compiler tools, the configure script should pick them up automatically with the above arguments. You can check the architecture of the built binary following "make" using "file".

    I have now set up a cron job to automatically remux MKVs to MP4s (well, M4V actually) so they can be streamed to my PS3:
    ffmpeg -loglevel error -i foo.mkv -vcodec copy -acodec copy foo.m4v
    Seems to work! I find MP4 the best format for HD videos without subtitles, as contrary to popular belief they -do- now support AC3 audio tracks, so no re-encoding required.

    (To go off on a tangent:, the "niagara"" section was already in the configure script in 0,10.2, though I was surprised to see "disable vis" here since I thought niagara did support v9 instruction sets. Probably something to do with the compiler.)

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More