Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Retired
Posts: 35
Registered: ‎10-15-2013
My Device: BlackBerry Z30
My Carrier: O2 UK

Porting libraries - ffmpeg

[ Edited ]

Library name: libffmpeg

Website: http://www.ffmpeg.org/

Source code: https://github.com/FFmpeg/FFmpeg (this is a mirror, the master repository git://source.ffmpeg.org/ffmpeg.git is very slow)

Specific commit SHA built: 

dc6a17cf74a90e41d70ea1753cdb70c0a5b2ced8

Build system: autotools

Dependencies: libx264 (optional - see below)

Build environment: OSX 10.9.2, XCode 5.1.1, BlackBerry SDK 10.2.0, GNU Make 3.82, 

QNX_HOST=/Applications/Momentics.app/host_10_2_0_15/darwin/x86, QNX_TARGET=/Applications/Momentics.app/target_10_2_0_1155/qnx6

 

 

ffmpeg is a flexible library with a large number of configuration options. You may need to tailor the configure flags to your specific requirements. In my configuration I'm building ffmpeg as a shared library with x264 support. x264 should be built already in a folder at the same level as ffmpeg and according to the instructions here.

 

First, make sure your environment is configured for command line development, and that you have autotools installed.

 

Configuring for QNX ARM (for devices)

 

./configure --enable-cross-compile --cross-prefix=arm-unknown-nto-qnx8.0.0eabi- --target-os=qnx --arch=armv7 --disable-debug --enable-optimizations --enable-asm --disable-static --enable-shared --disable-ffplay --disable-ffserver --disable-ffprobe --prefix=`pwd`/build/arm-qnx/release --enable-memalign-hack --enable-gpl --enable-libx264 --extra-cflags=-I`pwd`/../x264/build/arm-qnx/release/include --extra-ldflags=-L`pwd`/../x264/build/arm-qnx/release/lib 

 

Configuring for QNX x86 (for simulator)

 

./configure --enable-cross-compile --cross-prefix=i486-pc-nto-qnx8.0.0- --target-os=qnx --arch=x86 --enable-debug --enable-optimizations --enable-asm --disable-static --enable-shared --disable-ffplay --disable-ffserver --disable-ffprobe --prefix=`pwd`/build/x86-qnx/debug --enable-memalign-hack --enable-gpl --enable-libx264 --extra-cflags=-I`pwd`/../x264/build/x86-qnx/debug/include --extra-ldflags=-L`pwd`/../x264/build/x86-qnx/debug/lib 

 

Configure flags explained

Here's what the most important configure flags do. For more information on available flags run:

 

configure --help

 

--enable-cross-compile. This specifies that we're using a cross-compiler (ie the architecture the library will run on is different to the one we're building on)

--cross-prefix. This identifies the prefix which should be used when calling the build tools. For example, instead of calling gcc, we'll call arm-unknown-nto-qnx8.0.0eabi-gcc.

--target-os. This is used by the configure script to determine which host operating system we're building for. In this case the important part is: qnx. In configure you'll find a switch statement which matches *qnx* and sets up the build accordingly. 

-arch. This specifies the target architecture, in our case this is either armv7le (ARM version 7 Little Endian) for physical devices or x86 for the simulator.

--enable-shared. Build a shared library. Also possible to create a static library using --enable-static

--enable-memalign-hack. Without this ffmpeg will crash when opening H264 input formats. See http://stackoverflow.com/questions/18384687/malloc-check-failed-when-opening-video-stream for more.

--prefix. Specifies the installation directory for the libraries, headers and executables. I use the convention "build/<qnx_variant>/<build_type>" where qnx_variant can be arm-qnx or x86-qnx and build_type can be release or debug

 

Things to watch out for

When you run configure you might get some output like this: 

 

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

On OSX this output is generated by gcc. You might be wondering why configure is executing the host gcc and not the QNX version. The reason is that ffmpeg compiles and uses some tools which are executed on the host operating system (I think mainly to create documentation). You can override the host cc executable using the --host-cc flag but you shouldn't need to.

 

Building

 

make -j8
make install

Note: the -j flag simply specifies the number of cores I want to use during compilation. It can dramatically decrease build times.

 

Output

Because I used the --prefix flag the library and header files will be installed under build/<qnx_variant>/<build_type>

 

Special thanks to Martin Reed for his work on https://github.com/MartinMReed/libffbb which was a great help to me in porting this library.

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: Porting libraries - ffmpeg

[ Edited ]

I got an error when compiling with x264 because in your tutorial for compiling x264 you use --disable-shared so they are statically compiled. In these two command lines, you compile ffmpeg shared. Either you should compile both shared or both static, not a combination of the two.

 

When compiling x264 shared and ffmpeg shared it worked as it should.

 

