Bulding omxplayer for Raspberry Pi


6 posts
by dom » Sat Apr 21, 2012 2:32 pm
omxplayer is the command line version of the media player used in XBMC for Raspberry Pi.

It uses a similar build environment to xbmc, so I'd suggest you to start with the same procedure for creating the nfs rootfs and installing libs on the Raspberry Pi as here:

http://www.raspberrypi.org/for.....spberry-pi

I've written the instructions to a text file, as this forum is not great for formatting/editing.

http://dl.dropbox.com/u/366951.....uild.txt 

Please post if you spot any improvements.

Note: This is slightly simpler to build than xbmc, but is still not easy, so not recommended for the beginner.

Have fun!
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4023
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by henle » Sat Apr 21, 2012 8:29 pm
Great, thanks!

What kind of documentation did you peruse to make this?
Posts: 65
Joined: Sat Apr 21, 2012 7:23 pm
by XavM » Sat Jun 23, 2012 12:28 am
@dom :

I am really sorry to bother but I get stuck for hours/days now : Could you please give me some hints.

When I run "make ffmpeg" i get the following error : bcm2708-gcc is unable to create an executable file.

Every thing looks ok regarding "bcm2708-gcc" :
which bcm2708-gcc
/usr/local/bcm-gcc/bin/bcm2708-gcc

ll /usr/local/bcm-gcc/bin/bcm2708-gcc
lrwxrwxrwx 1 mxav mxav 29 2012-06-22 15:41 /usr/local/bcm-gcc/bin/bcm2708-gcc -> arm-bcm2708-linux-gnueabi-gcc*

which arm-bcm2708-linux-gnueabi-gcc
/usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc

ll /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc
-rwxrwxr-x 1 mxav mxav 241164 2012-06-22 15:41 /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc*


But when i try to execute it :
/usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc
-bash: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc: No such file or directory


I tried with my standard login (mxav) and with root ("sudo su" and then "make ffmpeg")
Both have the same $PATH that includes bcm2708-gcc : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/bcm-gcc/bin
But they fail with this same error : "bcm2708-gcc is unable to create an executable file."
and can't execute "usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc" :
"-bash: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-gcc: No such file or directory"


I think the first parts of the instructions (xbmc build) were ok, but there must be something wrong with the way i installed the ARM compiler.

Could you please confirm that i understand it right ->

When you say :
You will need an ARM compiler. I'll assume you are using this one:
https://github.com/raspberrypi/tools/tr ... /linux-x86
(...)
On Build Machine:
sudo cp /usr/local/bcm-gcc/arm-bcm2708-linux-gnueabi/sys-root/lib/libstdc++.so.6.0.14 /opt/bcm-rootfs/usr/lib

do you mean :
git clone https://github.com/raspberrypi/tools.git
sudo cp -a ./tools/arm-bcm2708/linux-x86 /usr/local/bcm-gcc
sudo cp /usr/local/bcm-gcc/arm-bcm2708-linux-gnueabi/sys-root/lib/libstdc++.so.6.0.14 /opt/bcm-rootfs/usr/lib


When you say :
cd /usr/lib/arm-linux-gnueabi/
sudo ln -sf libyajl.so libyajl.so.1
sudo ln -sf libmicrohttpd.so libmicrohttpd.so.5
sudo ln -sf libmysqlclient.so libmysqlclient.so.16
sudo ln -sf libjpeg.so libjpeg.so.62
cd /usr/lib
sudo ln -sf libpython2.7.so libpython2.6.so.1.0

cd /usr/lib/arm-linux-gnueabi/
sudo rm libyajl.so.1
sudo rm libmicrohttpd.so.5
sudo rm libmysqlclient.so.16
sudo rm libjpeg.so.62
cd /usr/lib
sudo rm libpython2.6.so.1.0

Do you confirm it should be done on the Raspberry Pi rootfs :
"/opt/bcm-rootfs/usr/lib/arm-linux-gnueabi/" and not on "/usr/lib/arm-linux-gnueabi/" which does not exist on my Ubuntu 11.10 VM-Build-Machine ?

------

Do you confirm that the following lines preceded by a "#" must not be done ?
#cd /lib
#sudo ln -sf arm-linux-gnueabi/libgcrypt.so libgcrypt.so
#sudo ln -sf arm-linux-gnueabi/libgpg-error.so.0 libgpg-error.so.0


Do you confirm that we should stop following "xbmc build" just before executing those instructions
On build machine
# now. Need to edit tools/rbp/setup-sdk.sh and change USE_BUILDROOT=1 to USE_BUILDROOT=0

and skip to "omxplayer_build" right here :


--------

I have had a really similar problem trying to build XBMC with the following error at the step "make -C tools/rbp/depends all" :
make[2]: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++: Command not found

mxav@ubuntu:~/xbmc-rbp$ ll /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++
-rwxr-xr-x 1 mxav mxav 245260 2012-06-21 00:49 /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++*
mxav@ubuntu:~/xbmc-rbp$ /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++
bash: /usr/local/bcm-gcc/bin/arm-bcm2708-linux-gnueabi-g++: No such file or directory
Posts: 35
Joined: Thu May 31, 2012 11:29 pm
by XavM » Tue Jun 26, 2012 11:58 am
Update : I have been able to build OMXPlayer :) !!!!!!

