Newest 'x264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • write x264_encoder_encode output nals to h264 file

    17 mai 2013, par Zetlb

    I'm trying to do a life stream software. What I'm trying is to use x264's lib to encode to h264 on server side and ffmpeg to decode on client side. After some failed attemps of doing it directly I decided to simplify, and the first thing I am trying to do is simply to encode frames with x264_encoder_encode and writing the resulting NALs to a file. Now I want to test if that file es correct.

    To initialize the encoder I do:

    x264_param_t param;
    x264_param_default_preset(&param, "veryfast", "zerolatency");
    param.i_threads = 1;
    param.i_width = a_iWidth;
    param.i_height = a_iHeight;
    param.i_fps_num = a_iFPS;
    param.i_fps_den = 1;
    param.i_keyint_max = a_iFPS;
    param.b_intra_refresh = 1;
    param.rc.i_rc_method = X264_RC_CRF;
    param.rc.i_vbv_buffer_size = 1000000;
    param.rc.i_vbv_max_bitrate =500;    //For streaming:
    param.b_repeat_headers = 1;
    param.b_annexb = 1;
    x264_param_apply_profile(&param, "baseline");
    encoder = x264_encoder_open(&param);
    

    Then when I have an image ( RGBA image ) I convert it to YUV420P and then I call x264_encoder_encode :

    int frame_size = x264_encoder_encode(encoder, &nals, &num_nals, picture, &pic_out);
    if (frame_size > 0)
    {
        m_vNALs.push_back( (char*)nals[0].p_payload );
        m_vSizes.push_back( frame_size );
    
        return frame_size;
    }
    

    Everything appears to be valid, frame_size returns non-zero positive value and all the others parameters appears to be ok. Every NAL starts with correct code.

    So I'm writing all the nals to a file:

    FILE* pFile;
    pFile = fopen("file.h264", "wb");
    for( int nIndex = 0; nIndex < m_vNALs.size(); nIndex++ )
    {
        fwrite( m_vNALs[ nIndex ], m_vSizes[ nIndex ], 1, pFile );
    }
    

    Now I have file.h264 file. So to test this file I use ffmpeg.exe ( I'm on windows ), and I get this output:

    [h264 @ 00000000021c5a60] non-existing PPS referenced
    [h264 @ 00000000021c5a60] non-existing PPS 0 referenced
    [h264 @ 00000000021c5a60] decode_slice_header error
    [h264 @ 00000000021c5a60] no frame!
    [h264 @ 00000000021c5a60] non-existing PPS referenced
    [h264 @ 00000000021b74a0] max_analyze_duration 5000000 reached at 5000000
    [h264 @ 00000000021b74a0] decoding for stream 0 failed
    [h264 @ 00000000021b74a0] Could not find codec parameters for stream 0 (Video: h
    264): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [h264 @ 00000000021b74a0] Estimating duration from bitrate, this may be inaccura
    te
    file.h264: could not find codec parameters
    

    vlc also can't play the file.

    ffplay tells:

    file.h264: Invalid data found when processing input
    

    What is wrong?????

    Thanks in advance, Zetlb

  • x264_encoder_open always return null

    16 mai 2013, par chinayin

    this is my code

    x264_param_default(&m_X264Param) ;

    nRet = x264_param_default_preset(&m_X264Param,"medium","zerolatency") ;
    if (nRet)
    {
        return -1;
    }
    if (cpMain == Param.nProfile)
    {
        nRet = x264_param_apply_profile(&m_X264Param,"main") ;
    }
    else if (cpSimple == Param.nProfile)
    {
        nRet = x264_param_apply_profile(&m_X264Param,"baseline") ;
    }
    else if (cpComplex == Param.nProfile)
    {
        nRet = x264_param_apply_profile(&m_X264Param,"high");
    }
    if (nRet)
    {
        return -1;
    }
    m_X264Param.i_width = Param.nWidth ;
    m_X264Param.i_height = Param.nHeight ;
    m_X264Param.i_threads = X264_THREADS_AUTO ;
    m_X264Param.i_log_level = X264_LOG_NONE ;
    m_X264Param.rc.i_bitrate = Param.nBitRate ;
    m_X264Param.rc.i_rc_method = X264_RC_ABR ;
    m_X264Param.i_csp          =  X264_CSP_I420 ;
    

    m_pX264Handle = x264_encoder_open(&m_X264Param) ;

    but it always return null it is my first time use it did i miss some key param? is anyone who can tell me the answer! thank you very much and best regards

  • How to build ffmpeg and x264 for iOS 6.0 ?

    16 mai 2013, par user2388180

    Here's my configuration:

    ./configure --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-avfilter --disable-debug --disable-decoders --enable-cross-compile --disable-encoders --disable-armv5te  --enable-decoder=h264 --enable-encoder=libx264 --enable-pic --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk --target-os=darwin --arch=arm --cpu=cortex-a8 --extra-cflags='-arch armv7' --disable-asm
    

    I then run make and make install. But there's no file in /usr/local.

  • how to built ffmpeg X264 for ios6.0 ?

    16 mai 2013, par user2388180

    ./configure --enable-libx264 --enable-gpl --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-avfilter --disable-debug --disable-decoders --enable-cross-compile --disable-encoders --disable-armv5te --enable-decoder=h264 --enable-encoder=libx264 --enable-pic --cc=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc --as='gas-preprocessor/gas-preprocessor.pl /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc' --extra-ldflags='-arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk' --sysroot=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk --target-os=darwin --arch=arm --cpu=cortex-a8 --extra-cflags='-arch armv7' --disable-asm

    make,make install;

    but it's no any file in urs/local
    How to correctly compile ? thanks!

  • Encoding a video in FFmpeg to X264 and have it playable in Quicktime

    7 mai 2013, par illu

    I am wondering which command line settings i need to explicitly set (or avoid) to make a video encoded into x264 (in the mp4 format) using ffmpeg by default playable in Quicktime. I find that a number of the predefined preset files work for me but some of them won't, for example I can't get any of the lossless ones to work and I'm interested in those ones as well. For example libx264-lossless_max.ffpreset will encode my video but it's only playable in VLC, not in Quicktime. In Quicktime the video stays black. I know Perian is an option but I want my file to be playable without installing Perian. Thanks for your help.