Newest 'x264' Questions - Stack Overflow
Les articles publiés sur le site
-
Build FFMPEG with x264 for Android
26 mai 2023, par KageI am trying to build FFMPEG with libx264 for Android.
I can successfully build and use FFMPEG for Android but I realized that I need the ability to encode, therefore I am trying to build FFMPEG with x264.
I am using this tutorial to build FFmpeg for Android http://www.roman10.net/how-to-build-ffmpeg-for-android/
When trying to build FFMPEG I get an error:
"ERROR: libx264 not found"
And in my log it says:
"/usr/local/lib/libx264.a: could not read symbols: Archive has no index; run ranlib to add one..."
I have the latest versions of both FFMPEG and x264. I understand that FFMPEG looks for the header and libraries in usr/lib and usr/include, so in order to make it find x264 I use the cflags and ldflags:
- --extra-cflags = " -I/usr/local/include "
- --extra-ldflags = " -L/usr/local/lib "
I have tried building x264 with many different options that other people on the internet have said that i need. eg. --enable-shared, --enable-static, --disable-pthreads etc. Some forums say enable this, others say no disable that.
Any help would be much appreciated, Thanks
EDIT:
If I build FFmpeg with the simplest commands to include libx264 then it works. ie.
./configure --enable-gpl --enable-libx264 --extra-cflags="-I/usr/local/include" --extra-ldflags="-L/usr/local/lib" --enable-static --enable-shared
However I need it to work for Android. The script I am using is:
NDK=~/Desktop/android-ndk-r7 PLATFORM=$NDK/platforms/android-8/arch-arm/ PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86 function build_one { ./configure --target-os=linux \ --prefix=$PREFIX \ --enable-cross-compile \ --enable-shared \ --enable-static \ --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 -I/usr/local/include" \ --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L $PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog -L/usr/local/lib " \ --enable-gpl \ --enable-libx264 \ --disable-everything \ --enable-demuxer=mov \ --enable-demuxer=h264 \ --disable-ffplay \ --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/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 } CPU=armv7-a OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU " PREFIX=./android/$CPU ADDITIONAL_CONFIGURE_FLAG= build_one
I am guessing that some option in my configure command is conflicting with enabling libx264
NOTE: If I remove --enable-libx264 then it works
-
Error encountered during encoding with 1 thread and decoding with multiple threads using FFmpeg in C
17 mai 2023, par RachelI'm currently working on a project where I'm using FFmpeg in C programming language for encoding and decoding video. I have configured the encoder to use 1 thread and the decoder to use multiple threads (specifically, 23 threads). However, when I run the code, I encounter the following error:
avcodec_receive_frame failure - Resource temporarily unavailable
Here are the relevant code snippets:
Encoder:
pt_handle->t_x264_param.i_threads = 1;
pt_handle->pt_x264_encoder = x264_encoder_open(&pt_handle->t_x264_param);
Decoder:
pt_handle->pt_avcodec_ctx->thread_count = 23;
i_retval = avcodec_open2(pt_handle->pt_avcodec_ctx, pt_h264_decoder, NULL);
I'm unsure about the cause of this error and how to resolve it. Any insights or suggestions on how to address this issue would be greatly appreciated. Thank you!
-
Gstreamer convert and display video v4l2 - tee problems in rust
27 mars 2023, par d3imI have USB grabber v4l2 source and I want to tee stream to autovideosink and x264enc to file (now as fake black hole)
When I disable one or another branch it works but together Pipeline goes:
Pipeline state changed from Null to Ready Pipeline state changed from Ready to Paused
and stays there never switches to Playing
gst-launch-1.0 with similar functionality works well.
gst::Element::link_many(&[&pw_video, &v_caps, &vid_queuey, &vid_tee]).unwrap(); gst::Element::link_many(&[&vid_queue1, &autovideoconvert, &vid_queuex, &autovideosink]).unwrap(); gst::Element::link_many(&[&vid_queue2, &autovideoconvert_x264, &vid_queue3, &x264, &vid_queue4, &fake]).unwrap(); let tee_display_pad = vid_tee.request_pad_simple("src_10").unwrap(); let vid_queue1_pad = vid_queue1.static_pad("sink").unwrap(); tee_display_pad.link(&vid_queue1_pad).unwrap(); let tee_convert_pad = vid_tee.request_pad_simple("src_20").unwrap(); let vid_queue2_pad = vid_queue2.static_pad("sink").unwrap(); tee_convert_pad.link(&vid_queue2_pad).unwrap();
How can I use tee in rust properly to have playable pipeline with two branches?
Update: I read some posts about increasing queue size, so I tried for this and then all queues:
let vid_queue1 = gst::ElementFactory::make("queue") .name("queue1") .property("max-size-buffers", 5000 as u32) .property("max-size-bytes", 1048576000 as u32) .property("max-size-time", 60000000000 as u64) .build() .expect("queue1");
but it didn't help so I tried set zero latency:
let x264 = gst::ElementFactory::make("x264enc") .name("x264") .property_from_str("speed-preset", "ultrafast") .property_from_str("pass", "qual") .property_from_str("tune", "zerolatency") .property("quantizer", 0 as u32) .property("threads", 8 as u32) .build() .expect("!x264");
and it works now. But comparable gst-launch-1.0 settings didn't had such option - only queues sizes increased.
Is there any other option than setting zerolatency?
-
How to fix the "No working C compiler found." problem for compiling x264 in Linux ?
27 février 2023, par gc xuFirstly I have read all other solutions related to this problem, including adding path and reinstall yasm, nasm, gcc... I git clone the source code from https://code.videolan.org/videolan/x264.git. Then, I run command ./configure, it shows
./configure: line 169: conftest.log: Invalid argument ./configure: line 169: conftest.log: Invalid argument ./configure: line 169: conftest.log: Invalid argument ./configure: line 169: conftest.log: Invalid argument No working C compiler found.
I check the file "config.log". It shows:
checking for -Werror=unknown-warning-option... no Failed commandline was: -------------------------------------------------- gcc conftest.c -Wall -I. -I$(SRCPATH) -Werror=unknown-warning-option -o conftest cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- checking for -Werror=unknown-attributes... no Failed commandline was: -------------------------------------------------- gcc conftest.c -Wall -I. -I$(SRCPATH) -Werror=unknown-attributes -o conftest cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- checking for -Werror=attributes... no Failed commandline was: -------------------------------------------------- gcc conftest.c -Wall -I. -I$(SRCPATH) -Werror=attributes -o conftest cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- checking for -Werror=ignored-attributes... no Failed commandline was: -------------------------------------------------- gcc conftest.c -Wall -I. -I$(SRCPATH) -Werror=ignored-attributes -o conftest cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- x264 configure script Command line options: "--enable-shared" "--enable-static" checking whether gcc works... no Failed commandline was: -------------------------------------------------- gcc conftest.c -m64 -Wall -I. -I$(SRCPATH) -m64 -lm -o conftest cc1: error: ‘-Werror=unknown-warning-option’: no option -Wunknown-warning-option -------------------------------------------------- Failed program was: -------------------------------------------------- int main (void) { return 0; } -------------------------------------------------- DIED: No working C compiler found.
Plus I wonder is there something to do with nasm? Becasuse I install nasm with some C grammer problems:
./config/config.h:659:16: error: duplicate ‘unsigned’ 659 | #define size_t unsigned int | ^~~~~~~~ ./config/config.h:659:25: error: two or more data types in declaration specifiers 659 | #define size_t unsigned int | ^~~ In file included from /usr/include/string.h:633, from ./include/compiler.h:89, from asm/nasm.c:38: ./include/compiler.h:241:7: error: expected identifier or ‘(’ before ‘__extension__’ 241 | char *strsep(char **, const char *); | ^~~~~~ ./include/compiler.h:241:7: error: expected identifier or ‘(’ before ‘)’ token 241 | char *strsep(char **, const char *); | ^~~~~~ make[1]: *** [asm/nasm.o] Error 1 make[1]: Leaving directory `/mnt/nfs0/gengcheng/ffmpeg-5.0.2/nasm-2.15.05' make: *** [all] Error 2
I have read all other solutions related to this problem, including adding path and reinstall yasm, nasm, gcc... I want to install x264 to configure it in ffmpeg. Thanks for all your answers!
-
How to use x264 encoder in Ant Media Server v2.5
26 février 2023, par farawayAnt Media Server starts to use OpenH264 as a software encoder in v2.5 but I need to use x264. How can I use x264 in Ant Media Server v2.5?
https://github.com/ant-media/Ant-Media-Server/releases/tag/ams-v2.5.0 https://antmedia.io