Newest 'libx264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • avconv transcoding drops frames

    8 mars 2015, par ziggestardust

    I have a logitech c920 that I can send perfectly fine to a wowza server with this with excelent results:

    ./capture  -o -c0|avconv -f alsa  -b 128k -i hw:1   -re -i - -vcodec copy  -ar 44100 -bufsize 1835k   -map 0:0 -map 1:0 -f flv rtmp://myhost/live/streamname
    

    (capture program is from here: http://derekmolloy.ie/streaming-video-using-rtp-on-the-beaglebone-black/ I'm not using beaglebone, but his capture software runs excellent on my debian pc)

    However, I want to store the h264 stream from the camera down to disk, and later send it in a lower resolution with avconv so I'm playing with libx264

    It seems I can't even do this without getting drops:

    ./capture  -o -c0|avconv -f alsa  -b 128k -i hw:1   -re -i - -vcodec libx264  -ar 44100 -bufsize 1835k   -map 0:0 -map 1:0 -f flv rtmp://myhost/live/streamname
    

    This is what avconv '-v verbose' shows:

    alsa @ 0x864b940] Estimating duration from bitrate, this may be inaccurate
    Input #0, alsa, from 'hw:1':
      Duration: N/A, start: 22758.998967, bitrate: N/A
        Stream #0.0: Audio: pcm_s16le, 32000 Hz, 2 channels, s16, 1024 kb/s
    .................................................................................................................................[h264 @ 0x8659400] max_analyze_duration reached
    [h264 @ 0x8659400] Estimating duration from bitrate, this may be inaccurate
    Input #1, h264, from 'pipe:':
      Duration: N/A, bitrate: N/A
        Stream #1.0: Video: h264 (Constrained Baseline), yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn, 48 tbc
    Parsing...
    Parsed protocol: 0
    

    ...... and then this :

    Output #0, flv, to 'rtmp://mystream/live/streamname':
      Metadata:
        encoder         : Lavf53.21.1
        Stream #0.0: Audio: libmp3lame, 44100 Hz, 2 channels, s16, 200 kb/s
        Stream #0.1: Video: libx264, yuvj420p, 1280x720 [PAR 1:1 DAR 16:9], q=-1--1, 1k tbn, 25 tbc
    Stream mapping:
      Stream #0:0 -> #0:0 (pcm_s16le -> libmp3lame)
      Stream #1:0 -> #0:1 (h264 -> libx264)
    Press ctrl-c to stop encoding
    [alsa @ 0x864b940] ALSA buffer xrun.
    *** drop!
        Last message repeated 39 times
    *** drop!11 fps=  0 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=40    
        Last message repeated 46 times
    *** drop!22 fps= 21 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=87    
    .    Last message repeated 20 timesss
    .....*** drop!   27 fps= 13 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=108    
        Last message repeated 3 timess
    ..*** drop! fps= 10 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=112    
        Last message repeated 5 timesss
    .*** drop!0 fps=  9 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=118    
    .    Last message repeated 5 timess
    .*** drop!2 fps=  9 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=124    
        Last message repeated 6 timesss
    .*** drop!3 fps=  8 q=0.0 size=       0kB time=0.03 bitrate= 116.9kbits/s dup=0 drop=131    
    ^C    Last message repeated 1 times
    *** drop!
        Last message repeated 3 times
    

    I have tried with ffmpeg but it gives same result with dropped frames.

    Any help appreciated

  • Make images to video using FFMPEG on android not working

    6 mars 2015, par Salmaan

    I built ffmpeg 2.5.4 with libx264 and am using these commands but they are giving error...
    On previous version of ffmpeg they were working fine...

    Here is the command i am using to convert images to video

              String[] ffmpegCommand = {
                        "/data/data/uk.org.humanfocus.hfi/ffmpeg",
                        "-r",
                        Fps,
                        "-i",
                        Environment.getExternalStorageDirectory().getPath()
                                + "/HumanFocus/MarkerFrame/frame%05d.jpg",
                        "-qscale", "0",
                        mFilePathMarker };
    

    Here is my ffmpeg Log

    03-06 10:00:12.579: V/asd(10011): ***Input #0, image2, from '/storage/emulated/0/HumanFocus/MarkerFrame/frame%05d.jpg':***
    03-06 10:00:12.579: V/asd(10011): ***  Duration: 00:00:02.32, start: 0.000000, bitrate: N/A***
    03-06 10:00:12.584: V/asd(10011): ***    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1279x719 [SAR 1:1 DAR 1279:719], 25 fps, 25 tbr, 25 tbn, 25 tbc***
    03-06 10:00:12.584: V/asd(10011): ***Please use -q:a or -q:v, -qscale is ambiguous***
    03-06 10:00:12.589: V/asd(10011): ***No pixel format specified, yuvj420p for H.264 encoding chosen.***
    03-06 10:00:12.589: V/asd(10011): ***Use -pix_fmt yuv420p for compatibility with outdated media players.***
    03-06 10:00:12.594: V/asd(10011): ***[libx264 @ 0x52e80] width not divisible by 2 (1279x719)***
    03-06 10:00:12.594: V/asd(10011): ***Output #0, mp4, to '/storage/emulated/0/HumanFocus/WPOvideos/TEMP/20150306050004.mp4':***
    03-06 10:00:12.594: V/asd(10011): ***    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 11.40 fps***
    03-06 10:00:12.594: V/asd(10011): ***    Metadata:***
    03-06 10:00:12.594: V/asd(10011): ***      encoder         : Lavc56.13.100 libx264***
    03-06 10:00:12.594: V/asd(10011): ***Stream mapping:***
    03-06 10:00:12.594: V/asd(10011): ***  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))***
    03-06 10:00:12.594: V/asd(10011): ***Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height***
    

    Please help me out...
    Where is the issue?

  • Android Error While Using FFMPEG Commands - error while opening encoder for output stream - maybe incorrect parameters such as bit_rate etc

    5 mars 2015, par Arslan Ahmad

    I compiled ffmpeg with libx264 on linux and now when i am running this command

    String[] ffmpegCommandImages = {
                        "/data/data/uk.org.humanfocus.hfi/ffmpeg",
                        "-i", videoPath,
                        "-b:v", "1000k",
                        "-vf", "scale=-1:576",
                        "-c:a", "copy",
                         "-c:v", "libx264", 
                        "-threads", "12",
                        "-b:a", "196k",
                        to };
    

    This is the error I get, posted the log...
    Please help me out.

    ***Starting FFMPEG***
    ***ffmpeg version 2.5.4 Copyright (c) 2000-2015 the FFmpeg developers***   ***  built on Mar  5 2015 19:02:01 with gcc 4.8 (GCC)***   V/asd(26115): ***  configuration:
    --prefix=/home/hfi/Downloads/android-ndk-r10d/sources/ffmpeg-2.5.4/android/arm --enable-shared --disable-static --disable-doc --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-doc --disable-symver --cross-prefix=/home/hfi/Downloads/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
    --target-os=linux --arch=arm --enable-cross-compile --enable-libx264 --enable-gpl --sysroot=/home/hfi/Downloads/android-ndk-r10d/platforms/android-9/arch-arm
    --extra-cflags='-Os -fpic -I /usr/local/include -marm' --extra-ldflags=' -L /usr/local/lib '***
    ***  libavutil      54. 15.100 / 54. 15.100***
    ***  libavcodec     56. 13.100 / 56. 13.100***
    ***  libavformat    56. 15.102 / 56. 15.102***
    ***  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*** E/Runnable(26115): CAlled V/asd(26115): ***Input #0, image2, from '/storage/emulated/0/HumanFocus/MarkerFrame/frame%05d.jpg':*** V/asd(26115): ***  Duration: 00:00:01.76, start: 0.000000, bitrate: N/A*** V/asd(26115): ***    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1279x719 [SAR 1:1 DAR 1279:719], 25 fps, 25 tbr, 25 tbn, 25 tbc*** V/asd(26115): ***Please use -q:a or -q:v,
    -qscale is ambiguous*** V/asd(26115): ***No pixel format specified, yuvj420p for H.264 encoding chosen.*** V/asd(26115): ***Use -pix_fmt yuv420p for compatibility with outdated media players.*** V/asd(26115): ***[libx264 @ 0x52e80] width not divisible by 2 (1279x719)*** V/asd(26115): ***Output #0, mp4, to '/storage/emulated/0/HumanFocus/WPOvideos/TEMP/20150305144005.mp4':*** V/asd(26115): ***    Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 11 fps*** V/asd(26115): ***    Metadata:*** V/asd(26115): ***      encoder         : Lavc56.13.100 libx264*** V/asd(26115): ***Stream mapping:*** V/asd(26115): ***  Stream #0:0 ->
    #0:0 (mjpeg (native) -> h264 (libx264))*** V/asd(26115): ***Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height*** V/asdas(26115):
    ***Ending FFMPEG***
    
  • compile ffmpeg with libx264 for android

    5 mars 2015, par Arslan Ahmad

    What is wrong with the libx264 path please anyone help me? I have compiled libx264 latest source code. When I compiled the ffmpeg source using below x264 path . It wont allow me to record video. Note that: I am compiling libraries by linux

    #!/bin/bash
    ######################################################
    # Usage:
    # put this script in top of FFmpeg source tree
    # ./build_android
    # It generates binary for following architectures:
    # ARMv6 
    # ARMv6+VFP 
    # ARMv7+VFM-ïd16 (Tegra2) 
    # ARMv7+Neon (Cortex-A8)
    # Customizing:
    # 1. Feel free to change ./configure parameters for more features
    # 2. To adapt other ARM variants
    # set $CPU and $OPTIMIZE_CFLAGS 
    # call build_one
    ######################################################
    
    HOME=/home
    NDK=$HOME/hfi/Downloads/android-ndk-r10d
    PLATFORM=$NDK/platforms/android-9/arch-arm
    SYSROOT=$PLATFORM
    PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64
    TOOLCHAIN=$PREBUILT
    
    function build_one
    {
    ./configure \
    --prefix=$PREFIX \
    --enable-shared \
    --enable-nonfree \
    --enable-gpl \
    --enable-libx264 \
    --disable-doc \
    --disable-ffmpeg \
    --disable-ffplay \
    --disable-ffprobe \
    --disable-ffserver \
    --disable-avdevice \
    --disable-doc \
    --disable-symver \
    --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
    --target-os=linux \
    --arch=arm \
    --enable-cross-compile \
    --sysroot=$SYSROOT \
    --extra-cflags="-Os -I /usr/local/include +-fpic $ADDI_CFLAGS" \
    --extra-ldflags="$ADDI_LDFLAGS" \
    $ADDITIONAL_CONFIGURE_FLAG
    make clean
    make
    make install
    }
    CPU=arm
    PREFIX=$(pwd)/android/$CPU
    ADDI_CFLAGS="-marm"
    build_one
    
  • libx264 bitrate to high for streaming

    26 février 2015, par KevinA

    I'm using libx264 to encode video captured at 1080p 24fps from a video camera. The output of the encoder goes to Live555 for streaming. I cannot get the bitrate below 30 mb/s.

    My Current Settings for x264 are:

    if (x264_param_default_preset(&m_pParam, "ultrafast", "zerolatency") != 0){
        return false;
    }
    int fps = 24;
    m_pParam.i_threads = 1;
    m_pParam.i_fps_num = fps;
    m_pParam.i_fps_den = 1;
    m_pParam.i_width = m_iWidthOut;
    m_pParam.i_height = m_iHeightOut;
    
    // One keyframe per X frames:
    m_pParam.i_keyint_max = 60;
    
    //Rate control:
    m_pParam.rc.i_rc_method = X264_RC_CRF;
    m_pParam.rc.f_rf_constant = fps - 5;
    m_pParam.rc.f_rf_constant_max = fps + 5;
    //m_pParam.i_sps_id = 7;
    //For streaming:
    m_pParam.b_repeat_headers = 1;
    m_pParam.b_annexb = 1;
    m_pParam.b_intra_refresh = 1;
    
    if (x264_param_apply_profile(&m_pParam, "main") != 0) {
        return false;
    }
    
    return true;
    

    Changing the preset seems to only slow the encoding rate and consequently the frame rate.

    How can I get the bitrate below 30mb/s so I can stream to something like a phone?