meetecho / janus-gateway

Janus WebRTC Server
https://janus.conf.meetecho.com
GNU General Public License v3.0
8.17k stars 2.47k forks source link

avcodec_find_encoder(AV_CODEC_ID_H264); #2833

Closed frankbuijze closed 2 years ago

frankbuijze commented 2 years ago

Platform: CentOS Stream 8 Janus: Latest version Libraries: Latest versions are compiled, and can be found by configure.

I've have found an issue with compiling post processing on CentOS Stream 8. I've used the following configure command:

./configure --disable-websockets --disable-rabbitmq --disable-mqtt --disable-unix-sockets --disable-nanomsg --disable-sample-event-handler --disable-websockets-event-handler --disable-rabbitmq-event-handler --disable-mqtt-event-handler -disable-nanomsg-event-handler --disable-gelf-event-handler --disable-plugin-audiobridge --disable-plugin-echotest --disable-plugin-recordplay --disable-plugin-sip --disable-plugin-nosip --disable-plugin-streaming --disable-plugin-textroom --disable-plugin-videocall --disable-plugin-voicemail --enable-post-processing --prefix=/opt/janus

This runs without any issues. make results in the following error. Janus compiles just fine without --enable-post-processing.

  CC       janus-version.o
  CCLD     janus
  CC       janus_cfgconv-version.o
  CCLD     janus-cfgconv
  CC       postprocessing/janus_pp_rec-pp-h264.o
postprocessing/pp-h264.c: In function ‘janus_pp_h264_create’:
postprocessing/pp-h264.c:70:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
                   ^~~~~~~~~~~~~~~~~~~~
postprocessing/pp-h264.c:77:29: error: assignment of member ‘video_codec’ in read-only object
  fctx->oformat->video_codec = codec->id;
                             ^
make[2]: *** [Makefile:2800: postprocessing/janus_pp_rec-pp-h264.o] Error 1
make[2]: Leaving directory '/usr/local/src/janus-gateway'
make[1]: *** [Makefile:3400: all-recursive] Error 1
make[1]: Leaving directory '/usr/local/src/janus-gateway'
make: *** [Makefile:1553: all] Error 2

It seems that the av is not fully initiated, and that constants are not filled or loaded. Similar issues are present for h265 and other 'codecs' post processor files.

Did I forget a switch, or is this truly a bug?

Side note: ffmpeg compiles just fine with the latest libraries.

lminiero commented 2 years ago

The codec ID is irrelevant, it looks like it's complaining about this:

postprocessing/pp-h264.c:77:29: error: assignment of member ‘video_codec’ in read-only object
  fctx->oformat->video_codec = codec->id;

What version of the library is this?

frankbuijze commented 2 years ago

A fresh compile, so my guess is the latest version is used.

lminiero commented 2 years ago

I'm not on CentOS 8 so I don't know what the latest version is :wink: If you installed it from some rpm, could you let us know the version from there? e.g.,

rpm -qi ffmpeg-devel
lminiero commented 2 years ago

On Fedora 34 I have 4.4.1 and I'm not getting this error, so I have to figure out if it's an upcoming API change that needs to be addressed.

frankbuijze commented 2 years ago

No rpm's are used. As CentOs 8 Stream does not provide those libraries. I've used the latest source code from the respective sites, to compile the libraries. They compile without errors, Janus configure script does not throw any error that libraries are missing/ wrong version.

The problem seems to be a change, where a value cannot be assigned to an object anymore, read only.

My temporary solution is a debian/ubuntu based docker container with the post processor to process the mjr-files.

lminiero commented 2 years ago

Looks like this is the commit that made oformat a const: https://github.com/FFmpeg/FFmpeg/commit/56450a0ee4fdda160f4039fc2ae33edfd27765c9 I'll have to think about how to change the way we use it.

lminiero commented 2 years ago

Looks like that line was unneeded, as removing it got me a valid mkv file anyway. Please let me know if it compiles for you now.

frankbuijze commented 2 years ago

Source code compiles without errors, but some small warnings. I will test janus-pp-rec next week

CC       postprocessing/janus_pp_rec-pp-g722.o
postprocessing/pp-g722.c: In function ‘janus_pp_g722_create’:
postprocessing/pp-g722.c:68:12: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  dec_codec = avcodec_find_decoder(codec);
            ^
  CC       postprocessing/janus_pp_rec-pp-h264.o
postprocessing/pp-h264.c: In function ‘janus_pp_h264_create’:
postprocessing/pp-h264.c:70:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H264);
                   ^~~~~~~~~~~~~~~~~~~~
  CC       postprocessing/janus_pp_rec-pp-av1.o
  CC       postprocessing/janus_pp_rec-pp-avformat.o
  CC       postprocessing/janus_pp_rec-pp-h265.o
postprocessing/pp-h265.c: In function ‘janus_pp_h265_create’:
postprocessing/pp-h265.c:70:19: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_H265);
                   ^~~~~~~~~~~~~~~~~~~~
  CC       postprocessing/janus_pp_rec-pp-opus.o