Compiling and Building a Slim version of avconv/ffmpeg for STM32F4-Discovery - an armv7 thumb 1/2 architecture

StackOverflow https://stackoverflow.com/questions/18346486

Question

This is my first attempt at posting for help on Stack Overflow.

My Project: Using an STM32F4-Discovery with the STM32F407VGT6 chip with the FPv4-SP and a camera/LCD peripheral setup, I need to record video at QVGA and output into a compressed MPEG-4 format with at least a 25:1 ratio.

I have identified the desired codec library (avconv, unless ffmpeg proves more useable) and am now in the process of trying to build the compiler options to give me a light-weight version that will be able to execute on the chip in ANSI-C and Thumb architecture.

This board has very limited space (192KB SRAM and 1MB of Flash - there is the possibility of expansion, but it would be preferred to use just what I have) and currently the "main" executable of either library is over 1MB.

Judging by the output with the different solutions I have tried - it does not appear many of the compiler options are successfully applying to the build. So my questions are:

1) Is it even possible to compile either library into the space desired using only rawvideo decoders, mpeg4 encoders, and the most basic utilities possible? If not, is there a guesstimate out there of how much would be required?

2) I've spent many hours scouring the internet, and it doesn't appear that anyone has attempted this - is there anyone out there who can tell me otherwise?

I have my configure/build script on hand for anyone who wants to take a look and see if I have missed something basic. Just ask and I will email it, I don't want to clutter the thread more than my seemingly verbose inquisition already has.

I would assume that neither library is likely broken. I have been attempting this on Ubuntu 12.04 32-bit.

I am a software intern and would be extremely appreciative of any help available.

One final question, should my solution prove unworkable, is there another open-source mpeg4 compression library that can easily compile for embedded ARMv7E-M/Thumb set architecture?

EDIT: Here is the build command, previously unincluded.

#!/bin/bash

NDK=~/Desktop/android-ndk-r9
PLATFORM=~/Desktop/gcc-arm-none-eabi-4_7-2013q2
PREBUILT=~/Desktop/gcc-arm-none-eabi-4_7-2013q2/arm-none-eabi
function build_one
{
./configure --target-os=symbian \
    --prefix=$PREFIX \
    --disable-everything \
    --enable-cross-compile \
    --disable-shared \
    --enable-static \
    --enable-small \
  #  --disable-asm \
    --enable-thumb \
    --extra-libs="-lgcc" \
    --arch=armv7e-m \
    --cc=$PREBUILT/bin/gcc \
    --cross-prefix=$PREBUILT/bin \
    --nm=$PREBUILT/bin/nm \
    --sysroot=$PLATFORM \
    --extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -mthumb-interwork -finline-limit=300 $OPTIMIZE_CFLAGS -I/usr/local/include" \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/arm-none-eabi/lib/armv7e-m -L $PLATFORM/arm-none-eabi/lib/armv7e-m -nostdlib -lc -lm -ldl -llog -L/usr/local/lib " \
--enable-gpl \
   # --enable-libx264 \
    --enable-demuxer=mov \
    --enable-demuxer=h264 \
    --disable-ffplay \
    --disable-ffserver \
    --disable-ffprobe \
    --enable-protocol=file \
    --enable-avformat \
    --enable-avcodec \
    --enable-decoder=rawvideo \
    --enable-decoder=mjpeg \
    --enable-decoder=h263 \
    --enable-decoder=mpeg4 \
    --enable-decoder=h264 \
    --enable-encoder=mjpeg \
    --enable-encoder=h263 \
    --enable-encoder=mpeg4 \
    --enable-encoder=h264 \
    --enable-parser=h264 \
    --disable-network \
    --enable-zlib \
    --disable-avfilter \
    --disable-avdevice \
    $ADDITIONAL_CONFIGURE_FLAG

make clean
make -j4 install
$PREBUILT/bin/ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/ld -rpath-link=$PLATFORM/arm-none-eabi/lib/armv7e-m -L$PLATFORM/arm-none-eabi/lib/armv7e-m  -soname libffmpeg.so -shared -Bshareable -nostdlib -Bdynamic --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --dynamic-linker=/system/bin/linker $PREBUILT../lib/gcc/arm-none-eabi/4.7.4/armv7e-m/libgcc.a
}

CPU=armv7e-m
OPTIMIZE_CFLAGS="-mfloat-abi=hard -mfpu=vfpv4 -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one

This is a script I have obtained and modified. It originally built successfully for ARMv7-a which will not execute on the ARMv7e-m chip (the discovery board).

Was it helpful?

Solution

Got some questions first:

What compiler options are you using? It's important to get them right to enable the correct libraries and floating point support. Can you post your build commands? Are you separating the compile and link stages?

Are you using newlib or newlib-nano? You can save space with newlib-nano.

Are you running bare metal or with an RTOS?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top