1

My current situation is; ffmpeg and libx264 has been compiled for Android, as shared and static libraries respectively. Since I have libx264.a and libffmpeg.so with me, only thing that remains is to link them and obtain a ffmpeg library that would allow me to proceed with my application. However, some questions remain unanswered. I am using Ubuntu with a virtual machine under Windows 7. I am using x264's last version, ffmpeg 0.10.4 release and NDK 7.

I have tried to adjust flags (extracf and extrald) in order to include libx264 to ffmpeg compilation process as well, however I keep failing. Below you may find my build script for ffmpeg and the errors I have encountered.

NDK=~/Android_NDK_r7b 
PLATFORM=$NDK/platforms/android-8/arch-arm/ 
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 
x264=/usr/local 
#x264v2=~/x264 
function build_one 
{ 
./configure --target-os=linux \ 
    --prefix=$PREFIX \ 
    --enable-cross-compile \ 
    --extra-libs="-lgcc" \ 
    --arch=arm \ 
    --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \ 
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \ 
    --nm=$PREBUILT/bin/arm-linux-androideabi-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 -finline-limit=300 $OPTIMIZE_CFLAGS " \ 
    --extra-cflags="-I$x264/include" \ 
    --enable-shared \ 
    --enable-static \ 
    #--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib  -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \ 
    --extra-ldflags="-L$x264/lib" \ 
   --disable-everything \ 
   # --enable-demuxer=mov \ 
   # --enable-demuxer=h264 \ 
   # --disable-ffplay \ 
    --enable-gpl \ 
    --enable-libx264 \ 
   # --enable-protocol=file \ 
   # --enable-avformat \ 
   # --enable-avcodec \ 
   # --enable-encoder=libx264 \ 
   # --enable-decoder=rawvideo \ 
   #--enable-decoder=mjpeg \ 
   # --enable-decoder=h263 \ 
   # --enable-decoder=mpeg4 \ 
   # --enable-encoder=h264 \ 
   # --disable-network \ 
    #--enable-zlib \ 
   # --disable-avfilter \ 
    #--disable-avdevice \ 
    $ADDITIONAL_CONFIGURE_FLAG 

make clean 
make  -j4 install 
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o 
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog  --warn-once  --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a 
} 

#arm v7vfpv3 
CPU=armv7-a 
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU " 
PREFIX=./androidIncludeTrialsNDK7/$CPU 
ADDITIONAL_CONFIGURE_FLAG= 
build_one 

If I basically delete the lines extracf and extrald flags and use other ones (commented outs), it works fine except libx264 not found error. Otherwise, I get the following erros.

./buildnew.sh: line 35: --extra-cflags=-I/usr/local/include: No such file or directory 
./buildnew.sh: line 38: --extra-ldflags=-L/usr/local/lib: No such file or directory 
./buildnew.sh: line 40: --disable-everything: command not found 
./buildnew.sh: line 44: --enable-gpl: command not found 

The compilation process ends with the following.

make: *** [libavdevice/v4l.o] Error 1 
make: *** Waiting for unfinished jobs.... 
/home/mehmet/Android_NDK_r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar: creating libavcodec/libavcodec.a 
/home/mehmet/Android_NDK_r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld: cannot open output file ./androidIncludeTrialsNDK7/armv7-a/libffmpeg.so: No such file or directory 

I have x264 installed in my directory /home/mehmet/x264 and I also check whereis x264.a, it shows me as /usr/local/lib. I have tried changing the path $x264 to point out to home/mehmet/x264 folder, but I get the same error.

