hanatos / vkdt

raw photography workflow that sucks less
https://jo.dreggn.org/vkdt
BSD 2-Clause "Simplified" License
389 stars 36 forks source link

Compile Error with i-vid Module #138

Closed jedypod closed 2 months ago

jedypod commented 2 months ago

Hello! I've been having a lot of fun playing around with vkdt the last 6 months or so, thanks for all the great work!

I just wanted to report a small compile issue I consistently run into:

The error goes something like this:

clang -Wall -pipe -I. -D_GNU_SOURCE -std=c11 -Ipipe -I. -fPIC -DVKDT_DSO_BUILD -Wall -pipe -O3 -march=x86-64 -DNDEBUG  -I/usr/include/ffmpeg  -shared pipe/modules/i-vid/main.c  -o pipe/modules/i-vid/libi-vid.so  -s -lavformat -lavcodec -lswresample  -ldl
pipe/modules/i-vid/main.c:472:42: error: no member named 'frame_num' in 'struct AVCodecContext'; did you mean 'frame_number'?
  472 |     if(mod->graph->frame + 1 != d->vctx->frame_num) // zero vs 1 based
      |                                          ^~~~~~~~~
      |                                          frame_number
/usr/include/ffmpeg/libavcodec/avcodec.h:1037:9: note: 'frame_number' declared here
 1037 |     int frame_number;
      |         ^
1 error generated.
make[2]: *** [Makefile:158: pipe/modules/i-vid/libi-vid.so] Error 1
make[2]: Leaving directory '/work/dev/image/vkdt/vkdt-master/src'
make[1]: *** [Makefile:104: src] Error 2
make[1]: Leaving directory '/work/dev/image/vkdt/vkdt-master'
make: *** [Makefile:7: all] Error 2

I think it might be related to the version of ffmpeg / libavcodec I have installed on my Rocky Linux 9 installation: I have ffmpeg 5.1.6 installed:

$ rpm -q ffmpeg-devel
ffmpeg-devel-5.1.6-1.el9.x86_64

And in that header, the property seems to be called frame_number not frame_num: see this excerpt from avcodec.h starting at line 1028:

    /**
     * Frame counter, set by libavcodec.
     *
     * - decoding: total number of frames returned from the decoder so far.
     * - encoding: total number of frames passed to the encoder so far.
     *
     *   @note the counter is not incremented if encoding/decoding resulted in
     *   an error.
     */
    int frame_number;

To resolve the compile error I open the file src/pipe/modules/i-vid/main.c and change line 472 from if(mod->graph->frame + 1 != d->vctx->frame_num) // zero vs 1 based to if(mod->graph->frame + 1 != d->vctx->frame_number) // zero vs 1 based

and then it compiles successfully.

Just thought I would report this and see if there was a way to get it fixed or maybe support multiple libavcodec versions if there has been a change in that property name.

Hope it helps!

hanatos commented 2 months ago

heya, thanks for reporting. this is ffmpeg 5 vs 6 (i have 6). not sure simply fixing up things in this one place will make the rest of the video code compatible with the older ffmpeg. there are some more deprecated symbols that i removed from the vkdt code. if you don't depend on video input/output it's probably better to disable this in config.mk, something like:

VKDT_USE_FFMPEG=0
export VKDT_USE_FFMPEG

i should probably look into a way of checking the version here.