Fix for latest FFMpeg library.

Signed-off-by: andreili <andreil499@gmail.com>
This commit is contained in:
andreili 2025-07-29 13:52:15 +02:00
parent 400e036ea2
commit 60c41f7f48
3 changed files with 9 additions and 8 deletions

View File

@ -49,7 +49,7 @@ static int http_ffmpeg_read_from_buf(void *opaque, uint8_t *buf, int buf_size)
return buf_size; return buf_size;
} }
static int http_ffmpeg_write_to_stream(void *opaque, uint8_t *buf, int buf_size) static int http_ffmpeg_write_to_stream(void *opaque, const uint8_t *buf, int buf_size)
{ {
http_ffmpeg_status_t *status = opaque; http_ffmpeg_status_t *status = opaque;
if (!status->stream) if (!status->stream)

View File

@ -7,7 +7,7 @@
static AVRational time_base = {1, 1000LL * 1000LL}; static AVRational time_base = {1, 1000LL * 1000LL};
static unsigned avio_ctx_buffer_size = 4096; static unsigned avio_ctx_buffer_size = 4096;
static int ffmpeg_remuxer_init_avcontext(AVFormatContext **context, ffmpeg_remuxer_t *remuxer, int output, int (*packet)(void *opaque, uint8_t *buf, int buf_size)) static int ffmpeg_remuxer_init_avcontext(AVFormatContext **context, ffmpeg_remuxer_t *remuxer, int output, ffmpeg_write_packet packet_out, ffmpeg_read_packet packet_in)
{ {
uint8_t *buffer = NULL; uint8_t *buffer = NULL;
AVIOContext *avio = NULL; AVIOContext *avio = NULL;
@ -20,7 +20,7 @@ static int ffmpeg_remuxer_init_avcontext(AVFormatContext **context, ffmpeg_remux
buffer = av_malloc(buffer_size); buffer = av_malloc(buffer_size);
if (!buffer) if (!buffer)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
avio = avio_alloc_context(buffer, buffer_size, output, remuxer->opaque, output ? NULL : packet, output ? packet : NULL, NULL); avio = avio_alloc_context(buffer, buffer_size, output, remuxer->opaque, packet_in, packet_out, NULL);
if (!avio) if (!avio)
goto error; goto error;
if (output && (ret = avformat_alloc_output_context2(context, NULL, remuxer->video_format, NULL)) < 0) if (output && (ret = avformat_alloc_output_context2(context, NULL, remuxer->video_format, NULL)) < 0)
@ -106,9 +106,9 @@ int ffmpeg_remuxer_open(ffmpeg_remuxer_t *remuxer)
remuxer->packet = av_packet_alloc(); remuxer->packet = av_packet_alloc();
if (!remuxer->packet) if (!remuxer->packet)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if ((ret = ffmpeg_remuxer_init_avcontext(&remuxer->input_context, remuxer, 0, remuxer->read_packet)) < 0) if ((ret = ffmpeg_remuxer_init_avcontext(&remuxer->input_context, remuxer, 0, NULL, remuxer->read_packet)) < 0)
return ret; return ret;
if ((ret = ffmpeg_remuxer_init_avcontext(&remuxer->output_context, remuxer, 1, remuxer->write_packet)) < 0) if ((ret = ffmpeg_remuxer_init_avcontext(&remuxer->output_context, remuxer, 1, remuxer->write_packet, NULL)) < 0)
return ret; return ret;
if ((ret = avformat_open_input(&remuxer->input_context, NULL, input_format, &remuxer->input_opts)) < 0) if ((ret = avformat_open_input(&remuxer->input_context, NULL, input_format, &remuxer->input_opts)) < 0)
return ret; return ret;

View File

@ -10,15 +10,16 @@
#define FFMPEG_DATA_PACKET_EOF -1 #define FFMPEG_DATA_PACKET_EOF -1
#endif #endif
typedef int (*ffmpeg_data_packet)(void *opaque, uint8_t *buf, int buf_size); typedef int (*ffmpeg_read_packet)(void *opaque, uint8_t *buf, int buf_size);
typedef int (*ffmpeg_write_packet)(void *opaque, const uint8_t *buf, int buf_size);
typedef struct ffmpeg_remuxer_s { typedef struct ffmpeg_remuxer_s {
const char *name; const char *name;
const char *input_format; const char *input_format;
const char *video_format; const char *video_format;
void *opaque; void *opaque;
ffmpeg_data_packet read_packet; ffmpeg_read_packet read_packet;
ffmpeg_data_packet write_packet; ffmpeg_write_packet write_packet;
unsigned read_buffer_size; unsigned read_buffer_size;
unsigned write_buffer_size; unsigned write_buffer_size;