Lastly, if I enable both extracf and extrald flags ( both commented ones and the used ones) . I get the same error mentioned above. I am afraid I am doing a simple typo here, but can`t see it and it is driving me crazy. Thanks a lot for your help.

Best.

EDIT

I have deleted the comments and now obtain the following.

./buildnew.sh: 4: ./buildnew.sh: function: not found
ERROR: libx264 not found

Above error is observed from the terminal when I run the script. It build upto some point and finishes the process with the following error.

libavcodec/libavcodec.a(libx264.o): In function `X264_frame':
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:159: undefined reference to `x264_picture_init'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:179: undefined reference to `x264_encoder_reconfig'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:191: undefined reference to `x264_encoder_encode'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:197: undefined reference to `x264_encoder_delayed_frames'
libavcodec/libavcodec.a(libx264.o): In function `encode_nals':
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:196: undefined reference to `x264_bit_depth'
libavcodec/libavcodec.a(libx264.o): In function `X264_close':
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:231: undefined reference to `x264_encoder_close'
libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:284: undefined reference to `x264_param_default'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:292: undefined reference to `x264_param_default_preset'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:305: undefined reference to `x264_param_parse'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:502: undefined reference to `x264_param_apply_fastfirstpass'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:505: undefined reference to `x264_param_apply_profile'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:544: undefined reference to `x264_encoder_open_125'
/home/mehmet/ffmpeg-0.10.4/libavcodec/libx264.c:554: undefined reference to `x264_encoder_headers'
./buildnew.sh: 51: ./buildnew.sh: build_one: not found
kerim yucel
  • 127
  • 1
  • 3
  • 13
  • Well, it did solve your first issue. Anyways this issue is different. Your compilation is not finding the libx264 library. Is it properly installed on the system? Your linking paths should give the path to the location where libx264 is, right? I don't think I see that. – av501 Aug 30 '12 at 19:39
  • @av501 , thanks for the help. I have made some progress but encountered new errors, thanks to Murphy's Laws. Well, I changed the flags to point out /home/myname/x264/buildfolder/include and lib. I don't get these errors, actually i don't get any of these errors but can't see libx264.a in the folder where my ffmpeg output filesare installed. Any ideas what causes that? – kerim yucel Aug 30 '12 at 20:30
  • Welcome.If this helped accept the answer and ask a seperate one so that others can also join in in helping you. In the meantime I would say why don;t you check paths when you did a make install of x264 where it went. – av501 Aug 30 '12 at 20:38
  • Strange thing just happened. I have checked libx264's place and it showed me it is located in usr/local/lib. I also have it installed on somewhere else. When I change flags to point out my x264 install directory, it compiles but terminates with an error saying it can't cd to my prefix directory(where ffmpeg build will be put). If I change it to usr/local/lib, it can't find libx264. This is interesting. – kerim yucel Aug 30 '12 at 22:08
  • Might be permissions issues also. Do a ls -l to check. Could be links that link to nowhere. – av501 Aug 30 '12 at 22:10
  • Directory which includes ffmpeg build have root access, the rest is fine. Weird thing is; if I build ffmpeg without x264, it build just fine. If I enable x264, I get this can't cd error. My x264 directory which include output builds of x264 doesn't require root access either. I also run the scripts with root access so it shouldn't be a problem actually. Any ideas? I will get angry if that's just a simple typo in the code – kerim yucel Aug 30 '12 at 22:21
  • Your new makefile would be useful. I gtg right now. So will be able to check tomorrow morning. Check if you can ls the file, copy it etc [the x264 file]. So then you know it does exist and whatever is the error is in the makefile. – av501 Aug 30 '12 at 22:23
  • @av501 Config.mak for x264 and ffmpeg seems intact, with root access of course. I tried adding lx264 as a extralib but it didn't help as well. Disabling shared helps but doesn't give me libx264.a in ffmpeg build folders. My last trial was to enable-encoder-libx264 just to check but I get the errors in my first post except the last line which says build_one not found – kerim yucel Aug 31 '12 at 03:09
  • I don't know if it is a mistake, but in your build script when you define PLATFORM you finish your declaration with a slash '/'. After, in your -rpathlink= you write $PLATFORM/usr/lib, I would delete the last slash. – Álvaro Aug 31 '12 at 06:46
  • @Álvaro , thanks for the heads up but sadly it didn't change anything. I have seen some other scripts that managed to do this and they disable shared, and that's what I did as well. But the problem is the same, I don't get libx264.a under ffmpegbuild/armv7-a/lib directory. – kerim yucel Aug 31 '12 at 13:27
  • @av501 you may refer to this link instead of here, I have opened a new thread about my issue. http://stackoverflow.com/questions/12222435/libx264-encoder-error-in-ffmpeg-android-build – kerim yucel Aug 31 '12 at 21:09

1 Answers1

1

Your errors are nothing to do with ffmpeg/libx264. You cannot have those comments in the middle. Look at the error

./buildnew.sh: line 35: --extra-cflags=-I/usr/local/include: No such file or directory

It thinks --extra-cflags is a command and so on for everyline that is the first one after the comment.

Your command should be continous and without any comments. The "\" operator does not work from comments.

av501
  • 6,645
  • 2
  • 23
  • 34