Newest 'libx264' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/libx264

Les articles publiés sur le site

  • How to reduce the quality of H264 Video

    20 février 2014, par user3239282

    How to reduce the quality of H264 video using libx264 library, for transmission over internet.

    I want to reduce the quality, so that the frame size will become small and decreases the network latency while transferring over internet.

  • Reduce Bandwidth requirement for Video Streaming

    19 février 2014, par user3239282

    Please suggest some points on, how to reduce the bandwidth requirement for a video stream.

    We are actually streaming the desktop across internet, Remote Access Application.

    Encoder : libx264.lib

    Decoder : Ffmpeg

    Codec : H264

    Following is how am configuring h264 for encoding:

        x264_param_default_preset(&this->m_x264Settings, "veryfast", "zerolatency");
        this->m_x264Settings.i_threads = 1;
        this->m_x264Settings.i_width = width / 2;
        this->m_x264Settings.i_height = height / 2;
        this->m_x264Settings.i_keyint_max = 10;//fps;
        this->m_x264Settings.b_intra_refresh = 1;
        this->m_x264Settings.i_fps_num = 10;
        this->m_x264Settings.i_fps_den = 1;
        // Intra refres:
        this->m_x264Settings.i_keyint_max = 25;
        this->m_x264Settings.b_intra_refresh = 1;
        //Rate control:
        this->m_x264Settings.rc.i_rc_method = X264_RC_CRF;
        this->m_x264Settings.rc.f_rf_constant = 25;
        this->m_x264Settings.rc.f_rf_constant_max = 35;
    
        //For streaming:
        this->m_x264Settings.b_repeat_headers = 1;
        this->m_x264Settings.b_annexb = 1;
        x264_param_apply_profile(&this->m_x264Settings, "baseline");
    
        this->m_width = width;
        this->m_height = height;
        this->m_encoder = x264_encoder_open(&this->m_x264Settings);
        x264_picture_alloc(&this->m_picIn,X264_CSP_I420,(width / 2),(height / 2));
        int sws_flags = SWS_BICUBIC;
        m_imgConverCtx = sws_getContext(width, height, PIX_FMT_RGB32, (width/2), (height/2), PIX_FMT_YUV420P,sws_flags, NULL, NULL, NULL);
    

    Thanks in advance, Paul.

  • Android link many static libraries into shared library

    3 février 2014, par nmxprime

    i have 4 static libraries libavcodec.a libavutil.a libswscale.a libx264.a

    I want to link it with libmytest.so

    I tried below Android.mk script

    LOCAL_PATH := $(call my-dir)
    INITIAL_PATH := $(LOCAL_PATH)
    
    include $(CLEAR_VARS)
    LOCAL_MODULE := mytest
    
    LOCAL_SRC_FILES := mytest.c
    
    LOCAL_LDLIBS += -llog
    LOCAL_WHOLE_STATIC_LIBRARIES := libavutil libavcodec libswscale libx264
    
    include $(BUILD_SHARED_LIBRARY)
    

    mytest.c calls many functions from those libraries. The 4 libraries are placed inside PROJECTPATH\jni\.

    But i get undefined reference to all functions from those libraries.

    I tried giving LOCAL_ALLOW_UNDEFINED_SYMBOLS := truewhich allowed me to create shared library, but when i launch the app, i get

    01-22 07:15:15.650: E/AndroidRuntime(9655): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]:  1868 cannot locate 'avcodec_register_all'...
    01-22 07:15:15.650: E/AndroidRuntime(9655):     at java.lang.Runtime.loadLibrary(Runtime.java:370)
    01-22 07:15:15.650: E/AndroidRuntime(9655):     at java.lang.System.loadLibrary(System.java:535)
    
  • Building ffmpeg for ubuntu No working C compiler found

    27 janvier 2014, par Whoami

    I am building ffmpeg on ubuntu. I could able to build yasm-1.2.0, and next i tried building x264. x264 requires minumum of yasm-1.2.0, Hence i tried the below command to build x264.

    ./configure --prefix= --bindir= --extracflgs= --extra-ldflags= 
    

    I got the below error:

    No working C compiler found.
    

    Not sure what error i commited. Could someone kindly tell me what do i have to do?

  • ffmpeg libx264 neon optimization breaks execution

    27 janvier 2014, par nmxprime

    Hi use libx264 source obtained from x264-snapshot-20140122-2245 and compiling using below script

    NDK=~/Android/android-ndk-r7c
    PLATFORM=$NDK/platforms/android-9/arch-arm/
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
    function build_one
    {
    ./configure --prefix=$PREFIX \
    --sysroot=$PLATFORM \
    --disable-avs \
    --disable-lavf \
    --disable-ffms \
    --disable-gpac \
    --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
    --host=arm-linux \
    --enable-static \
    --libdir=$PLATFORM/usr/lib \
    --includedir=$PLATFORM/usr/include \
    --extra-cflags="-march=armv7-a -mfloat-abi=softfp -mfpu=neon -mvectorize-with-neon-quad" \
    --extra-ldflags="-Wl,--fix-cortex-a8" \
    --enable-debug
    

    The config log is:

    platform:      ARM
    system:        LINUX
    cli:           yes
    libx264:       internal
    shared:        no
    static:        yes
    asm:           yes
    interlaced:    yes
    avs:           no
    lavf:          no
    ffms:          no
    mp4:           no
    gpl:           yes
    thread:        no
    opencl:        yes
    filters:       crop select_every
    debug:         yes
    gprof:         no
    strip:         no
    PIC:           no
    bit depth:     8
    chroma format: all
    
    You can run 'make' or 'make fprofiled' now.
    

    I hope the above code compiles and optimizes for NEON execution

    Doubts:

    Why Threads is no, because i didn't specified --disable-thread

    What is cli and it's significance here, also significance of opencl, such that libx264 uses opencl features?


    Then i built ffmpeg 1.2.5with following script

    ./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 " \
    --disable-shared \
    --enable-static \
    --extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog -lx264 $EXTRA_LD_FLAG" \
    --disable-ffplay \
    --disable-everything \
    --enable-avformat \
    --enable-avcodec \
    --enable-libx264 \
    --enable-gpl \
    --enable-encoder=libx264 \
    --enable-encoder=libx264rgb \
    --enable-decoder=h264 \
    --disable-network \
    --disable-avfilter \
    --disable-avdevice \
    --enable-debug=3 \
    $ADDITIONAL_CONFIGURE_FLAG
    

    where

    ADDITIONAL_CONFIGURE_FLAG = --enable-debug=3
    OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mvectorize-with-neon-quad"
    

    The log shows NEON supported.

    When i run the code (called in a while loop),

    ret = avcodec_encode_video2(c, &pkt, picture, &got_output);//avcodec_encode_video(c, finalout, outbuf_size, picture);
    
    fprintf(stderr,"ret = %d, got-out = %d \n",ret,got_output);
    if (ret < 0) 
            fprintf(stderr, "error encoding frame\n");
    
        if (got_output) 
            fprintf(stderr,"encoding frame %3d (size=%5d): (ret=%d)\n", 1, pkt.size,ret);
    

    it runs for 2 or 3 time(during which if(got_output) is not true), then i get SIGSEGV. Tried addr2line and ndk-stack but no use[Though i enabled debug info, ndk-stack cannot find routine info].

    I edited libx264's encoder.c code with some fprintf statements. Posting snippet of code

       if( h->frames.i_input <= h->frames.i_delay + 1 - h->i_thread_frames )
        {
            /* Nothing yet to encode, waiting for filling of buffers */
            pic_out->i_type = X264_TYPE_AUTO;
    fprintf(stderr,"EditLog:: Returns as waiting for filling \n"); //edit
            return 0;
        }
    }
    
    else
    {
        /* signal kills for lookahead thread */
        x264_pthread_mutex_lock( &h->lookahead->ifbuf.mutex );
        h->lookahead->b_exit_thread = 1;
        x264_pthread_cond_broadcast( &h->lookahead->ifbuf.cv_fill );
        x264_pthread_mutex_unlock( &h->lookahead->ifbuf.mutex );
    }
    fprintf(stderr,"After wait for fill \n");
    fprintf(stderr,"h: %p \n",h); //edit
    fprintf(stderr,"h->i_frame = %p \n",&h->i_frame); //edit
    h->i_frame++;
    fprintf(stderr,"after i_frame++");
    

    in log, i don't see after i_frame++, here occurs (may be) the SIGSEGV.

    Please help in solving it. The same works without neon optimization!!