91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 30.96MB
    文件類(lèi)型: .zip
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2024-01-30
  • 語(yǔ)言: 其他
  • 標(biāo)簽: FFmpeg??YUV??H.264??編碼??

資源簡(jiǎn)介

本程序?qū)崿F(xiàn)了YUV像素?cái)?shù)據(jù)編碼為視頻碼流(H.265,H264,MPEG2,VP8等等)。是最簡(jiǎn)單的FFmpeg視頻編碼方面的教程。它包含以下兩個(gè)子項(xiàng)目: simplest_ffmpeg_video_encoder:最簡(jiǎn)單的基于FFmpeg的視頻編碼器。使用libavcodec和libavformat編碼并且封裝視頻。 simplest_ffmpeg_video_encoder_pure:最簡(jiǎn)單的基于FFmpeg的視頻編碼器-純凈版。僅使用libavcodec編碼視頻,不使用libavformat。 1.2版本增加了多平臺(tái)下編譯的支持:Windows,MacOS,以及Linux。

資源截圖

代碼片段和文件信息

/**
?*?最簡(jiǎn)單的基于FFmpeg的視頻編碼器
?*?Simplest?FFmpeg?Video?Encoder
?*?
?*?雷霄驊?Lei?Xiaohua
?*?leixiaohua1020@126.com
?*?中國(guó)傳媒大學(xué)/數(shù)字電視技術(shù)
?*?Communication?University?of?China?/?Digital?TV?Technology
?*?http://blog.csdn.net/leixiaohua1020
?*?
?*?本程序?qū)崿F(xiàn)了YUV像素?cái)?shù)據(jù)編碼為視頻碼流(H264,MPEG2,VP8等等)。
?*?是最簡(jiǎn)單的FFmpeg視頻編碼方面的教程。
?*?通過(guò)學(xué)習(xí)本例子可以了解FFmpeg的編碼流程。
?*?This?software?encode?YUV420P?data?to?H.264?bitstream.
?*?It‘s?the?simplest?video?encoding?software?based?on?FFmpeg.?
?*?Suitable?for?beginner?of?FFmpeg?
?*/

#include?

#define?__STDC_CONSTANT_MACROS

#ifdef?_WIN32
//Windows
extern?“C“
{
#include?“l(fā)ibavutil/opt.h“
#include?“l(fā)ibavcodec/avcodec.h“
#include?“l(fā)ibavformat/avformat.h“
};
#else
//Linux...
#ifdef?__cplusplus
extern?“C“
{
#endif
#include?
#include?
#include?
#ifdef?__cplusplus
};
#endif
#endif


