Newest 'libx264' Questions - Stack Overflow

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

Les articles publiés sur le site

  • encode x264(libx264) raw yuv frame data

    26 juin 2015, 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.

  • Write x264_encoder_encode output to file and play it

    20 juin 2015, par mkd156

    I need to encode a video stream using x264 library and write the output to a file. Here is the code I am using for encoding.

    x264_param_t    params;
    x264_param_default(&params);
    x264_param_default_preset(&params,"medium","zerolatency");
    
    params.i_width  = width;
    params.i_height = height;
    params.i_frame_reference    = 1;
    params.rc.i_rc_method       = X264_RC_CRF; //X264_RC_ABR;
    params.rc.f_vbv_buffer_init = 0;
    params.rc.f_rf_constant = 25;
    params.rc.f_rf_constant_max = 35;
    params.rc.f_rate_tolerance  = 0.1;
    params.rc.b_stat_write      = 0;
    params.i_threads        = 1; //0 is auto!!
    params.b_sliced_threads     = 0;
    params.rc.i_lookahead       = 0;
    params.i_sync_lookahead     = 0;
    params.i_bframe             = 0;
    params.b_annexb         = 1; 
    params.b_repeat_headers     = 1;
    params.i_fps_den        = 1;
    params.b_intra_refresh      = 1;
    params.vui.i_chroma_loc     = 0;
    params.i_scenecut_threshold = 0;
    params.analyse.i_subpel_refine = 6; 
    
    x264_param_apply_profile(&params,"baseline");
    
    // Open encoder
    encoder_ = x264_encoder_open(&params);
    
    ...
    
    x264_picture_alloc(&pic_, X264_CSP_I420, width, height);
    
    int size = x264_encoder_encode(encoder_, &nals_, &numNals_, &pic_, &picOut_);  
    
    FILE* pFile = NULL;
    pFile = fopen("h264Output", "wb");
    
    fwrite( nals_[0].p_payload, size, 1, pFile );
    fclose (pFile);
    
    x264_picture_clean(&pic_);
    

    After this I try to open h264Output file with ffPlay.exe but it gives the following error: Invalid data found when processing input.

    Can someone help me what am I doing wrong? I had a look at the following post but it didn't help me. write x264_encoder_encode output nals to h264 file

  • Improve ffmpeg CPU usage by compramising quality

    20 juin 2015, par Hardik Juneja

    I am using FFMpeg for screen capturing. I am looking for a screen capturing tool that will run on 1000 of VMs (windows and mac).The VMs have limited CPU (1 core) and 2GB ram and No GPU.

    Currently I invoke ffmpeg with

    ffmpeg  -y -framerate 8 -f dshow -f gdigrab -i "desktop"  -c:v libx264  -crf 0 -preset ultrafast -threads 0 temp.mkv
    

    I am using gdigrab to capture screen? Is there any better options that might reduce cpu usage? or changing the encoder or format?

    I am aiming for 4-5% reduction in CPU usage.

    Thanks in advance

  • Decode mJPEG to a format usable by libx264

    16 juin 2015, par Dan Tumaykin

    I am compressing frames coming from webcam with libx264. So far I used YUY2 raw frames and swscale to transcode the frames to I420, which is usable by x264.

    Anyway I would like to add support for mJPEG webcams (usually webcam provides both, but mJPEG allows higher frame rates and resolutions). What can I use to transcode mJPEG to some format, that can be used by x264?

  • Why av_find_encoder(AV_CODEC_ID_H264) has no profiles

    14 juin 2015, par SabinManiac

    I have this code:

    int32_t codecs[ ] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8,   AV_CODEC_ID_VP9 };
    AVCodec* codec;
    const AVProfile* profile=nullptr;
    for ( int32_t i=0;isizeof(codecs[0]);++i) {
    codec = avcodec_find_encoder(static_cast(codecs[i]));
    if (codec) {
      profile = codec->profiles;
      printf("%s\n",codec->name);
      if(!profile)
          printf("\t NO PROFILE\n");
      while (profile &&
             profile->profile!=FF_PROFILE_UNKNOWN){
        printf("\t:%s\n",profile->name);
        profile++;
      }
    } else {
      printf("No codec.\n");
    }
    }
    return true;
    

    Why doesn't the encoder have a list of profiles. If I replace avcodec_find_encoder with avcodec_find_decoder I have the profiles listed. I know that the decoder is implemented inside ffmpeg and the encoder in x264, but is there any way to make this work. I need to know what profiles are available(at least for AV_CODEC_ID_H264).