unique_ptr<Mux> create_mux(HTTPD *httpd, const AVOutputFormat *oformat, X264Encoder *x264_encoder, AudioEncoder *audio_encoder)
{
AVFormatContext *avctx = avformat_alloc_context();
- avctx->oformat = oformat;
+ avctx->oformat = const_cast<decltype(avctx->oformat)>(oformat); // const_cast is a hack to work in FFmpeg both before and after 5.0.
uint8_t *buf = (uint8_t *)av_malloc(MUX_BUFFER_SIZE);
avctx->pb = avio_alloc_context(buf, MUX_BUFFER_SIZE, 1, httpd, nullptr, nullptr, nullptr);
void VideoEncoder::open_output_stream()
{
AVFormatContext *avctx = avformat_alloc_context();
- avctx->oformat = oformat;
+ avctx->oformat = const_cast<decltype(avctx->oformat)>(oformat); // const_cast is a hack to work in FFmpeg both before and after 5.0.
uint8_t *buf = (uint8_t *)av_malloc(MUX_BUFFER_SIZE);
avctx->pb = avio_alloc_context(buf, MUX_BUFFER_SIZE, 1, this, nullptr, nullptr, nullptr);
{
AVFormatContext *format_ctx = avformat_alloc_context();
format_ctx->interrupt_callback = interrupt_cb;
+#ifdef ff_const59
+ if (avformat_open_input(&format_ctx, pathname, const_cast<ff_const59 AVInputFormat *>(fmt), options) != 0) {
+#else
if (avformat_open_input(&format_ctx, pathname, fmt, options) != 0) {
+#endif
format_ctx = nullptr;
}
return AVFormatContextWithCloser(format_ctx);
unsigned char *buf = (unsigned char *)av_malloc(buf_size);
format_ctx->pb = avio_alloc_context(buf, buf_size, /*write_flag=*/false, opaque,
read_packet, /*write_packet=*/nullptr, /*seek=*/nullptr);
+#ifdef ff_const59
+ if (avformat_open_input(&format_ctx, "", const_cast<ff_const59 AVInputFormat *>(fmt), options) != 0) {
+#else
if (avformat_open_input(&format_ctx, "", fmt, options) != 0) {
+#endif
format_ctx = nullptr;
}
return AVFormatContextWithCloser(format_ctx);