WebRTC Videoengine Ultra-Detailed tutorial (i)--the basic process of video Call

Source: Internet
Author: User
Tags fread goto stdin
General Statement

In the previous article, we explained how to integrate the OPENH264 codec into the WEBRTC, but OPENH264 can only encode baseline H264 video, and in terms of encoding quality, X264 is the best, This article will explain how to integrate the X264 encoder into the WEBRTC, in order to achieve decoding, at the same time to use the ffmpeg. The overall process, as before, is divided into the re-encapsulation codec and the registration call two major steps, the registration call this step is not any different, mainly re-encapsulation this step is a big difference.re-encapsulate X264 encoding functionFirst of all, of course, download the X264 source code to compile the corresponding library for the call. Compile with MinGW under Windows, export the library using the Poxports tool, and finally get Libx264.dll and Libx264.lib, while X264.h and x264_ Config.h A total of four files are placed in the project directory and configured accordingly in the project properties.
The basic flow of video encoding using x264 is as follows[CPP]  View plain copy #include  <stdint.h>   #include  <stdio.h>   #include  <x264.h>      Int main ( int argc, char **argv )    {       int width, height;        x264_param_t param;       x264_picture_t pic;        x264_picture_t pic_out;       x264_t *h;       int i_frame = 0;       int i_frame_ size;       x264_nal_t *nal;       int i_ nal;          /* get default params for preset/ tuning */       if ( x264_param_default_preset ( &param, ) MeDium ", null )  < 0 )             goto fail;          /* configure non-default params  */       param.i_csp = X264_CSP_I420;        param.i_width  = width;       param.i_height =  height;       param.b_vfr_input = 0;        param.b_repeat_headers = 1;       param.b_annexb =  1;          /* apply profile restrictions. */        if ( x264_param_apply_profile ( &param,  "High"  )  < 0 )            goto fail;        &Nbsp;  if ( x264_picture_alloc ( &pic, param.i_csp, param.i_width,  param.i_height )  < 0 )            goto  fail;          h = x264_encoder_open ( &param);        if ( !h )             goto fail;          int luma_size = width  * height;       int chroma_size = luma_size /  4;       /* Encode frames */        for ( ;;  i_frame++ )        {            /* Read input frame */            if ( fread ( pic.img.plane[0], 1, luma_size, stdin )  != luma_size )                break;            if ( fread ( pic.img.plane[1], 1, chroma_size,  stdin )  != chroma_size )                 break;           if ( fread (  pic.img.plane[2], 1, chroma_size, stdin )  != chroma_size )                 break;  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.