WebRTC VideoEngine超詳細教程(一)——視訊通話的基本流程

來源:互聯網
上載者:User
總述

在前一篇文章中,講解了如何將OPENH264轉碼器整合到WebRTC中,但是OPENH264隻能編碼baseline的H264視頻,而且就編碼品質而言,還是X264最好,本文就來講解一下如何將X264編碼器整合到WebRTC中,為了實現解碼,同時要用到ffmpeg。總體流程和之前一樣,分為重新封裝轉碼器和註冊調用兩大步驟,註冊調用這一步沒有任何不同,主要是重新封裝這一步驟有較大區別。 重新封裝X264編碼功能 首先當然還是要下載X264源碼編譯出相應的庫以供調用。在windows下使用mingw進行編譯,再使用poxports工具匯出庫,最後得到libx264.dll和libx264.lib,同時把x264.h和x264_config.h總共四個檔案放到工程目錄下,並在項目屬性中進行相應配置。
使用x264進行視頻編碼的基本流程如下 [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;          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;  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.