MCJack123 / sanjuuni

Converts images and videos into a format that can be displayed in ComputerCraft.
GNU General Public License v2.0
32 stars 5 forks source link

error while compiling sanjuuni.o #25

Closed A765-ALEX closed 2 months ago

A765-ALEX commented 2 months ago

I get this error on linux mint (a ubuntu based distro), using the latest versions of ffmpeg, libpoco-dev, libavformat etc. installed via apt

g++ -o obj/sanjuuni.o -c  -g -O2  -std=c++17 src/sanjuuni.cpp
src/sanjuuni.cpp: In function ‘int main(int, const char**)’:
src/sanjuuni.cpp:1053:41: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘duration’; did you mean ‘pkt_duration’?
 1053 |                 totalDuration += frame->duration;
      |                                         ^~~~~~~~
      |                                         pkt_duration
src/sanjuuni.cpp:1150:116: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘duration’; did you mean ‘pkt_duration’?
 1150 | ters, colors, palette, w / 2, h / 3) << "sleep(" << (frame->duration * av_q2d(format_ctx->streams[video_stream]->time_base)) << ")\n";
      |                                                             ^~~~~~~~
      |                                                             pkt_duration
src/sanjuuni.cpp:1234:27: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘ch_layout’; did you mean ‘channel_layout’?
 1234 |                 newframe->ch_layout = AV_CHANNEL_LAYOUT_MONO;
      |                           ^~~~~~~~~
      |                           channel_layout
src/sanjuuni.cpp:1234:39: error: ‘AV_CHANNEL_LAYOUT_MONO’ was not declared in this scope; did you mean ‘AV_CH_LAYOUT_MONO’?
 1234 |                 newframe->ch_layout = AV_CHANNEL_LAYOUT_MONO;
      |                                       ^~~~~~~~~~~~~~~~~~~~~~
      |                                       AV_CH_LAYOUT_MONO
src/sanjuuni.cpp:1236:80: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘ch_layout’; did you mean ‘channel_layout’?
 1236 |  if ((error = swr_alloc_set_opts2(&resample_ctx, &newframe->ch_layout, AV_SAMPLE_FMT_U8, 48000, &frame->ch_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL)) < 0) {
      |                                                             ^~~~~~~~~
      |                                                             channel_layout
src/sanjuuni.cpp:1236:124: error: ‘AVFrame’ {aka ‘struct AVFrame’} has no member named ‘ch_layout’; did you mean ‘channel_layout’?
 1236 | ctx, &newframe->ch_layout, AV_SAMPLE_FMT_U8, 48000, &frame->ch_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL)) < 0) {
      |                                                             ^~~~~~~~~
      |                                                             channel_layout
src/sanjuuni.cpp:1236:34: error: ‘swr_alloc_set_opts2’ was not declared in this scope; did you mean ‘swr_alloc_set_opts’?
 1236 |                     if ((error = swr_alloc_set_opts2(&resample_ctx, &newframe->ch_layout, AV_SAMPLE_FMT_U8, 48000, &frame->ch_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL)) < 0) {
      |                                  ^~~~~~~~~~~~~~~~~~~
      |                                  swr_alloc_set_opts
make: *** [Makefile:26: obj/sanjuuni.o] Error 1

Trying to do the "did you mean..." edits in the source files i have a few less errors, but it still won't compile idk how to program in c++, so heres the error and an issue instead of a pr

g++ -o obj/sanjuuni.o -c  -g -O2  -std=c++17 src/sanjuuni.cpp
src/sanjuuni.cpp: In function ‘int main(int, const char**)’:
src/sanjuuni.cpp:1236:53: error: cannot convert ‘SwrContext**’ to ‘SwrContext*’
 1236 |                     if ((error = swr_alloc_set_opts(&resample_ctx, &newframe->channel_layout, AV_SAMPLE_FMT_U8, 48000, &frame->channel_layout, (AVSampleFormat)frame->format, frame->sample_rate, 0, NULL)) < 0) {
      |                                                     ^~~~~~~~~~~~~
      |                                                     |
      |                                                     SwrContext**
In file included from src/sanjuuni.cpp:30:
/usr/include/x86_64-linux-gnu/libswresample/swresample.h:250:58: note:   initializing argument 1 of ‘SwrContext* swr_alloc_set_opts(SwrContext*, int64_t, AVSampleFormat, int, int64_t, AVSampleFormat, int, int, void*)’
  250 | struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
      |                                       ~~~~~~~~~~~~~~~~~~~^
make: *** [Makefile:26: obj/sanjuuni.o] Error 1
A765-ALEX commented 2 months ago

psycho If it compiles, don't touch it

A765-ALEX commented 2 months ago

this is a pretty s**tty way to fix it, but as long as that error doesn't happen i'm fine

A765-ALEX commented 2 months ago

if anyone wants the code i'll upload it Edit: available in A765-ALEX/sanjuuni don't open issues if it doesn't work, it's meant as a temporary fix that works for me and you probably won't have audio

MCJack123 commented 2 months ago

sanjuuni 0.5 requires FFmpeg 6.0 or later to build.

This is not a correct solution - it will result in crashes when using anything that has audio. I will backport the code to work with older versions soon, considering there's been so many people complaining about it not compiling.

A765-ALEX commented 2 months ago

This is not a correct solution.

ikr? It's meant as a temporary fix, I'll just leave it if someone needs it to work on older versions without audio and archive the repo when people using older versions can compile sanjuuni properly.

nvm as I was writing I realized why this doesn't work

The version of ffmpeg required is 6.0 The latest version in Ubuntu Jammy (22.04) repos is 4.4.2

btw thanks for maintaining this 👍 edit: bolded = edit