gpt4 book ai didi

c++ - av_read_frame() 方法的输入参数

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

我想在不解码的情况下在编码域中读取和打开视频。到目前为止,我已经编写了代码,并且它可以正常工作。但是方法 av_read_frame() 的输出只是给出了零的数量,并且相同的负整数值正在重复。
我不确定我是否将参数正确传递给了方法。请帮忙。

void CFfmpegmethods::VideoRead(){
av_register_all();

const char *url = "H:\\Sanduni_projects\\ad_1.mp4";
AVDictionary *options = NULL;
AVFormatContext *s = avformat_alloc_context(); //NULL;
//AVFormatContext *avfmt = NULL;
//avformat_alloc_context();

AVPacket pkt;

//AVFormatContext *avformat_alloc_context();
//AVIOContext *avio_alloc_context();

//open an input stream and read the header
int ret = avformat_open_input(&s, url, NULL, NULL);

//avformat_find_stream_info(s, &options); //finding the missing information

if (ret < 0)
abort();

av_dict_set(&options, "video_size", "640x480", 0);
av_dict_set(&options, "pixel_format", "rgb24", 0);

if (avformat_open_input(&s, url, NULL, &options) < 0){
abort();
}

av_dict_free(&options);

AVDictionaryEntry *e;

if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
abort();
}
//int i = 0;
while (1){
//Split what is stored in the file into frames and return one for each call
//returns the next frame of the stream
int frame = av_read_frame(s, &pkt);
//cout <<i << " " << frame << endl;
waitKey(30);
//i++;
}

//make the packet free
av_packet_unref(&pkt);

//Close the file after reading
avformat_close_input(&s);

}

最佳答案

方法 av_read_frame() 在读取数据包时输出零,然后给出负值。在我的代码循环中无限运行。因此给出无限数量的负值。

关于c++ - av_read_frame() 方法的输入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43736583/

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