Newest 'libx264' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg + x264 in Android, undefined reference to several functions
13 avril 2013, par user1914692I was trying to use the halfninja's tutorial to get the library for Android.
However, it has error:
error: ERROR: libx264 not found
After painful searching, I found that Panayiotis Karabassis's configuration works.
for x264 configuration, we need to add:
--enable-static \
for ffmpeg configuration,
--ld=arm-linux-androideabi-gcc \ --extra-libs="-lgcc"
I do not know why we should use ld=arm-linux-androideabi-gcc, rather than ld=arm-linux-androideabi-ld. But if we use ld=arm-linux-androideabi-ld, the compiling will not work.
Anyway, now I get libvideokit.so I put it in the jni project folder. I include the header files. So snippet in Android.mk is:
LOCAL_C_INCLUDES += $(LOCAL_PATH)/include LOCAL_LDLIBS += -L$(NDK_PLATFORMS_ROOT)/$(TARGET_PLATFORM)/arch-arm/usr/lib -L$(LOCAL_PATH) LOCAL_LDLIBS += -lvideokit LOCAL_LDLIBS += -llog -ldl LOCAL_LDLIBS += -ljnigraphics
The related ffmpeg configuration are:
featureflags="--disable-everything \ --enable-decoder=mjpeg --enable-demuxer=mjpeg --enable-parser=mjpeg \ --enable-demuxer=image2 --enable-muxer=mp4 --enable-encoder=libx264 --enable-libx264 \ --enable-decoder=rawvideo \ --enable-protocol=file \ --enable-hwaccels" ./configure --enable-cross-compile \ --arch=arm5te \ --enable-armv5te \ --target-os=linux \ --disable-stripping \ --prefix=../output \ --disable-neon \ --enable-version3 \ --enable-shared \ --enable-static \ --enable-gpl \ --enable-memalign-hack \ --cc=arm-linux-androideabi-gcc \ --ld=arm-linux-androideabi-gcc \ --extra-cflags="-fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated" \ $featureflags \ --disable-everything \ --enable-decoders \ --enable-demuxers \ --enable-muxer=mp4 \ --enable-encoders \ --enable-libx264 \ --enable-protocols \ --enable-parsers \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --enable-network \ --enable-filter=buffer \ --enable-filter=buffersink \ --enable-filter=scale \ --enable-bsfs \ --enable-swscale \ --enable-asm \ --disable-demuxer=v4l \ --disable-demuxer=v4l2 \ --disable-indev=v4l \ --disable-indev=v4l2 \ --extra-cflags="-I../x264" \ --extra-ldflags="-L../x264" \ --extra-libs="-lgcc"
In my jni c file jni_part.cpp, it Here is one snippet:
static int open_input_file(const char *filename, structForInVFile& inVStruct) { int ret; // static AVCodecContext *inCodecContext; inVStruct.video_stream_index = -1; AVCodec* inCodec; if ((ret = avformat_open_input(&(inVStruct.inFormatContext), filename, NULL, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n"); return ret; } if ((ret = avformat_find_stream_info(inVStruct.inFormatContext, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n"); return ret; } /* select the video stream */ ret = av_find_best_stream(inVStruct.inFormatContext, AVMEDIA_TYPE_VIDEO, -1, -1, &(inVStruct.inCodec), 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot find a video stream in the input file\n"); return ret; } inVStruct.video_stream_index = ret; inVStruct.inCodecContext = inVStruct.inFormatContext->streams[inVStruct.video_stream_index]->codec; inVStruct.inFrameRate = inVStruct.inFormatContext->streams[inVStruct.video_stream_index]->r_frame_rate.num; /* init the video decoder */ if ((ret = avcodec_open2(inVStruct.inCodecContext, inVStruct.inCodec, NULL)) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot open video decoder\n"); return ret; } if (ret == 0) { // Allocate AVFrame, AVPacekt for the input video file: inFormatContext inVStruct.inFrame = avcodec_alloc_frame(); if (!inVStruct.inFrame) { perror("Could not allocate inFrame"); exit(1); } } return 0; }
After building, the console information is:
./obj/local/armeabi-v7a/objs/native_sample/jni_part.o: In function `open_input_file': /AndrVideo/jni/jni_part.cpp:82: undefined reference to `avformat_find_stream_info' /AndrVideo/jni/jni_part.cpp:99: undefined reference to `avcodec_open2'
(and other undefined reference information in the remaining: such as: av_opt_set, av_frame_get_best_effort_timestamp, avcodec_free_frame, avformat_close_input, avcodec_encode_video2 etc.)
You could see that: function "avformat_open_input" can be resolved. But the next function "avformat_find_stream_info", is not undefined. Both functions are in the utils.c file. So the difference might be in the enable options. But I have no clue to find out the solution.
Help!! I have been stuck here for quite a while... BTW, the original cpp file in C++ environment works well.
[Update 1] I found the reason. The grabbed ffmpeg in halfninja is an old one. The old one does not have the function avformat_find_stream_info. I grab latest version of ffmpeg and x264. But there are still errors. Let me try to figure it out.
[Update 2] There are many versions for compiling ffmpeg+libx264 on Android. I want to use the latest version of ffmpeg and libx264. And I found combination of halfninja and vitamio can make compilation work. However, wait... Now I get the -lavdevice -lavformat -lavfilter -lavcodec -lswscale -lavutil -lx264 I include them in the jni in the Android app. Building the app is fine. However, running is not good. Error information is:
04-12 18:50:49.303: D/dalvikvm(8149): Trying to load lib /data/data/com.example.andrvideoprocess/lib/libnative_sample.so 0x4051def8 04-12 18:50:49.303: D/AndroidRuntime(8149): Shutting down VM 04-12 18:50:49.313: W/dalvikvm(8149): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 04-12 18:50:49.313: E/AndroidRuntime(8149): FATAL EXCEPTION: main 04-12 18:50:49.313: E/AndroidRuntime(8149): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1312]: 69 cannot locate '__aeabi_llsl'... 04-12 18:50:49.313: E/AndroidRuntime(8149): at java.lang.Runtime.loadLibrary(Runtime.java:434)
I spend a lot of time solving issues one by one. And now I am still far away from success. Help!!!
-
Debug Assertion Failed on dllinit.cpp Line703 by using own regular DLL
20 mars 2013, par user2190325I'm creating a Regular DLL(mylib.dll and mylib.lib) that using libx264.dll(dynamic linking by import lib) and libfaac.lib(static linking). mylib.dll created and has no build errors, but Debug Assertion Failed message popped up at runtime in dllinit.cpp:Line703.
How to solve above DLL-hells ?
-
Encoding h.264 with libavcodec/x264
13 mars 2013, par szatmaryI am attempting to encode video using libavcodec/libavformat. Audio works great, but when I try to encode video I get the following errors:
[libx264 @ 0x10182a000]broken ffmpeg default settings detected [libx264 @ 0x10182a000]use an encoding preset (vpre)
easy to fix using the command line ffmpeg, but I am trying to do this in C. my options are
AVStream *pVideoOutStream = av_new_stream(pOutFormatCtx, 0); AVCodecContext *pVideoOutCodecCtx = pVideoOutStream->codec; pVideoOutCodecCtx->codec_id = CODEC_ID_H264; pVideoOutCodecCtx->codec_type = CODEC_TYPE_VIDEO; pVideoOutCodecCtx->bit_rate = pVideoInCodecCtx->bit_rate; pVideoOutCodecCtx->width = pVideoInCodecCtx->width; pVideoOutCodecCtx->height = pVideoInCodecCtx->height; pVideoOutCodecCtx->pix_fmt = pVideoInCodecCtx->pix_fmt; pVideoOutCodecCtx->sample_rate = pVideoInCodecCtx->sample_rate; pVideoOutCodecCtx->gop_size = 30;
but avcodec_open() fails.
What other values do I need to set to make x264 happy?
-
x264 library speed - Altivec vs SSE2 -
25 février 2013, par Omer MerdanI have simple cheap dualcore intel-3ghz-debian and access to super-expensive powerPc7-Aix.
And after few days of strugle, i compiled libx264 and tested it on both computers:
- GCC: library x264 on intel (with SSE2 capabilities) and
- GCC on 16 core powerPc (with altivec).
... and result is that cheap intel is x2 times faster ! (with altivec disabled, intel is 10x times faster)
My question: is this normal? Does all other powerPC-users have same results? Can powerPc-altivec-optimisation of x264 library work at same speed with intel... or MMX/SSE optimisation is officially at least 2 times faster for this library?
I am not interested in multi-thread options. Number of cores and threads are irrelevant. Just simple one-thread x264 encoding with default "medium preset" using rawvideo as source, sse vs altivec.
Maybe native Aix XLC compiler provide better results? (i managed only gcc to work)
... mac-powerpc-users maybe know something about this.
powrPc7-Aix:$ time (cat raw10sec.y4m |x264 --input-res 720x576 --fps 50 -o /dev/null -) x264: 64-bit XCOFF x264 [info]: using cpu capabilities: Altivec time: real 0m33.559s --- intelDebian:$ time (cat raw10sec.y4m |x264 --input-res 720x576 --fps 50 -o /dev/null -) x264: ELF 32-bit LSB executable x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64 time: real 0m16.503s
-
.mov conversion to .mp4 using ffmpeg doesn't convert the entire video
5 février 2013, par user504879I am trying to convert a mov file which I got from saving my powerpoint presentation to a movie file. However only a part of the presentation is converted not the entire one and also running qt-start doesn't make the exported mp4 to stream over rtmp. Is there something which I am missing?
I am attaching the output which i get when I am trying to convert the file using ffmpeg
$ export LD_LIBRARY_PATH=/usr/local/lib; /usr/local/bin/ffmpeg -y -i /data/tmp/vialogues_prez.mov -r 20 -g 40 -acodec libfaac -ar 44100 -ab 96k -vcodec libx264 -s 640x480 -vpre medium /data/videos/vialogues_prez.mp4 FFmpeg version 0.6.1, Copyright (c) 2000-2010 the FFmpeg developers built on Feb 19 2011 19:03:56 with gcc 4.4.5 configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab libavutil 50.15. 1 / 50.15. 1 libavcodec 52.72. 2 / 52.72. 2 libavformat 52.64. 2 / 52.64. 2 libavdevice 52. 2. 0 / 52. 2. 0 libswscale 0.11. 0 / 0.11. 0 libpostproc 51. 2. 0 / 51. 2. 0 [mov,mp4,m4a,3gp,3g2,mj2 @ 0x186f460]max_analyze_duration reached Seems stream 0 codec frame rate differs from container frame rate: 600.00 (600/1) -> 0.08 (1/12) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/tmp/vialogues_prez.mov': Metadata: major_brand : qt minor_version : 537199360 compatible_brands: qt comment : Microsoft PowerPoint Movie comment-eng : Microsoft PowerPoint Movie Duration: 00:04:47.00, start: 0.000000, bitrate: 22 kb/s Stream #0.0(eng): Video: qtrle, bgra, 640x480, 21 kb/s, 0.01 fps, 0.08 tbr, 600 tbn, 600 tbc Stream #0.1(eng): Video: 0x0000, 600 tbr, 600 tbn, 600 tbc Stream #0.2(eng): Video: 0x0000, 600 tbr, 600 tbn, 600 tbc [libx264 @ 0x1873b50]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64 [libx264 @ 0x1873b50]profile High, level 3.0 [libx264 @ 0x1873b50]264 - core 114 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=200 ratetol=20.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00 Output #0, mp4, to '/data/videos/vialogues_prez.mp4': Metadata: encoder : Lavf52.64.2 Stream #0.0(eng): Video: libx264, yuv420p, 640x480, q=10-51, 200 kb/s, 20 tbn, 20 tbc Stream mapping: Stream #0.0 -> #0.0 Press [q] to stop encoding frame= 4 fps= 0 q=32766.0 Lsize= 50kB time=45.05 bitrate= 9.0kbits/s video:49kB audio:0kB global headers:0kB muxing overhead 1.740573% [libx264 @ 0x1873b50]frame I:1 Avg QP:32.73 size: 8427 [libx264 @ 0x1873b50]frame P:3 Avg QP:20.68 size: 13640 [libx264 @ 0x1873b50]mb I I16..4: 60.8% 14.6% 24.7% [libx264 @ 0x1873b50]mb P I16..4: 28.7% 7.2% 15.4% P16..4: 2.0% 1.3% 1.4% 0.0% 0.0% skip:43.9% [libx264 @ 0x1873b50]final ratefactor: -16.67 [libx264 @ 0x1873b50]8x8 transform intra:14.2% inter:5.0% [libx264 @ 0x1873b50]coded y,uvDC,uvAC intra: 25.2% 18.4% 13.0% inter: 5.3% 7.4% 7.2% [libx264 @ 0x1873b50]i16 v,h,dc,p: 63% 34% 1% 2% [libx264 @ 0x1873b50]i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 41% 31% 1% 1% 1% 1% 1% 4% [libx264 @ 0x1873b50]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 33% 19% 2% 3% 3% 4% 3% 4% [libx264 @ 0x1873b50]i8c dc,h,v,p: 75% 20% 4% 1% [libx264 @ 0x1873b50]Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0x1873b50]ref P L0: 57.0% 12.2% 26.2% 4.7% [libx264 @ 0x1873b50]kb/s:1.14
any help is appreciated.