gpt4 book ai didi

visual-c++ - ffmpeg 的“avcodec_decode_video”不起作用

转载 作者:行者123 更新时间:2023-12-04 23:34:27 27 4
gpt4 key购买 nike

我使用 vc++ express,我将使用 ffmpeg ..

但是在第一个程序中我遇到了麻烦。

vc++ 说 '标识符'avcodec_decode_video':找不到标识符'关于编译过程。

我不知道为什么....

接下来是我编码的...
.

include "avcodec.h"

include "avformat.h"

include "swscale.h"

int main(int argc, char *argv[])

{
av_register_all();

AVFormatContext *pFormatCtx;

// Open video file

if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)

return -1; // Couldn't open file

// Retrieve stream information

if(av_find_stream_info(pFormatCtx)<0)

return -1; // Couldn't find stream information

// Dump information about file onto standard error

dump_format(pFormatCtx, 0, argv[1], 0);


int i;

AVCodecContext *pCodecCtx;

// Find the first video stream

int videoStream=-1;

for(i=0; i<pFormatCtx->nb_streams; i++)

if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO) {

videoStream=i;

break;

}

if(videoStream==-1)

return -1; // Didn't find a video stream

// Get a pointer to the codec context for the video stream

pCodecCtx=pFormatCtx->streams[videoStream]->codec;

AVCodec *pCodec;


// Find the decoder for the video stream

pCodec=avcodec_find_decoder(pCodecCtx->codec_id);

if(pCodec==NULL) {

fprintf(stderr, "Unsupported codec!\n");

return -1; // Codec not found

}

// Open codec

if(avcodec_open(pCodecCtx, pCodec)<0)

return -1; // Could not open codec

AVFrame *pFrame;

// Allocate video frame

pFrame=avcodec_alloc_frame();

// Allocate an AVFrame structure

AVFrame* pFrameRGB=avcodec_alloc_frame();

if(pFrameRGB==NULL)

return -1;

uint8_t *buffer;

int numBytes;

// Determine required buffer size and allocate buffer

numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx->width,pCodecCtx->height);

buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

// Assign appropriate parts of buffer to image planes in pFrameRGB

// Note that pFrameRGB is an AVFrame, but AVFrame is a superset

// of AVPicture

avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,pCodecCtx->width, pCodecCtx->height);

int frameFinished;

AVPacket packet;

i=0;

while(av_read_frame(pFormatCtx, &packet)>=0) {

if(packet.stream_index==videoStream) {

**// here makes compile error**

avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,packet.data, packet.size);

if(frameFinished) {

img_convert((AVPicture *)pFram eRGB, PIX_FMT_RGB24, (AVPicture*)pFrame, pCodecCtx->pix_fmt,pCodecCtx->width, pCodecCtx->height);

}
av_free_packet(&packet);
}
av_free(buffer);

av_free(pFrameRGB);

av_free(pFrame);

avcodec_close(pCodecCtx);

av_close_input_file(pFormatCtx);


return 0;

}

最佳答案

也许只是因为 avcodec_decode_video 在 ffmpeg 中被 avcodec_decode_video2 取代了?
http://cekirdek.pardus.org.tr/~ismail/ffmpeg-docs/deprecated.html

关于visual-c++ - ffmpeg 的“avcodec_decode_video”不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8440829/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com