Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg 5 compatibility #36

Open
xiaoqiangwang opened this issue Jun 12, 2024 · 0 comments
Open

ffmpeg 5 compatibility #36

xiaoqiangwang opened this issue Jun 12, 2024 · 0 comments

Comments

@xiaoqiangwang
Copy link

On RHEL9 the ffmpeg package from rpmfusion has version 5.1.4. The build gives errors

../ffmpegServerApp/src/ffmpegCommon.cpp: In function ‘void ffmpegInitialise()’:
../ffmpegServerApp/src/ffmpegCommon.cpp:12:5: error: ‘avcodec_register_all’ was not declared in this scope
   12 |     avcodec_register_all();
      |     ^~~~~~~~~~~~~~~~~~~~
../ffmpegServerApp/src/ffmpegCommon.cpp:15:5: error: ‘av_register_all’ was not declared in this scope
   15 |     av_register_all();
      |     ^~~~~~~~~~~~~~~

According to https://github.com/FFmpeg/FFmpeg/blob/9fb6f024c3db2c19aca7f5f93c6843b7e5d1eecf/doc/APIchanges#L1131, these functions have been deprecated and removed later. After removing these two, there are further errors,

../ffmpegServerApp/src/ffmpegFile.cpp: In member function ‘virtual asynStatus ffmpegFile::openFile(const char*, NDFileOpenMode_t, NDArray*)’:
../ffmpegServerApp/src/ffmpegFile.cpp:50:15: error: invalid conversion from ‘const AVOutputFormat*’ to ‘AVOutputFormat*’ [-fpermissive]
   50 |     fmt = oc->oformat;
      |           ~~~~^~~~~~~
      |               |
      |               const AVOutputFormat*
../ffmpegServerApp/src/ffmpegFile.cpp:71:33: error: invalid conversion from ‘const AVCodec*’ to ‘AVCodec*’ [-fpermissive]
   71 |     codec = avcodec_find_encoder(codec_id);
      |             ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
      |                                 |
      |                                 const AVCodec*
../ffmpegServerApp/src/ffmpegFile.cpp:88:23: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
   88 |         c = video_st->codec;
      |                       ^~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:97:9: error: ‘avcodec_get_context_defaults3’ was not declared in this scope
   97 |         avcodec_get_context_defaults3(c, codec);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:150:23: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  150 |         c = video_st->codec;
      |                       ^~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:214:25: error: ‘AVPicture’ was not declared in this scope; did you mean ‘inPicture’?
  214 |         avpicture_fill((AVPicture *)scPicture,(uint8_t *)scArray->pData,c->pix_fmt,c->width,c->height);
      |                         ^~~~~~~~~
      |                         inPicture
../ffmpegServerApp/src/ffmpegFile.cpp:214:36: error: expected primary-expression before ‘)’ token
  214 |         avpicture_fill((AVPicture *)scPicture,(uint8_t *)scArray->pData,c->pix_fmt,c->width,c->height);
      |                                    ^
../ffmpegServerApp/src/ffmpegFile.cpp:214:9: error: ‘avpicture_fill’ was not declared in this scope
  214 |         avpicture_fill((AVPicture *)scPicture,(uint8_t *)scArray->pData,c->pix_fmt,c->width,c->height);
      |         ^~~~~~~~~~~~~~
../ffmpegServerApp/src/ffmpegFile.cpp: In member function ‘virtual asynStatus ffmpegFile::writeFile(NDArray*)’:
../ffmpegServerApp/src/ffmpegFile.cpp:251:19: warning: ‘void av_init_packet(AVPacket*)’ is deprecated [-Wdeprecated-declarations]
  251 |     av_init_packet(&pkt);
      |     ~~~~~~~~~~~~~~^~~~~~
In file included from /usr/include/ffmpeg/libavcodec/avcodec.h:45,
                 from ../ffmpegServerApp/src/ffmpegCommon.h:10,
                 from ../ffmpegServerApp/src/ffmpegFile.cpp:2:
/usr/include/ffmpeg/libavcodec/packet.h:512:6: note: declared here
  512 | void av_init_packet(AVPacket *pkt);
      |      ^~~~~~~~~~~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:255:11: error: ‘avcodec_encode_video2’ was not declared in this scope; did you mean ‘avcodec_encode_subtitle’?
  255 |     ret = avcodec_encode_video2(c, &pkt, this->scPicture, &got_output);
      |           ^~~~~~~~~~~~~~~~~~~~~
      |           avcodec_encode_subtitle
../ffmpegServerApp/src/ffmpegFile.cpp:263:16: error: ‘AVCodecContext’ {aka ‘struct AVCodecContext’} has no member named ‘coded_frame’
  263 |         if (c->coded_frame->key_frame)
      |                ^~~~~~~~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:274:49: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  274 |     scPicture->pts += av_rescale_q(1, video_st->codec->time_base, video_st->time_base);
      |                                                 ^~~~~
../ffmpegServerApp/src/ffmpegFile.cpp: In member function ‘virtual asynStatus ffmpegFile::closeFile()’:
../ffmpegServerApp/src/ffmpegFile.cpp:312:37: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  312 |             avcodec_close(video_st->codec);
      |                                     ^~~~~
../ffmpegServerApp/src/ffmpegFile.cpp:317:35: error: ‘AVStream’ {aka ‘struct AVStream’} has no member named ‘codec’
  317 |         av_freep(&oc->streams[i]->codec);
      |                                   ^~~~~

It seems these functions are deprecated since ffmpeg 4 and now removed in ffmpeg 5.

xiaoqiangwang added a commit to xiaoqiangwang/ffmpegServer that referenced this issue Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant