1被声明为已否决
其他类似错误请参见:https://blog.csdn.net/qq_24854861/article/details/79757120
pCodecCtx = pFormatCtx->streams[videoIndex]->codec;//不能这么得到codec
正确做法:
pCodecCtx = avcodec_alloc_context3(NULL);
if (pCodecCtx == NULL) {
printf("Could not allocate AVCodecContext\n");
return -1; }
avcodec_parameters_to_context(pCodecCtx, pFormatCtx->streams[videoIndex]->codecpar);
pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
if (pCodec == NULL) {
printf("Codec not found.\n");
return -1; }
fopen_s(&fp,filename, "w+b");//fopen不可用
2 小记
AVInputFormat:封装格式mp4,avi
AVStream[2]:0视频流 1音频流 index:标识符0/1
AVPacket:h.264:AVCodec
AVFrame:yuv
AVFormatContext->AV
AVStream[2]:0视频流 1音频流 index:标识符0/1
AVPacket:h.264:AVCodec
AVFrame:yuv
AVFormatContext->AV
H264文件头数据其实是一段包含SPS(序列参数集)、PPS(图像参数集)的数据,里面的参数用来配置解码器的初始化。
H264格式文件中每一段NALU的长度不是固定的,这就需要在读取文件中做判断。
H264格式文件中每一段NALU的长度不是固定的,这就需要在读取文件中做判断。
AVFormatContext *pFormatCtx = NULL;
AVCodecContext *pCodecCtx = NULL;
AVCodec *pCodec;
<
AVCodecContext *pCodecCtx = NULL;
AVCodec *pCodec;