I still don't understand why "arm-bcm2708-linux-gnueabi-g++" and "arm-bcm2708-linux-gnueabi-gcc" didn't want to play and where throwing those "No such file or directory", but after "git cloning" several times https://github.com/raspberrypi/tools.git I ended up with some working compiler.

So, I confirm dom's instructions still work with Debian Wheezy Beta;
I had to adapt Makefile.include and Makefile.ffmpeg to my conf and to include new PATH (for Wheezy ? / for the new firmwares ?)

- Makefile.include :
USE_BUILDROOT=0

ifeq ($(USE_BUILDROOT), 1)
BUILDROOT :=/opt/xbmc-bcm/buildroot
SDKSTAGE :=$(BUILDROOT)/output/staging
TARGETFS :=$(BUILDROOT)/output/target
TOOLCHAIN :=$(BUILDROOT)/output/host/usr/
HOST :=arm-unknown-linux-gnueabi
SYSROOT :=$(BUILDROOT)/output/host/usr/arm-unknown-linux-gnueabi/sysroot
else
BUILDROOT :=/opt/bcm-rootfs
SDKSTAGE :=/opt/bcm-rootfs
TARGETFS :=/opt/bcm-rootfs
TOOLCHAIN :=/home/mxav/tools/arm-bcm2708/linux-x86
HOST :=bcm2708
SYSROOT :=/home/mxav/tools/arm-bcm2708/linux-x86/arm-bcm2708-linux-gnueabi/sys-root
endif

JOBS=2

CFLAGS := -isystem$(BUILDROOT)/usr/include -isystem$(PREFIX)/include -I/home/mxav/rootfs/opt/vc/include/interface/vcos/pthreads -I/home/mxav/rootfs/usr/include/arm-linux-gnueabi
CXXFLAGS := $(CFLAGS)
CPPFLAGS := $(CFLAGS)
LDFLAGS := -L$(BUILDROOT)/lib
LD := $(TOOLCHAIN)/bin/$(HOST)-ld --sysroot=$(SYSROOT)
CC := $(TOOLCHAIN)/bin/$(HOST)-gcc --sysroot=$(SYSROOT)
CXX := $(TOOLCHAIN)/bin/$(HOST)-g++ --sysroot=$(SYSROOT)
OBJDUMP := $(TOOLCHAIN)/bin/$(HOST)-objdump
RANLIB := $(TOOLCHAIN)/bin/$(HOST)-ranlib
STRIP := $(TOOLCHAIN)/bin/$(HOST)-strip
AR := $(TOOLCHAIN)/bin/$(HOST)-ar
CXXCP := $(CXX) -E
PATH := $(PREFIX)/bin:$(BUILDROOT)/output/host/usr/bin:$(PATH)

CFLAGS += -pipe -mfloat-abi=softfp -mcpu=arm1176jzf-s -fomit-frame-pointer -mabi=aapcs-linux -mtune=arm1176jzf-s -mfpu=vfp -Wno-psabi -mno-apcs-stack-check -O3 -mstructure-size-boundary=32 -mno-sched-prolog
LDFLAGS += -L$(SDKSTAGE)/lib -L$(SDKSTAGE)/usr/lib -L$(SDKSTAGE)/opt/vc/lib/
INCLUDES += -isystem$(SDKSTAGE)/staging/usr/include -isystem$(SDKSTAGE)/staging/opt/vc/include


- Makefile.ffmpeg :
include Makefile.include

CFLAGS=-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_HAVE_SBRK -D_LARGEFILE64_SOURCE -DHAVE_CMAKE_CONFIG -DHAVE_VMCS_CONFIG -D_REENTRANT -DUSE_VCHIQ_ARM -DVCHI_BULK_ALIGN=1 -DVCHI_BULK_GRANULARITY=1 -DEGL_SERVER_DISPMANX -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D__VIDEOCORE4__ -DGRAPHICS_X_VG=1 -U_FORTIFY_SOURCE -Wall -DHAVE_OMXLIB -DUSE_EXTERNAL_FFMPEG -DHAVE_LIBAVCODEC_AVCODEC_H -DHAVE_LIBAVUTIL_MEM_H -DHAVE_LIBAVUTIL_AVUTIL_H -DHAVE_LIBAVFORMAT_AVFORMAT_H -DHAVE_LIBAVFILTER_AVFILTER_H -DOMX -DOMX_SKIP64BIT

WORK=$(PWD)

all: checkout configure compile

copy:
find ffmpeg -name '*.so*' -exec cp {} . \;
$(TOOLCHAIN)/bin/$(HOST)-strip *.so*

compile:
cd ffmpeg; \
make -j4

