【问题标题】:DCT coefficient and motion vector extraction in encoded domain编码域中的DCT系数和运动矢量提取
【发布时间】:2017-09-24 16:20:09
【问题描述】:

我想从 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);   
}

【问题讨论】:

  • 这是一个帮助网站分享您的代码或向我们展示您尝试过的内容。那么只有我们可以帮助您。
  • 我只是想知道是否可以在没有任何解码过程的情况下从压缩域的视频中提取上述特征。就是这样。
  • 欢迎来到 Stack Overflow!请edit您的问题显示the code you have so far。您应该至少包含您遇到问题的代码的大纲(但最好是minimal reproducible example),然后我们可以尝试帮助解决具体问题。您还应该阅读How to Ask。

标签: c++ opencv machine-learning ffmpeg computer-vision


【解决方案1】:

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

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;

}

【讨论】:

  • 这是我到目前为止的代码。我可以读取编码视频并将数据写入文本文件。但是那里写入的数据不可读。
猜你喜欢
  • 2017-09-02
  • 2011-05-27
  • 2021-11-02
  • 2013-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-23
相关资源
最近更新 更多