diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c
index 4f5c5d8..da9b16d 100644
--- a/src/modules/avformat/consumer_avformat.c
+++ b/src/modules/avformat/consumer_avformat.c
@@ -1287,6 +1287,13 @@ static void *consumer_thread( void *arg )
 			if ( !video_st || ( video_st && audio_st[0] && audio_pts < video_pts ) )
 			{
 				// Write audio
+				// Create the fifo if we don't have one
+				if ( fifo == NULL )
+				{
+					fifo = sample_fifo_init( frequency, channels );
+					mlt_properties_set_data( properties, "sample_fifo", fifo, 0, ( mlt_destructor )sample_fifo_close, NULL );
+				}
+
 				if ( ( video_st && terminated ) || ( channels * audio_input_frame_size ) < sample_fifo_used( fifo ) )
 				{
 					int j = 0; // channel offset into interleaved source buffer
@@ -1610,6 +1617,12 @@ static void *consumer_thread( void *arg )
 			av_init_packet( &pkt );
 			pkt.size = 0;
 
+			if ( fifo == NULL )
+			{
+				fifo = sample_fifo_init( frequency, channels );
+				mlt_properties_set_data( properties, "sample_fifo", fifo, 0, ( mlt_destructor )sample_fifo_close, NULL );
+			}
+
 			if ( /*( c->capabilities & CODEC_CAP_SMALL_LAST_FRAME ) &&*/
 				( channels * audio_input_frame_size < sample_fifo_used( fifo ) ) )
 			{