int?flush_encoder(AVFormatContext?*fmt_ctxunsigned?int?stream_index){
int?ret;
int?got_frame;
AVPacket?enc_pkt;
if?(!(fmt_ctx->streams[stream_index]->codec->codec->capabilities?&
CODEC_CAP_DELAY))
return?0;
while?(1)?{
enc_pkt.data?=?NULL;
enc_pkt.size?=?0;
av_init_packet(&enc_pkt);
ret?=?avcodec_encode_video2?(fmt_ctx->streams[stream_index]->codec?&enc_pkt
NULL?&got_frame);
av_frame_free(NULL);
if?(ret? break;
if?(!got_frame){
ret=0;
break;
}
printf(“Flush?Encoder:?Succeed?to?encode?1?frame!\tsize:%5d\n“enc_pkt.size);
/*?mux?encoded?frame?*/
ret?=?av_write_frame(fmt_ctx?&enc_pkt);
if?(ret? break;
}
return?ret;
}

int?main(int?argc?char*?argv[])
{
AVFormatContext*?pFormatCtx;
AVOutputFormat*?fmt;
AVStream*?video_st;
AVCodecContext*?pCodecCtx;
AVCodec*?pCodec;
AVPacket?pkt;
uint8_t*?picture_buf;
AVframe*?pframe;
int?picture_size;
int?y_size;
int?framecnt=0;
//FILE?*in_file?=?fopen(“src01_480x272.yuv“?“rb“); //Input?raw?YUV?data?
FILE?*in_file?=?fopen(“../ds_480x272.yuv“?“rb“);???//Input?raw?YUV?data
int?in_w=480in_h=272;??????????????????????????????//Input?data‘s?width?and?height
int?framenum=100;???????????????????????????????????//frames?to?encode
//const?char*?out_file?=?“src01.h264“;??????????????//Output?Filepath?
//const?char*?out_file?=?“src01.ts“;
//const?char*?out_file?=?“src01.hevc“;
const?char*?out_file?=?“ds.h264“;

av_register_all();
//Method1.
pFormatCtx?=?avformat_alloc_context();
//Guess?Format
fmt?=?av_guess_format(NULL?out_file?NULL);
pFormatCtx->oformat?=?fmt;

//Method?2.
//avformat_alloc_output_context2(&pFormatCtx?NULL?NULL?out_file);
//fmt?=?pFormatCtx->oformat;


//Open?output?URL
if?(avio_open(&pFormatCtx->pbout_file?AVIO_FLAG_READ_WRITE)? printf(“Failed?to?open?output?file!?\n“);
return?-1;
}

video_st?=?avformat_new_stream(pFormatCtx?0);
video_st->time_base.num?=?1;?
video_st->time_base.den?=?25;??

if?(video_st==NULL){
return?-1;
}
//Par

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件??????????28??2015-02-12?17:38??.gitignore
?????文件????19584000??2015-02-12?17:38??ds_480x272.yuv
?????文件????????1053??2015-02-12?17:38??readme.txt
?????文件???????67142??2015-02-12?17:38??simplest_ffmpeg_video_encoder.jpg
?????文件????????1469??2015-02-12?17:38??simplest_ffmpeg_video_encoder.sln
?????文件???????22528??2015-02-12?17:38??simplest_ffmpeg_video_encoder.suo
?????目錄???????????0??2015-02-12?17:38??simplest_ffmpeg_video_encoder\
?????文件??????????61??2015-02-12?17:38??simplest_ffmpeg_video_encoder\.gitignore
?????文件????19294208??2015-02-12?17:38??simplest_ffmpeg_video_encoder\avcodec-56.dll
?????文件?????1341440??2015-02-12?17:38??simplest_ffmpeg_video_encoder\avdevice-56.dll
?????文件?????2201088??2015-02-12?17:38??simplest_ffmpeg_video_encoder\avfilter-5.dll
?????文件?????5721088??2015-02-12?17:38??simplest_ffmpeg_video_encoder\avformat-56.dll
?????文件??????424960??2015-02-12?17:38??simplest_ffmpeg_video_encoder\avutil-54.dll
?????文件?????????632??2015-02-12?17:38??simplest_ffmpeg_video_encoder\compile_cl.bat
?????文件?????????439??2015-02-12?17:38??simplest_ffmpeg_video_encoder\compile_gcc.sh
?????文件?????????462??2015-02-12?17:38??simplest_ffmpeg_video_encoder\compile_mingw.sh
?????文件??????201505??2015-02-12?17:38??simplest_ffmpeg_video_encoder\ds.h264
?????目錄???????????0??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\
?????文件????????7976??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\_mingw.h
?????文件????????5721??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\inttypes.h
?????目錄???????????0??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\
?????文件??????177529??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\avcodec.h
?????文件????????3111??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\avfft.h
?????文件????????3659??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\dv_profile.h
?????文件????????2358??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\dxva2.h
?????文件???????10623??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\old_codec_ids.h
?????文件????????4007??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\vaapi.h
?????文件????????5437??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\vda.h
?????文件????????6200??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\vdpau.h
?????文件????????6035??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\version.h
?????文件????????6062??2015-02-12?17:38??simplest_ffmpeg_video_encoder\include\libavcodec\xvmc.h
............此處省略202個(gè)文件信息

評(píng)論

共有 條評(píng)論