After I compiled the libraries, editted the bar-descripter and all the other files (base on the documentation at https://github.com/MartinMReed/libffbb) I have the following errors:

 

../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_init@LIBSWRESAMPLE_0'
../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_close@LIBSWRESAMPLE_0'
../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_is_initialized@LIBSWRESAMPLE_0'
../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_free@LIBSWRESAMPLE_0'
../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_alloc@LIBSWRESAMPLE_0'
../ffmpeg/lib/armle-v7/libavcodec.so: undefined reference to `swr_convert@LIBSWRESAMPLE_0'

 Any idea what the problem can be?

______________________________________________________
BB10-OAuth: GitHub
Retired
Posts: 35
Registered: ‎10-15-2013
My Device: BlackBerry Z30
My Carrier: O2 UK

Re: Porting libraries - ffmpeg

[ Edited ]

Are those errors occurring at compile-time or at run-time? I'm guessing run-time.

 

In which case it means that you haven't included libswresample.so in your list of assets to be deployed in bar-descriptor.xml.

 

I take your point about compiling static or shared but this is easily configured using the --enable-shared flag.  

Developer
Posts: 230
Registered: ‎01-12-2013
My Device: z30
My Carrier: Mobile Vikings

Re: Porting libraries - ffmpeg

[ Edited ]

Hey Don

 

Thanks. I will have a look at it this evening. Is the libswresample.so outputted in the libs folder after the make command got executed? Not at my home computer at the moment.

 

The remark regarding the static/shared was just for others that will try to compile it in the future Smiley Happy. Is it better to compile static or shared? Or isn't their an advantage between the two?

 

Thanks!

 

[EDIT]

After adding this to the bar-descriptor.xml

<asset path="ffmpeg/lib/armle-v7/libswresample.so.0">lib/libswresample.so.0</asset>

 

 

And adding

-lswresample

 

to the .pro file it works!!!

______________________________________________________
BB10-OAuth: GitHub
Retired
Posts: 35
Registered: ‎10-15-2013
My Device: BlackBerry Z30
My Carrier: O2 UK

Re: Porting libraries - ffmpeg

New Contributor
Posts: 3
Registered: ‎09-11-2014
My Device: non-BlackBerry user
My Carrier: Vodafone

Re: Porting libraries - ffmpeg

Hi everyone,

 

I am a QNX user (armv7 architecture) and in my project I am required to build ffmpeg for QNX. I cross-compiled ffmpeg, but when I run it on my embedded target, it tells me that a bunch of libraries are missing:

 

./ffmpeg

ldd:FATAL: Could not load library libgcc_s.so.1
ldd:FATAL: Could not load library libpthread.so.0
ldd:FATAL: Could not load library libc.so.6
ldd:FATAL: Could not load library libm.so.6
ldd:FATAL: Could not load library ld-linux-armhf.so.3

 

My ./configure command is as follows:

 

./configure --enable-cross-compile --target-os=qnx --arch=armv7le --cc=arm-unknown-nto-qnx6.5.0-gcc --cxx=arm-unknown-nto-qnx6.5.0-gcc --extra-ldflags='-Wl,-s ' --enable-gpl --enable-static --enable-shared --disable-network --enable-debug --disable-optimizations --disable-asm --disable-doc --disable-debug --enable-decoder=h264 --enable-demuxer=h264 --enable-parser=h264 --enable-avfilter --disable-stripping --bindir=/usr/bin

 

What did I miss ? Should I also build these libraries separately ?

 

Best Regards,

Alex.

New Contributor
Posts: 3
Registered: ‎09-11-2014
My Device: non-BlackBerry user
My Carrier: Vodafone

Re: Porting libraries - ffmpeg

I solved this in the meanwhile, by building ffmpeg statically:

 

--extra-libs=-static --extra-cflags=--static

 

Retired
Posts: 35
Registered: ‎10-15-2013
My Device: BlackBerry Z30
My Carrier: O2 UK

Re: Porting libraries - ffmpeg

Building shared libraries should work. I've tried it on my OSX machine and was able to successfully build and run on a device. Here's the process I went through:

 

1. Build ffmpeg using the ./configure command in the original post

2. SSH into the device and create a folder /accounts/devuser/ffmpeg

3. Using Momentics copy the contents of ffmpeg/build/arm-qnx/release/ into the ffmpeg folder on the device. You can open the File Navigator view by doing Window->Show View->Other->QNX Targets->Target File System Navigator, now you drag and drop files from Finder/Explorer into the device. 

4. Also copy libx264.so and its link into the /accounts/devuser/ffmpeg/lib

5. On your SSH session run the following: export LD_LIBRARY_PATH=/accounts/devuser/ffmpeg/lib

 

Now you should be able to run ffmpeg from the bin folder.

 

One other thing I notice is that you're using an old version of the Native Development Kit which includes QNX 6.5.0. You should definitely download the latest version (which includes QNX 8.0.0) and try recompiling. 

Developer
Posts: 147
Registered: ‎05-31-2013
My Device: BlackBerry Z10 Limited Edition
My Carrier: Bonbon

Re: Porting libraries - ffmpeg

I'm aware that I'm resurrecting an old thread, but I'm up against the wall here.

I tried both static and shared libs and the result is the same.

I cannot get pass the av_register_all(); line.

 

Application crashes with SIGSEV code=2 (is that access violation code?).

 

Can someone confirm/show/how to do this with OS 10.3.1 and 10.3.1 Gold SDK?