Newest 'libx264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to open AVCodec ?

    28 novembre 2014, par Anton Kasabutski

    I'm tired of searching the solution about this theme. Can anybody help?

    Types:

    AVOutputFormat* m_outFormat;
    AVFormatContext* m_formatContext;
    AVCodecContext* m_videoCodecContext;
    AVCodec* m_videoCodec;
    

    Code:

    avcodec_register_all();
    av_register_all();
    m_outFormat = av_guess_format(NULL,filePath().toUtf8().constData(),NULL);
    //filePath ended like ".mp4"
    if (!m_outFormat)
        return; //all is fine
    avformat_alloc_output_context2(&m_formatContext,NULL,NULL,filePath().toUtf8().constData());
    m_formatContext->oformat->video_id = CODEC_ID_H264;
    m_outFormat=m_formatContext->oformat;
    ////////////////////////////////////////////////////////////////////
    m_videoCodec=avcodec_find_encoder(CODEC_ID_H264);
    m_videoStream = avformat_new_stream(m_formatContext,m_videoCodec);
    if (m_videoStream)
        return; //all is fine
    m_videoCodecContext = avcodec_alloc_context3(m_videoCodec);
    m_videoCodecContext->codec_id = CODEC_ID_H264;
    m_videoCodecContext->width = 1280;
    m_videoCodecContext->height = 720;
    m_videoCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
    m_videoCodecContext->pix_fmt = PIX_FMT_YUV420P;
    av_codec_open2(M_videoCodecContext,m_videoCodec,NULL);
    

    I'm getting an error:

    [libx264 @.....] Codec type or id mismathes.

    av_codec_open2(..) returned (-22 error). Where I did mistake?More info:
    • last ffmpeg
    • Mac Os x 10.10
    • libx264 installed
    • after av_guess_format(...) I've got audio_codec = CODEC_ID_H264, video_codec = CODEC_ID_NONE, long_name MP4(MPEG-4 Part 14) in m_outFormat.
    • after avformat_alloc_context3(...) I've got audio_codec_id = video_codec_id = CODEC_ID_NONE in m_formatContext.
    • after avcodec_find_encoder(CODEC_ID_H264) I've got name = "libx264", id = CODEC_ID_MPEG1VIDEO in m_videoCodec.

      I can share more info if You can say, what do You exactly need.

  • how to use x264 encoder with directshow

    14 octobre 2014, par habibhassani

    i can't figure out how to use x264 with directshow. i installed many thinks that pretend to have x264 encoder in with no use i downloaded the videoLAN x264 binary and when i run it, it shows so fast a console windows, and nothing happen after that

    these is the encoders that i have

    enter image description here

    i am working on windows 8.1 x64

    please help with this issue it's just going to make me crazy hhh, i wanna use x264 because the other encoders that i have installed, either didn't work or encode with so big size.

  • FFMPEG x264 encoder Android

    24 septembre 2014, par DundeeDave

    I've compiled an FFMPEG library for use on Android with libx264 and using the NDK.

    I want to encode an MPEG video file however the application is failing when opening the encoder codec, in avcodec_open2.

    The FFMPEG logs I receive from avcodec_open2 are below with the function returning -22.

    • Picture size %ux%u is invalid.
    • ignoring invalid width/height values
    • Specified pix_fmt is not supported

    On windows this code works fine, it's only on Android that there is a failure. Any ides why this would fail on Android?

    if (!(codec = avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO)))
        {
            return -1;
        }
    
        //Allocate context based on codec
        if (!(context = avcodec_alloc_context3(codec)))
        {
            return -2;
        }
    
        //Setup Context
        // put sample parameters
        context->bit_rate = 4000000;
        // resolution must be a multiple of two
        context->width = 1280;
        context->height = 720;
        // frames per second
        context->time_base = (AVRational){1,25};
        context->inter_quant_bias = 96;
        context->gop_size = 10;
        context->max_b_frames = 1;
        //IDs
        context->pix_fmt = AV_PIX_FMT_YUV420P;
        context->codec_id = AV_CODEC_ID_MPEG1VIDEO;
        context->codec_type = AVMEDIA_TYPE_VIDEO;
    
    
        if (AV_CODEC_ID_MPEG1VIDEO == AV_CODEC_ID_H264)
        {
            av_opt_set(context->priv_data, "preset", "slow", 0);
        }
    
        if ((result = avcodec_open2(context, codec, NULL)) < 0)
        {
            //Failed opening Codec!
        }
    
  • ffmpeg libx264 non-existing PPS 0 referenced

    18 août 2014, par k961

    hello i have installed ffmpeg and libx264 based in the offical tutorial on ffmpeg installation here : https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

    i want to get an stream from mumudvb and pass it to ffmpeg for h264 encoding when i use

    ffserver -f /path/to/config -d
    

    i get this output :

    [h264 @ 0x1ab32c0] non-existing PPS 0 referenced
    [mpegts @ 0x2c7cca0] Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B)): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [h264 @ 0x1ab32c0] non-existing SPS 0 referenced in buffering period
    [h264 @ 0x1ab32c0] non-existing PPS 0 referenced
    [h264 @ 0x1ab32c0] decode_slice_header error
    [h264 @ 0x1ab32c0] no frame!
    [mpegts @ 0x1aadca0] 
    decoding for stream 0 failed
    [mpegts @ 0x1aadca0] decoding for stream 1 failed
    Input #0, mpegts, from 'http://127.0.0.1:9097':
      Duration: N/A, start: 45508.714822, bitrate: N/A
      Program 107 
    [mpegts @ 0x1aadca0]     Stream #0:0[0x42e]: Video: h264 ([27][0][0][0] / 0x001B)[mpegts @ 0x30b0ca0] decoding for stream 1 failed
    , 50 fpsitech@itech-All-Series:~$ , 50 tbr, 90k tbn, 180k tbc
    [mpegts @ 0x1cd5ca0]     Stream #0:1Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    [0x42f](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 48000 Hz, stereo, fltp
    http://127.0.0.1:8888/tv7.ffm: Input/output error
    Input #0, mpegts, from 'http://127.0.0.1:9093':
      Duration: N/A, start: 25560.704144, bitrate: N/A
      Program 103 
        Stream #0:0[0x406]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 16:11 DAR 20:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
        Stream #0:1[0x407](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
        Stream #0:2[0x40b](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    Received signal 2: terminating.
    [mpegts @ 0x30b0ca0] Could not find codec parameters for stream 0 (Video: h264 ([27][0][0][0] / 0x001B)): unspecified size
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    http://127.0.0.1:8888/tv3.ffm: Input/output error
    [mpegts @ 0x1aadca0] Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
    Input #0, mpegts, from 'http://127.0.0.1:9094':
    Received signal 2: terminating.
    Could not find codec parameters for stream 1 (Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp): unspecified sample rate
    Consider increasing the value for the 'analyzeduration' and 'probesize' options
      Duration: N/A, start: 43409.427056, bitrate: N/A
      Program 104 
        Stream #0:0[0x410]Input #0, mpegts, from 'http://127.0.0.1:9098':
    : Video: h264 ([27][0][0][0] / 0x001B), 50 fps, 50 tbr, 90k tbn, 180k tbc
        Stream #0:1[0x411](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
        Stream #0:2[0x415](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    http://127.0.0.1:8888/tv4.ffm: Input/output error
    Received signal 2: terminating.
      Duration: N/A, start: 26351.744300, bitrate: N/A
      Program 108 
        Stream #0:0[0x438]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt470bg), 720x576 [SAR 12:11 DAR 15:11], 25 fps, 50 tbr, 90k tbn, 50 tbc
        Stream #0:1[0x439](per): Audio: aac_latm ([17][0][0][0] / 0x0011), 0 channels, fltp
        Stream #0:2[0x43d](ara): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
    http://127.0.0.1:8888/tv8.ffm: Input/output error
    Received signal 2: terminating.
    

    ffmpeg will gime me the output. but the prooblem is that the outputs bitrate is around 2000k to 3000k it should be 512k

    this is my ffserver config :

    Port 8888
    BindAddress 0.0.0.0
    MaxHTTPConnections 20000
    MaxClients 10000
    MaxBandwidth 1000000
    CustomLog -
    
    File /tmp/ch1.ffm
    FileMaxSize 100M
    ACL allow 127.0.0.1
    launch ffmpeg -i http://127.0.0.1:9094
    
    
    
    Feed ch1.ffm
    Format mpegts
    AudioBitRate 64
    AudioChannels 2
    AudioSampleRate 44100
    #AVOptionAudio flags +global_header
    VideoBitRate 512
    VideoBufferSize 400
    VideoFrameRate 25
    VideoBitRateTolerance 100
    VideoSize 720x576
    VideoGopSize 12
    AudioCodec aac
    VideoCodec libx264
    AVOptionVideo bsf h264_mp4toannexb
    #AVOptionVideo threads 0
    AVOptionVideo threads_type frame
    AVOptionVideo coder 0
    AVOptionVideo bf 0
    AVOptionVideo flags +loop
    AVOptionVideo partitions +parti8x8+parti4x4+partp8x8+partb8x8
    AVOptionVideo me_method hex
    AVOptionVideo subq 7
    AVOptionVideo me_range 16
    AVOptionVideo g 250
    AVOptionVideo keyint_min 10
    AVOptionVideo sc_threshold 40
    AVOptionVideo i_qfactor 0.71
    AVOptionVideo b_strategy 1
    AVOptionVideo qcomp 0.6
    AVOptionVideo qmin 10
    AVOptionVideo qmax 51
    AVOptionVideo qdiff 4
    AVOptionVideo refs 3
    AVOptionVideo directpred 1
    AVOptionVideo trellis 1
    AVOptionVideo wpredp 0
    #AVOptionVideo flags +global_header
    
    StartSendOnKey
    
    
  • how to use x264 dll in another project

    5 août 2014, par Hadi Rasekh

    enter code here I want to use x264 in my project. There is some line in the code said:

    /* Application developers planning to link against a shared library version of * libx264 from a Microsoft Visual Studio or similar development environment * will need to define X264_API_IMPORTS before including this header. * This clause does not apply to MinGW, similar development environments, or non * Windows platforms. */

    But I don't get this line: define X264_API_IMPORTS before including this header

    We can create x264 dll by its configuration and make

        ./configure --enable-shared
        make
    

    but I can not use the dll in my Qt Project.

    I can make my own dll (in another code) and use it in the project. But when I start to use x264 dll in my project I get the following error:

        C:\DataHiding\SourceCode2\GUI\DataHiding\mainwindow.cpp:10: error:
        'pulldown_frame_duration' was not declared in this scope
        qDebug() << pulldown_frame_duration[1];
                 ^