Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
Yet another ffmpeg/libx264 issue
26 décembre 2013, par kerim yucelMy 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
-
libx264 encoder error in ffmpeg android build
26 décembre 2013, par kerim yucelRight now, I have a ffmeg build script which recognizes libx264 and compiles succesfully. I have also compiled x264 and obtained libx264.a library. Both ffmpeg and libx264 are built from source. I can build ffmpeg without libx264 succesfully as well. Below you may find my script which tries to build ffmpeg with libx264.
#!/bin/bash NDK=~/Android_NDK_r7b PLATFORM=$NDK/platforms/android-8/arch-arm/ PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 alitan=~/x264/ndk7_build 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=" -I$alitan/include" \ --disable-shared \ --enable-static \ --extra-ldflags=" -L$alitan/lib " \ --enable-version3 \ --enable-gpl \ --disable-doc \ --disable-everything \ --enable-libx264 \ --enable-encoder=libx264 \ $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=./DONE/$CPU ADDITIONAL_CONFIGURE_FLAG= build_one
Above script doesn't give me libx264.a in ffmpeg output builds.Several other scenarios are as follows. If I enable x264 encoder, I get undefined reference errors to some variables in x264.c (in libavcodec). If I enable shared in ffmpeg configure, I get an error which says it can't cd to my prefix directory (no permission issues by the way).
I am using latest releases of ffmpeg and x264 (cloned the git today) and ndk 7. Ubuntu runs on VM, installed on Windows 7. For further details about my adventure of ffmpeg/x264 porting to Android, you may refer here.
What should I do to use libx264 with ffmpeg? I kept on trying this script with different configurations, removed all ffmpeg x264 folders and reinstalled them, but to no avail.
Thanks a lot in advance.
EDIT Below is my x264 build script. It builds fine, gives me the static library and the headers.
export ARM_ROOT=/home/mehmet/Android_NDK_r7b export ARM_INC=$ARM_ROOT/platforms/android-8/arch-arm/usr/include/ export ARM_LIB=$ARM_ROOT/platforms/android-8/arch-arm/usr/lib/ export ARM_TOOL=$ARM_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 export ARM_LIBO=$ARM_TOOL/lib/gcc/arm-linux-androideabi/4.4.3 export PATH=$ARM_TOOL/bin:$PATH export PATH=$ARM_TOOL/arm-linux-androideabi/bin:$PATH export ARM_PRE=arm-linux-androideabi #tries to build for 4.4.3 toolchain ./configure --prefix=./ndk7_build \ --disable-gpac \ --extra-cflags=" -I$ARM_INC -fPIC -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP " \ --extra-ldflags=" -nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ARM_LIB -nostdlib $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -lc -lm -ldl -lgcc " \ --cross-prefix=${ARM_PRE}- \ --disable-asm \ --enable-static \ --host=arm-linux \
This is what happens on terminal when i enable libx264 encoder.
STRIP ffmpeg INSTALL install-progs-yes INSTALL ffmpeg INSTALL ffprobe libavcodec/libavcodec.a(libx264.o): In function `X264_frame': /home/mehmet/ffmpeg/libavcodec/libx264.c:158: undefined reference to `x264_picture_init' /home/mehmet/ffmpeg/libavcodec/libx264.c:178: undefined reference to `x264_encoder_reconfig' /home/mehmet/ffmpeg/libavcodec/libx264.c:189: undefined reference to `x264_encoder_encode' /home/mehmet/ffmpeg/libavcodec/libx264.c:195: undefined reference to `x264_encoder_delayed_frames' libavcodec/libavcodec.a(libx264.o): In function `encode_nals': /home/mehmet/ffmpeg/libavcodec/libx264.c:100: undefined reference to `x264_bit_depth' libavcodec/libavcodec.a(libx264.o): In function `X264_close': /home/mehmet/ffmpeg/libavcodec/libx264.c:230: undefined reference to `x264_encoder_close' libavcodec/libavcodec.a(libx264.o): In function `X264_init': /home/mehmet/ffmpeg/libavcodec/libx264.c:283: undefined reference to `x264_param_default' /home/mehmet/ffmpeg/libavcodec/libx264.c:291: undefined reference to `x264_param_default_preset' /home/mehmet/ffmpeg/libavcodec/libx264.c:313: undefined reference to `x264_param_parse' /home/mehmet/ffmpeg/libavcodec/libx264.c:448: undefined reference to `x264_param_apply_fastfirstpass' /home/mehmet/ffmpeg/libavcodec/libx264.c:451: undefined reference to `x264_param_apply_profile' /home/mehmet/ffmpeg/libavcodec/libx264.c:494: undefined reference to `x264_encoder_open_125' /home/mehmet/ffmpeg/libavcodec/libx264.c:505: undefined reference to `x264_encoder_headers'
-
FFmpeg remux rtp to mpegts [closed]
16 décembre 2013, par ArdoramorI am trying to remux rtp stream into mptegts format. I have an SDP file with the following contents:
v=0 o=- 0 0 IN IP4 127.0.0.1 s=Unnamed i=N/A c=IN IP4 192.168.17.44 t=0 0 a=recvonly a=orient:portrait m=video 8202 RTP/AVP 96 a=rtpmap:96 H264/90000 a=fmtp:96 packetization-mode=1;profile-level-id=428028;sprop-parameter-sets=Z0KAKJWgKA9E,aM48gA==; a=control:trackID=1
I execute the following ffmpeg command:
ffmpeg -i "test.sdp" -f mpegts -vcodec copy "/tmp/test.ts"
And I get the following information:
Input #0, sdp, from 'test.sdp': Metadata: title : Unnamed comment : N/A Duration: N/A, start: 0.066622, bitrate: N/A Stream #0.0: Video: h264 (Baseline), yuv420p, 640x480, 90k tbr, 90k tbn, 180k tbc [mpegts @ 0x1101d4c0] muxrate VBR, pcr every 9000 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to '/tmp/test.ts': Metadata: title : Unnamed comment : N/A encoder : Lavf53.4.0 Stream #0.0: Video: libx264, yuv420p, 640x480, q=2-31, 90k tbn, 90k tbc Stream mapping: Stream #0.0 -> #0.0
I receive the following error:
[mpegts @ 0x1c85f960] h264 bitstream malformated, no startcode found, use -vbsf h264_mp4toannexb av_interleaved_write_frame(): Operation not permitted
So I add the suggested bitstream filter:
ffmpeg -i "test.sdp" -f mpegts -vbsf h264_mp4toannexb "/tmp/test.ts"
But the h264 encoding now becomes h262 (mpeg2video):
~$ffprobe /tmp/test.ts Input #0, mpegts, from '/tmp/test.ts': Duration: 00:00:04.13, start: 1.400000, bitrate: 640 kb/s Program 1 Metadata: service_name : Unnamed service_provider: FFmpeg Stream #0.0[0x100]: Video: mpeg2video (Main), yuv420p, 640x480 [PAR 1:1 DAR 4:3], 104857 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc
Is there any way to keep the h264 codec without re-encoding it? Doing so becomes very CPU intensive.
Update
Hopefully this will clear up the issue and remove the off-topic stamp.
I'm writing an Android app that is based off of SpyDroids streaming architecture. The app communicates with the server, providing it the SDP. The server spawns an ffmpeg process to remux the incoming video stream into mpegts and broadcasts it on multicast (right now just file).
SpyDroid performs streaming by sending recorded mp4 file through localsocket, received h264 packets, supposedly (according to code removed mp4 h264 prefix [annexb]), wraps it with rtp headrs and sends it on its way. Thus, the RPT stream I get is clearly not originally generated as such.
As @Wagner Patriota has mentioned, I should add '-vcodec copy'. I had run the remuxing with it before as well but the error is still present (full output):
~$ffmpeg -i "test.sdp" -f mpegts -vcodec copy -vbsf h264_mp4toannexb "/tmp/test.ts" ffmpeg version 0.8.6, Copyright (c) 2000-2011 the FFmpeg developers built on Jan 30 2012 17:17:54 with gcc 4.5.2 configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --disable-avisynth --enable-libdc1394 --enable-libfaac --enable-libgsm --enable-libmp3lame --enable-libx264 --enable-libxvid --extra-cflags='-O2 -g -m64 -mtune=generic -fPIC' --disable-stripping --disable-demuxer=v4l --disable-demuxer=v4l2 --disable-indev=v4l --disable-indev=v4l2 libavutil 51. 9. 1 / 51. 9. 1 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 4. 0 / 53. 4. 0 libavdevice 53. 1. 1 / 53. 1. 1 libavfilter 2. 23. 0 / 2. 23. 0 libswscale 2. 0. 0 / 2. 0. 0 libpostproc 51. 2. 0 / 51. 2. 0 [h264 @ 0x16b4b1c0] concealing 232 DC, 232 AC, 232 MV errors [h264 @ 0x16b4b1c0] concealing 63 DC, 63 AC, 63 MV errors [h264 @ 0x16b4b1c0] concealing 25 DC, 25 AC, 25 MV errors [h264 @ 0x16b4b1c0] concealing 138 DC, 138 AC, 138 MV errors [h264 @ 0x16b4b1c0] concealing 69 DC, 69 AC, 69 MV errors [sdp @ 0x16b43400] Estimating duration from bitrate, this may be inaccurate Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2) Input #0, sdp, from 'test.sdp': Metadata: title : Unnamed comment : N/A Duration: N/A, start: 0.033256, bitrate: N/A Stream #0.0: Video: h264 (Baseline), yuv420p, 640x480, 90k tbr, 90k tbn, 180k tbc [mpegts @ 0x16b4a4c0] muxrate VBR, pcr every 9000 pkts, sdt every 200, pat/pmt every 40 pkts Output #0, mpegts, to '/tmp/test.ts': Metadata: title : Unnamed comment : N/A encoder : Lavf53.4.0 Stream #0.0: Video: libx264, yuv420p, 640x480, q=2-31, 90k tbn, 90k tbc Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop, [?] for help h264_mp4toannexb failed for stream 0, codec copy: Invalid argument [mpegts @ 0x16b4a4c0] h264 bitstream malformated, no startcode found, use -vbsf h264_mp4toannexb av_interleaved_write_frame(): Operation not permitted
The error reports that the invalid argument has been supplied. Increased loglevel does not give any more information. I know that ffmpeg is sometimes finicky with argument order. However, they seen to be in order of documentation as well as suggested order by @Wagner Patriota.
-
latency when streaming x264
18 novembre 2013, par tobsenI would like to produce a
zerolatency
live video stream and play it in VLC player with as little latency as possible.This are the settings I currently use:
x264_param_default_preset( &m_Params, "veryfast", "zerolatency" ); m_Params.i_threads = 2; m_Params.b_sliced_threads = true; m_Params.i_width = m_SourceWidth; m_Params.i_height = m_SourceHeight; m_Params.b_intra_refresh = 1; m_Params.b_vfr_input = true; m_Params.i_timebase_num = 1; m_Params.i_timebase_den = 1000; m_Params.i_fps_num = 1; m_Params.i_fps_den = 60; m_Params.rc.i_vbv_max_bitrate = 512; m_Params.rc.i_vbv_buffer_size = 256; m_Params.rc.f_vbv_buffer_init = 1.1f; m_Params.rc.i_rc_method = X264_RC_CRF; m_Params.rc.f_rf_constant = 24; m_Params.rc.f_rf_constant_max = 35; m_Params.b_annexb = 0; m_Params.b_repeat_headers = 0; m_Params.b_aud = 0; x264_param_apply_profile( &m_Params, "high" );
Using those settings, I have the following issues:
- VLC shows lots of missing frames (see screenshot, "verloren"). I am not sure if this is an issue.
- If I set a value <200ms for the network stream delay in VLC, VLC renders a few frames and than stops to decode/render frames.
- If I set a value >= 200ms for the network stream delay in VLC, everything looks good so far but the latency is, obviously, 200ms, which is too high.
Question: Which settings (x264lib and VLC) should I use in order to encode and stream with as little latency as possible?
-
Compile x264 with Thread Support for Android Platform
10 novembre 2013, par Stryker33I've been tryin' to compile x264 for Android with Thread Support...But with no success...
I've managed to compile the same without thread support...The configure command is as follows :
./configure --prefix=$PREFIX \ --enable-pic \ --host=arm-linux \ --disable-cli \ --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \ --sysroot=$PLATFORM
where
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86
andPLATFORM=$NDK/platforms/android-14/arch-arm
I've also tried with and without the option
--enable-static
andextra-ldflags="-lpthread"
, but when attemptedmake
it ends with errors.Is there any way to accomplish the above said...?