无锡网站关键词优化,工作5年体重飙400斤,网站建设与管理教程视频教程,深圳网站建设服务合同整体方案: 采集端:摄像头采集(YUV)-编码(YUV转H264)-RTMP推流 客户端:RTMP拉流-解码(H264转YUV)-YUV显示(SDL2)
H264码流转YUV是视频解码部分,具体的代码实现如下。
#include stdio.h
#include stdlib.h
#ifdef __cplusplus
ext…整体方案: 采集端:摄像头采集(YUV)-编码(YUV转H264)-RTMP推流 客户端:RTMP拉流-解码(H264转YUV)-YUV显示(SDL2)
H264码流转YUV是视频解码部分,具体的代码实现如下。
#include stdio.h
#include stdlib.h
#ifdef __cplusplus
extern "C"
{
#endif
#include libavformat/avformat.h
#include libavcodec/avcodec.h
#include libavutil/imgutils.h
#include libswscale/swscale.h
#ifdef __cplusplus
}
#endifint main(int argc, char *argv[])
{char* in_file = NULL;char* out_file = NULL;av_log_set_level(AV_LOG_INFO);if(argc 3){av_log(NULL, AV_LOG_ERROR, "缺少输入文件和输出文件参数");return -1;}in_file = argv[1];out_file = argv[2];AVFormatContext *fmt_ctx = NULL;AVCodecContext *cod_ctx = NULL;AVCodec *cod = NULL;struct SwsContext *img_convert_ctx = NULL;int ret = 0;AVPacket packet;//第一步创建输入文件AVFormatContextfmt_ctx = avformat_alloc_context();if (fmt_ctx == NULL){ret = -1;av_log(NULL, AV_LOG_ERROR,"alloc fail");goto __ERROR;}if (avformat_open_input(fmt_ctx