Newest 'x264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • avcodec_find_encoder(AV_CODEC_ID_H264) returns null

    22 janvier, par Monjura Rumi

    I am building an android application which will encode image captured from camera preview and later decode it. I am using ffmpeg library to encode and decode. To build static library with x264 I have used this tutorial. http://dl.dropbox.com/u/22605641/ffmpeg_android/main.html. As a source code of ffmpeg if I use the one downloaded from the link given in tutorial I can built it but can't build library if i use source code downloaded from here git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg. I have built library in ubuntu and using it in windows 7 in Eclipse. As I need only h264 encoder and decoder I have used following code for ffmpeg, slightly modified from tutorial.

    #!/bin/bash
    
    NDK=~/Documents/android-ndk-r8e
    PLATFORM=$NDK/platforms/android-8/arch-arm
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
    PREFIX=/home/android-ffmpeg
    
    function build_one
    {
        ./configure --target-os=linux --prefix=$PREFIX \
        --enable-cross-compile \
        --enable-runtime-cpudetect \
        --disable-asm \
        --arch=arm \
        --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
        --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
        --disable-stripping \
        --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
        --sysroot=$PLATFORM \
        --enable-nonfree \
        --enable-version3 \
        --disable-everything \
        --enable-gpl \
        --disable-doc \
        --enable-avresample \
        --disable-ffplay \
        --disable-ffserver \
        --enable-ffmpeg \
        --disable-ffprobe \
        --enable-avcodec \
        --enable-libx264 \
        --enable-encoder=libx264 \
        --enable-encoder=libx264rgb \
        --enable-decoder=h263 \
        --enable-decoder=h264 \
        --enable-decoder=svq3 \   
        --enable-zlib \
        --enable-gpl \
        --enable-pic \
        --disable-devices \
        --disable-avdevice \
        --extra-cflags="-I/home/android-ffmpeg/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
        --extra-ldflags="-L/home/android-ffmpeg/lib"
    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 -L$PREFIX/lib  -soname libffmpeg.so -shared -nostdlib  -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
    }
    
    build_one
    

    After building library I have been able to build android ndk. A little part of my JNI code is here.

    JNIEXPORT jint JNICALL Java_com_example_testjava_TestjniActivity_initencoder(JNIEnv* env,jobject obj){
    
        av_register_all();
        avcodec_register_all();
        codec = avcodec_find_encoder(AV_CODEC_ID_H264);
        if (!codec) {
          __android_log_write(ANDROID_LOG_INFO, "debug", "not found");                
           return -1;
        }
    .
    .
    .
    }
    

    When I run my java source code that calls initencoder() I get -1 as return value and logcat prints "not found". That means avcodec_find_encoder() returns null and if condition is being ok. I don't know what's wrong. Why this function is returning null? I have searched a lot but did not find any solution that could guide me to right direction. some says to use avcodec_init(). But ndk-build command fails and shows error saying undefined reference to 'avcodec_init()'. I have started with library build because I thought may be I am doing wrong from the first stage. Did I make any mistake in library building like not enabling things that I should? Please help me here. This is kind of urgent for me.

  • Per macroblock encoding in libx264

    12 janvier, par Wei.M

    I know that in x264 encoding, the process is going on with the unit of macroblock. However, is that possible to set the parameters for each macroblocks? For example, if I want to let the QP of some specific area to be smaller than others. Is that possible? If I need to modify the functions and Apis in libx264, where should I begin?

  • libx264 : which parameters can be changed on fly ?

    12 janvier, par Dan Tumaykin

    I know that it is possible to change some encoder parameters on fly, using x264_encoder_reconfig(). From this commit I can deduce that we can change ratecontrol parameters - but I was unable to find a clear list of parameters that may be changed.

    Question: which parameters of x264 encoder can be changed on fly?

  • Why pkg-config overrides 'prefix' with another default one ?

    12 janvier, par SteveH

    I have an issue in using pkg-config to link some libraries to a program. The problem is 'prefix' variable in each library pkg-config files (*.pc) are overridden with an unwanted directory leading to building the program could not find the library's header and lib files.

    Here, one of '*.pc' files, x264.pc:

    prefix=/e/x264/x64-windows-rel  
    exec_prefix=${prefix}   
    libdir=${exec_prefix}/lib   
    includedir=${prefix}/include    
    ...
    

    I run this from MSYS2 terminal:

    pkg-config --cflags --debug x264
    

    This is some of the output it traced out:

    ...
     Parsing package file 'D:/msys64/usr/local/lib/pkgconfig\x264.pc'
     line>prefix=/e/x264/x64-windows-rel
     Variable declaration, 'prefix' overridden with 'D:/msys64/usr/local'
    ...
    

    Note that MSYS2 and pkg-config are updated to newest versions.

    Could anybody tell me why it happens and how to solve the issue without renaming 'prefix' to something else.? Thanks.

  • encode x264(libx264) raw yuv frame data

    12 janvier, par Mohamed El-Sayed

    I am trying to encode an MP4 video using raw YUV frames data, but I am not sure how can I fill the plane data (preferably without using other libraries like ffmpeg)

    The frame data is already encoded in I420, and does not need conversion.

    Here is what I am trying to do:

    const char *frameData = /* Raw frame data */;
    
    x264_t *encoder = x264_encoder_open(&param);
    x264_picture_t imgInput, imgOutput;
    x264_picture_alloc(&imgInput, X264_CSP_I420, width, height);
    
    // how can I fill the struct data of imgInput
    
    x264_nal_t *nals;
    int i_nals;
    int frameSize = x264_encoder_encode(encoder, &nals, &i_nals, &imgInput, &imgOutput);
    

    The equivalent command line that I have found is :

     x264 --output video.mp4 --fps 15 --input-res 1280x800 imgdata_01.raw 
    

    But I could not figure out how the app does it.

    Thanks.