jishnujayakumar / MV-Tractus

A simple tool to extract motion vectors from h264 encoded videos.
108 stars 27 forks source link

compile fails #25

Closed LiTangCherry closed 3 years ago

LiTangCherry commented 3 years ago

Thank you for your work!However, I failed at compile, which shows that "redefinition of ‘struct AVPacketList’ 1985 | typedef struct AVPacketList { | ^~~~ In file included from /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/bsf.h:30, from /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/avcodec.h:44, from include/libavformat/avformat.h:319, from extract_mvs.c:29: /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/packet.h:404:16: note: originally defined here 404 | typedef struct AVPacketList { | ^~~~ In file included from extract_mvs.c:29: include/libavformat/avformat.h:1988:3: error: conflicting types for ‘AVPacketList’ 1988 | } AVPacketList; | ^~~~ In file included from /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/bsf.h:30, from /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/avcodec.h:44, from include/libavformat/avformat.h:319, from extract_mvs.c:29: /opt/dev-tools-sources/ffmpeg/build/include/libavcodec/packet.h:407:3: note: previous declaration of ‘AVPacketList’ was here 407 | } AVPacketList; " Do you have any suggestions? Thank you so much!

LiTangCherry commented 3 years ago

Oh, I tackled this problem by changing "include/libavutil/motion_vector.h" and "include/libavformat/avformat.h" in extract_mvs.c to "/opt/dev-tools-sources/ffmpeg/build/include/libavutil/motion_vector.h" and "/opt/dev-tools-sources/ffmpeg/build/include/libavformat/avformat.h". And the same thing is made to extract_mvs_with_frames.c. Hope it helpful!

alanzyt311 commented 3 years ago

@LiTangCherry @jishnujayakumar

Sorry to bother you guys. But I met the same problem about Redefinition just like LiTang's when compiling. After following the above solution by changing #include file mentioned by LiTang. I met another new error message:

extract_mvs.c:38:8: error: unknown type name ‘AVCodecContext’ static AVCodecContext *video_dec_ctx = NULL; ^~~~~~~~~~~~~~

extract_mvs.c: In function ‘open_codec_context’: extract_mvs.c:171:5: error: unknown type name ‘AVCodecContext’; use ‘struct’ keyword to refer to the type AVCodecContext *dec_ctx = NULL; ^~~~~~~~~~~~~~ struct

extract_mvs_with_frames.c:45:1: error: unknown type name ‘AVCodecContext’; use ‘struct’ keyword to refer to the type AVCodecContext *pCodecCtxOrig = NULL; ^~~~~~~~~~~~~~ struct extract_mvs_with_frames.c:46:1: error: unknown type name ‘AVCodecContext’; use ‘struct’ keyword to refer to the type AVCodecContext *pCodecCtx = NULL; ^~~~~~~~~~~~~~ struct

extract_mvs_with_frames.c: In function ‘decode_packet’: extract_mvs_with_frames.c:149:47: error: request for member ‘height’ in something not a structure or union pFrame->linesize, 0, pCodecCtx->height, ^~ extract_mvs_with_frames.c:153:43: error: request for member ‘width’ in something not a structure or union SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,video_frame_count); ^~ extract_mvs_with_frames.c:153:61: error: request for member ‘height’ in something not a structure or union SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height,video_frame_count); ^~ extract_mvs_with_frames.c: In function ‘open_codec_context’: extract_mvs_with_frames.c:230:5: error: unknown type name ‘AVCodecContext’; use ‘struct’ keyword to refer to the type AVCodecContext *dec_ctx = NULL; ^~~~~~~~~~~~~~ struct

extract_mvs_with_frames.c: In function ‘extract_motion_vectors’: extract_mvs_with_frames.c:334:60: error: request for member ‘width’ in something not a structure or union numBytes=avpicture_get_size(AV_PIX_FMT_RGB24, pCodecCtx->width, ^~ extract_mvs_with_frames.c:335:21: error: request for member ‘height’ in something not a structure or union pCodecCtx->height); ^~ extract_mvs_with_frames.c:341:21: error: ‘AVPicture’ undeclared (first use in this function); did you mean ‘AVPictureType’? avpicture_fill((AVPicture *)pFrameRGB, buffer, AV_PIX_FMT_RGB24, ^~~~~~~~~ AVPictureType extract_mvs_with_frames.c:341:21: note: each undeclared identifier is reported only once for each function it appears in extract_mvs_with_frames.c:341:32: error: expected expression before ‘)’ token avpicture_fill((AVPicture *)pFrameRGB, buffer, AV_PIX_FMT_RGB24, ^ extract_mvs_with_frames.c:345:21: error: request for member ‘width’ in something not a structure or union pCodecCtx->width, ^~ extract_mvs_with_frames.c:346:18: error: request for member ‘height’ in something not a structure or union pCodecCtx->height, ^~ extract_mvs_with_frames.c:347:18: error: request for member ‘pix_fmt’ in something not a structure or union pCodecCtx->pix_fmt, ^~ extract_mvs_with_frames.c:348:18: error: request for member ‘width’ in something not a structure or union pCodecCtx->width, ^~

extract_mvs_with_frames.c:349:18: error: request for member ‘height’ in something not a structure or union pCodecCtx->height, ^~

I am pretty sure that my FFMPEG installation is successful. Could you give me some hints on how to solve it. Reall appreciate that.