configure:
cd ffmpeg; \
CFLAGS="$(CFLAGS) ${INCLUDES}" \
LDFLAGS="" \
./configure \
--extra-cflags="-mfpu=vfp -mfloat-abi=softfp -mno-apcs-stack-check -mstructure-size-boundary=32 -mno-sched-prolog" \
--enable-cross-compile \
--enable-shared \
--disable-static \
--arch=arm \
--cpu=arm1176jzf-s \
--target-os=linux \
--disable-muxers \
--enable-muxer=spdif \
--enable-muxer=adts \
--disable-encoders \
--enable-encoder=ac3 \
--enable-encoder=aac \
--disable-decoder=mpeg_xvmc \
--disable-devices \
--disable-ffprobe \
--disable-ffplay \
--disable-ffserver \
--disable-ffmpeg \
--enable-shared \
--disable-doc \
--enable-postproc \
--enable-gpl \
--enable-protocol=http \
--enable-pthreads \
--disable-runtime-cpudetect \
--enable-pic \
--disable-armv5te \
--disable-neon \
--enable-armv6t2 \
--enable-armv6 \
--enable-armvfp \
--enable-hardcoded-tables \
--disable-runtime-cpudetect \
--disable-debug \
--cross-prefix=$(TOOLCHAIN)/bin/$(HOST)-

clean:
@rm -rf ffmpeg

checkout:
git clone git://git.videolan.org/ffmpeg.git ffmpeg; \
cd ffmpeg; git checkout master; git checkout 13a7bd70c8d94c5a46c14e7ac23a170b77eff52e

install:
cd ffmpeg; make -j4 DESTDIR="$(WORK)/ffmpeg_compiled" install
$(TOOLCHAIN)/bin/$(HOST)-strip ffmpeg_compiled/usr/local/lib/*.so


Feel free tu use, but adapt bold parts according to your configuration :

    - "mxav" was the Ubuntu login I used on the build machine
    - "/home/mxav/tools/" was the directory used to "git clone https://github.com/raspberrypi/tools.git"
    - "JOBS=2" I am not sure this variable is used any way (Should have been the number of concurrent cc i guess)
    - "/home/mxav/rootfs/opt/vc/include/interface/vcos/pthreads" added to CFLAGS to avoid "Error: vcos_platform_types.h: No such file or directory"
    - "/home/mxav/rootfs/usr/include/arm-linux-gnueabi" added to CFLAGS to get rid of "bits/predefs.h: No such file or directory"
    - "$(TOOLCHAIN)/bin/" added to "$(HOST)-strip" to set the full path to the utility.

If you find any big mistake <- tell me here.

------------

You can get the version I have built here : https://dl.dropbox.com/s/9hoxtq1ebrhd9t ... ist.tar.gz

This version adds "Volume control" with "+" and "-" (<- This is what I was interested in and it cost me 3 sleep less night ...) and a few other things <- See : https://github.com/huceke/omxplayer/commits/master

- Dirty install :
wget https://dl.dropbox.com/s/9hoxtq1ebrhd9t ... ist.tar.gz
tar zxvf ./omxplayer-dist.tar.gz

- Run :
LD_LIBRARY_PATH=omxplayer-dist/usr/lib/omxplayer ./omxplayer-dist/usr/usr/bin/omxplayer.bin -o hdmi ../big_buck_bunny_1080p_h264_ac3.mkv

XavM
Posts: 35
Joined: Thu May 31, 2012 11:29 pm
by lpsk » Tue Jul 03, 2012 6:50 pm
Where did you get rootfs/opt/vc/... and stuff like that. Is rootfs mounted to RPi filesystem over the network or is there a place I can download all that stuff from? The XBMC build notes are quite confusing and I'm not sure what exactly should I do and what to skip when I just want omxplayer.
Posts: 3
Joined: Tue Jul 03, 2012 5:24 pm
by XavM » Tue Jul 03, 2012 8:34 pm
Hi lpsk,

rootfs is a copy of the complet file system from the debian image.

You get it from downloading the image here : http://www.raspberrypi.org/downloads
and the following dom's instructions here : http://dl.dropbox.com/u/3669512/stable/xbmc_build.txt

You have to follow all the steps, but the part you are interested in for rootfs is :
mkdir -p ~/mnt
sudo mount -o loop,offset=80740352 sd.img ~/mnt
sudo rm -rf ~/rootfs
sudo cp -a ~/mnt ~/rootfs


Basically it means that on the (Ubuntu) build machine you should :

- Create an empty directory : mkdir -p ~/mnt
- Mount the Debian image (starting at 80740352) on this new directory : sudo mount -o loop,offset=80740352 sd.img ~/mnt
- Supress any previous rootfs directory (just in case) : sudo rm -rf ~/rootfs
- Copy the mounted image in your newly created rootfs directory : sudo cp -a ~/mnt ~/rootfs

Once this is done, just follow dom's instructions and you should be able to boot your Pi via NFS from this fresh rootfs on the Build machine.

Be careful if you are not using the Debian Squeeze image when you use "sudo mount -o loop,offset=80740352 sd.img ~/mnt"

The offset 80740352 represents the sector in the image where file system starts times the sector size : 157696*512=80740352

If you use the Debian Wheezy image, the FS layout is different and the correct offset should be 62914560 :
"sudo mount -o loop,offset=62914560 sd.img ~/mnt"

XavM
Posts: 35
Joined: Thu May 31, 2012 11:29 pm