// avformat header files
#include <libavformat/avformat.h>
+#include <libavformat/avio.h>
#ifdef SWSCALE
#include <libswscale/swscale.h>
#endif
#endif
#if LIBAVCODEC_VERSION_MAJOR >= 53
-#include <libavformat/avio.h>
#include <libavutil/opt.h>
#define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO
#define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO
return time2.tv_sec * 1000000 + time2.tv_usec - time1->tv_sec * 1000000 - time1->tv_usec;
}
-#if LIBAVFORMAT_VERSION_MAJOR > 52
static int mlt_write(void *h, uint8_t *buf, int size)
{
mlt_properties properties = (mlt_properties) h;
{
listener( owner, service, (uint8_t*) args[0], (int) args[1] );
}
-#endif
/** The main thread - the argument is simply the consumer.
audio_st[i] = NULL;
}
-#if LIBAVFORMAT_VERSION_MAJOR > 52
// Setup custom I/O if redirecting
if ( mlt_properties_get_int( properties, "redirect" ) )
{
int buffer_size = 32768;
unsigned char *buffer = av_malloc( buffer_size );
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
AVIOContext* io = avio_alloc_context( buffer, buffer_size, 1, properties, NULL, mlt_write, NULL );
-
+#else
+ ByteIOContext* io = av_alloc_put_byte( buffer, buffer_size, 1, properties, NULL, mlt_write, NULL );
+#endif
if ( buffer && io )
{
oc->pb = io;
+#if LIBAVFORMAT_VERSION_MAJOR >= 53
oc->flags |= AVFMT_FLAG_CUSTOM_IO;
+#endif
mlt_properties_set_data( properties, "avio_buffer", buffer, buffer_size, av_free, NULL );
mlt_properties_set_data( properties, "avio_context", io, 0, av_free, NULL );
mlt_events_register( properties, "avformat-write", (mlt_transmitter) write_transmitter );
mlt_log_error( MLT_CONSUMER_SERVICE(consumer), "failed to setup output redirection\n" );
}
}
- else
-#endif
// Open the output file, if needed
- if ( !( fmt->flags & AVFMT_NOFILE ) )
+ else if ( !( fmt->flags & AVFMT_NOFILE ) )
{
#if LIBAVFORMAT_VERSION_MAJOR >= 53
if ( avio_open( &oc->pb, filename, AVIO_FLAG_WRITE ) < 0 )