Newest 'x264' Questions - Stack Overflow

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

Articles published on the website

  • ffmpeg convert from H.264 (High 4:4:4 Profile) to H.265 (Main Profile)

    30 November, by David Alonso Ruiz

    How can I convert a video from H.264 (High 4:4:4 Profile) to H.265 (Main Profile 4:2:0) using ffmpeg?

    I can't do that with this command: ffmpeg -i input.mkv -c:v hevc_nvenc -c:a copy output2.mkv

    That'd return an error, does not recognize the source format

  • x264 lib fails to build on Android, other plugins not included

    24 November, by SOSparachuter1

    On my x86 windows machine, I'm compiling an Android app that links gstreamer using CMake: https://github.com/henkeldi/gstreamer-android/blob/master/app/src/main/cpp/CMakeLists.txt

    I'm using the latest Android binaries provided by gstreamer, so far everything worked and I've successfully linked gstreamer's app plugin. Next I tried to link x264:

    SET(GST_PLUGINS_CORE_LIBS gstx264 gstapp)
    
    SET(GST_PLUGINS_BASE ... x264)
    

    However, doing so results in dozens of these text relocation errors:

    ld:error: relocation R_AARCH64_ADD_ABS_L012_NC cannot be used against symbol x264_cabac_range_lps; recompile with -fPIC
    

    Even after I add the flag -fPIC these do not go away. Doing a bit of digging I see that Android does not allow text relocation since Api23, but that was several years ago. Is there still no fix on Android?

    I also noticed that the videoparsersbad and hls plugins are not in the latest Android gstreamer binaries (version 1.21.2). Are these also not supported on Android?

  • How to use x264 encoder in Ant Media Server v2.5

    22 November, by faraway

    Ant 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

  • ffmpeg conversion x264 [error]: malloc of size 769152 failed

    4 October, by prashanthp

    I am trying to convert video recorded from Android smart watch (.mp4 format) to a format (.mp4) which playable on all browsers. The video recorded from smart watch is not playing in the browsers. so, i've used ffmpeg to convert in into a playable mp4 format.

    But sometimes it is showing error as x264 [error]: malloc of size 503008 failed

    What is the reason for this. Sometimes it's getting converted and sometimes it is showing error .

    Here is the console output.

     /usr/local/ffmpeg_build/ffmpeg/bin/ffmpeg  -i /home/xestatt1/public_html/app/webroot/mobile/uploads/in/Dec152014161945.mp4 -vcodec libx264   -r 24 -s 352*288 -acodec aac  -ab 12k -strict -2  /home/xestatt1/public_html/app/webroot/mobile/uploads/out/ot12.mp4
    
    ffmpeg version 2.5.git Copyright (c) 2000-2014 the FFmpeg developers
      built on Dec 13 2014 05:42:08 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-55)
      configuration: --prefix=/usr/local/ffmpeg_build/ffmpeg --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/ffmpeg_build/x264/include --extra-ldflags=-L/usr/local/ffmpeg_build/x264/lib
      libavutil      54. 15.100 / 54. 15.100
      libavcodec     56. 14.100 / 56. 14.100
      libavformat    56. 15.103 / 56. 15.103
      libavdevice    56.  3.100 / 56.  3.100
      libavfilter     5.  2.103 /  5.  2.103
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/xestatt1/public_html/app/webroot/mobile/uploads/in/Dec152014161945.mp4':
      Metadata:
        major_brand     : 3gp4
        minor_version   : 0
        compatible_brands: isom3gp4
        creation_time   : 2014-12-15 10:50:02
      Duration: 00:00:10.12, start: 0.000000, bitrate: 151 kb/s
        Stream #0:0(eng): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 135 kb/s, 13.14 fps, 50 tbr, 90k tbn, 200 tbc (default)
        Metadata:
          creation_time   : 2014-12-15 10:50:02
          handler_name    : VideoHandle
          encoder         :
        Stream #0:1(eng): Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
        Metadata:
          creation_time   : 2014-12-15 10:50:02
          handler_name    : SoundHandle
    File '/home/xestatt1/public_html/app/webroot/mobile/uploads/out/ot12.mp4' already exists. Overwrite ? [y/N] y
    [libx264 @ 0x13b69120] using SAR=12/11
    [libx264 @ 0x13b69120] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.1 Cache64
    [libx264 @ 0x13b69120] profile High, level 1.3
    [libx264 @ 0x13b69120] 264 - core 142 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - 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=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=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=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to '/home/xestatt1/public_html/app/webroot/mobile/uploads/out/ot12.mp4':
      Metadata:
        major_brand     : 3gp4
        minor_version   : 0
        compatible_brands: isom3gp4
        encoder         : Lavf56.15.103
        Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 352x288 [SAR 12:11 DAR 4:3], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
        Metadata:
          creation_time   : 2014-12-15 10:50:02
          handler_name    : VideoHandle
          encoder         : Lavc56.14.100 libx264
        Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 8000 Hz, mono, fltp, 12 kb/s (default)
        Metadata:
          creation_time   : 2014-12-15 10:50:02
          handler_name    : SoundHandle
          encoder         : Lavc56.14.100 aac
    Stream mapping:
      Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (amr_nb (amrnb) -> aac (native))
    Press [q] to stop, [?] for help
    Past duration 1.000000 too large
    Multiple frames in a packet from stream 1
    Past duration 1.000000 too large
    av_interleaved_write_frame(): Cannot allocate memory
    x264 [error]: malloc of size 769152 failed
    Video encoding failed
    [libx264 @ 0x13b69120] frame I:1     Avg QP:22.20  size:  3166
    [libx264 @ 0x13b69120] mb I  I16..4: 28.3% 70.5%  1.3%
    [libx264 @ 0x13b69120] 8x8 transform intra:70.5%
    [libx264 @ 0x13b69120] coded y,uvDC,uvAC intra: 47.5% 55.3% 12.4%
    [libx264 @ 0x13b69120] i16 v,h,dc,p: 16% 26%  6% 52%
    [libx264 @ 0x13b69120] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 19% 15% 12%  3%  3%  3%  5% 16%
    [libx264 @ 0x13b69120] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16%  2% 20% 10% 16% 14%  4% 11%  6%
    [libx264 @ 0x13b69120] i8c dc,h,v,p: 61% 17% 19%  4%
    [libx264 @ 0x13b69120] kb/s:607.87
    [aac @ 0x13b6a4c0] 2 frames left in the queue on closing
    Conversion failed!
    

    UPDATED

    When i execute this from shell it is working fine. But when i create a script file and trying to execute that script file from php , it is showing error's. I increased the memory limit in php, still it is showing error. Also , we are using ZEND framework. Is there any problems with ZEND??

  • avcodec_find_encoder(AV_CODEC_ID_H264) returns null

    29 September, by 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.