2

I know that one can extract the motion vectors from an h264 encoded via by first setting the flag

av_dict_set(&opts, "flags2", "+export_mvs", 0);

then you can query the side-data for the motion vectors by doing this

sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS);

When I looked online to see if you can do something similar with HEVC encoded videos, I wasn't able to find any information. All I found was this by the definition of "AV_FRAME_DATA_MOTION_VECTORS"

Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec AVCodecContext flags2 option).

The data is the AVMotionVector struct defined in libavutil/motion_vector.h.

but there was no information on exactly which codecs export this motion vector information. How would I go about finding this out?

Ronald S. Bultje
  • 10,828
  • 26
  • 47
John Allard
  • 3,564
  • 5
  • 23
  • 42

1 Answers1

1

If I'm not mistaken h264 is the only codec to print Motion Estimation Vectors.

I would suggest trying out the video filter mestimate.

Also, if you want to have a better ideia what's going on in ffmpeg, check the function ff_print_debug_info2 in libavcodec/mpegvideo.c

tweellt
  • 2,171
  • 20
  • 28
  • To be clear, do you think that I could use the mestimate filter to force h265 encoded video to export the motion vectors in the side-data? Thanks for the response btw – John Allard Nov 17 '17 at 01:31
  • @JohnAllard Yes, mestimate does exactly that, it will add motion vectors values to sidedata. I don't really know the use case of your solution but I should tell you that it's a bit of a slow process. – tweellt Nov 17 '17 at 02:15
  • BTW, mestimate is quite new, so use the latest versions – tweellt Nov 17 '17 at 02:17