Github user sreid8 commented on a diff in the pull request:
https://github.com/apache/guacamole-server/pull/159#discussion_r173988802
--- Diff: src/guacenc/ffmpeg-compat.c ---
@@ -165,3 +197,62 @@ int guacenc_avcodec_encode_video(guacenc_video* video,
AVFrame* frame) {
#endif
}
+AVCodecContext* guacenc_build_avcodeccontext(AVStream* stream,
+ AVCodec* codec,
+ int bitrate,
+ int width,
+ int height,
+ int gop_size,
+ int qmax,
+ int qmin,
+ int pix_fmt,
+ AVRational time_base) {
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 33, 100)
+ stream->codec->bit_rate = bitrate;
+ stream->codec->width = width;
+ stream->codec->height = height;
+ stream->codec->gop_size = gop_size;
+ stream->codec->qmax = qmax;
+ stream->codec->qmin = qmin;
+ stream->codec->pix_fmt = pix_fmt;
+ stream->codec->time_base = time_base;
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(55, 44, 100)
+ stream->codec->time_base = time_base;
+#else
+ stream->time_base = time_base;
+#endif
+ return stream->codec;
+#else
+ AVCodecContext* context = avcodec_alloc_context3(codec);
+ if (context) {
+ context->bit_rate = bitrate;
+ context->width = width;
+ context->height = height;
+ context->gop_size = gop_size;
+ context->qmax = qmax;
+ context->qmin = qmin;
+ context->pix_fmt = pix_fmt;
+ context->time_base = time_base;
+ stream->time_base = time_base;
--- End diff --
Similar to my other comment above about ```codec``` being ignored, it seems
like ffmpeg is doing some soul searching about the roles of
```AVCodecContext``` and ```AVStream```. Just like the way that codec
parameters are in ```AVStream->codecpar``` in >=57.33.100 instead of
```AVCodecContext->(parameter)``` or ```AVStream->codec->(parameter)```, it
seems like they're having a hard time deciding where the ```time_base``` should
be set. So since there are some versions where it needs to be on the
```AVCodecContext``` and some on the ```AVStream```, but no cases where it
_can't_ be on both, I decided to put it on both to cover all our bases.
---