Modify /opt/opencv/opencv-3.2.0/modules/videoio/src/cap_ffmpeg_impl.hpp, add the following in the header:
#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22) #define CODEC_FLAG_GLOBAL_HEADER AV_CODEC_FLAG_GLOBAL_HEADER #define AVFMT_RAWPICTURE 0x0020
Save and recompile.