编码域中提取DCT系数和运动矢量

我想从MPEG 4视频中提取DCT系数和运动矢量,而不进行解码。我已经搜索过答案,但没有找到任何有用的东西。

请您友好地分享任何想法、完成此任务的可能性或代码。

不知怎的,我设法编写了一个使用ffmpeg读取编码代码的程序。

void CFfmpegmethods::VideoRead(){    //cout << "this is video read" << endl;    const char *url = "H:/Sanduni_projects/ad_2.mp4";    AVFormatContext *s = NULL;    int ret = avformat_open_input(&s, url, NULL, NULL);    if (ret < 0)        //abort();    AVDictionary *options = NULL;    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();    }    avformat_close_input(&s);   }

回答:

我能够按如下方式提取运动矢量。在这里,我使用坐标生成一个数组。即矢量的初始和目标位置。

static int MV_generation(const AVPacket *pkt){    double x_src_val = 0;    double y_src_val = 0;    double x_dst_val = 0;    double y_dst_val = 0;int ret = avcodec_send_packet(video_dec_ctx, pkt);while (ret >= 0){    ret = avcodec_receive_frame(video_dec_ctx, frame);    if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {        break;    }    if (ret >= 0) {        AVFrameSideData *sd;        sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);        if (sd) {            const AVMotionVector *mvs = (const AVMotionVector *)sd->data;            int size_sd = sd->size;            }        av_frame_unref(frame);    }}return 0;

}

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注