如何在ffmpeg的extract_mvs.c上用“框架类型"替换“标志" [英] How to replace 'flags' with 'frame types' on ffmpeg's extract_mvs.c

查看:164
本文介绍了如何在ffmpeg的extract_mvs.c上用“框架类型"替换“标志"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从ffmpeg提取运动矢量以用于计算机视觉项目.我一直在寻找一种以有意义的方式提取此信息的简便方法.

I am in the process of extracting motion vectors from ffmpeg to use in a computer vision project. I have been looking for an easy way to extract this information in a meaningful way.

在阅读不同的帖子和其他网站时,我在FFmpeg的示例文件夹中遇到了extract_mvs.c.我注意到,在此文件生成的数据(编译后)中,有一个我想修改的标志列,以使其打印帧类型,而不是如下所示的0x0s.

While reading through different posts and other websites, I came across the extract_mvs.c in the example folder of FFmpeg. I noticed that out of the data produced by this file (after it has been compiled) there is a flag column which I would like to modify, to make it print frame types instead of 0x0s as shown below.

我从自己编码.

提取后的extract_mvs.c文件返回如下信息:

The extract_mvs.c file after it is compiled, returns information like this:

framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,flags
2,-1,16,16,   8,   8,   8,   8,0x0
2, 1,16,16,   8,   8,   8,   8,0x0
2, 1,16,16,  24,   8,  24,   8,0x0
2, 1,16,16,  40,   8,  40,   8,0x0
2, 1,16,16,  56,   8,  56,   8,0x0
2, 1,16,16,  72,   8,  72,   8,0x0
2, 1,16,16,  88,   8,  88,   8,0x0
...
297, 1,16,16, 248, 280, 248, 280,0x0
297, 1,16,16, 264, 280, 264, 280,0x0
297,-1,16,16, 278, 279, 280, 280,0x0
297, 1,16,16, 280, 280, 280, 280,0x0
297, 1,16,16, 296, 280, 296, 280,0x0
297, 1,16,16, 312, 280, 312, 280,0x0
297, 1,16,16, 328, 280, 328, 280,0x0
297, 1,16,16, 344, 280, 344, 280,0x0

理想情况下,我想要实现的是:

Ideally what I want to achieve is:

framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,frametypes
2,-1,16,16,   8,   8,   8,   8,B
2, 1,16,16,   8,   8,   8,   8,B
2, 1,16,16,  24,   8,  24,   8,B
2, 1,16,16,  40,   8,  40,   8,B
2, 1,16,16,  56,   8,  56,   8,B
2, 1,16,16,  72,   8,  72,   8,B
2, 1,16,16,  88,   8,  88,   8,B
...
297, 1,16,16, 248, 280, 248, 280,P
297, 1,16,16, 264, 280, 264, 280,P
297,-1,16,16, 278, 279, 280, 280,P
297, 1,16,16, 280, 280, 280, 280,P
297, 1,16,16, 296, 280, 296, 280,P
297, 1,16,16, 312, 280, 312, 280,P
297, 1,16,16, 328, 280, 328, 280,P
297, 1,16,16, 344, 280, 344, 280,P

文件中需要修改的部分是如此处所示,其中 mv-> flags 需要替换为帧类型变量.我想到了用指针引用AVFrame结构并调用pict类型.但不知道构建基块会如何.有帮助吗?

The part that requires modification in the file is shown here, where mv->flags needs to be replaced with frame type variable. I thought of making a reference to AVFrame struct with a pointer and call the pict-type. But not sure how the building blocks would be. Any help?

推荐答案

我设法找出如何用帧类型替换标志.我只是将此行打印功能更改为这个:

I managed to find out how to replace flags with frame type. I simply changed this line print function to this:

                printf("%d,%2d,%2d,%2d,%4d,%4d,%4d,%4d,%c\n",
                    video_frame_count, mv->source,
                    mv->w, mv->h, mv->src_x, mv->src_y,
                    mv->dst_x, mv->dst_y, av_get_picture_type_char(frame->pict_type));

然后您可以更改标题行 标志以读取帧类型:

printf("framenum,source,blockw,blockh,srcx,srcy,dstx,dsty,frametypes\n")

这篇关于如何在ffmpeg的extract_mvs.c上用“框架类型"替换“标志"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