当前位置:首页 > 编程笔记 > 正文
已解决

01-解码-H264转YUV

来自网友在路上 181881提问 提问时间:2023-11-11 13:16:37阅读次数: 81

最佳答案 问答题库818位专家为你答疑解惑

整体方案:
采集端:摄像头采集(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
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"01-解码-H264转YUV":http://eshow365.cn/6-37611-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!