Hi,

attached patch moves header writing call after first frame received. that patch makes possible to do some additional actions on container context after receiving frame.

--
________________________________________
Maksym Veremeyenko

>From 39d389d062e2ae2ab47ae8d03adfef22f6092403 Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1.tv>
Date: Thu, 18 Sep 2014 18:49:37 +0300
Subject: [PATCH 1/3] move avformat_write_header after first frame received

---
 src/modules/avformat/consumer_avformat.c |   36 +++++++++++++++++------------
 1 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c
index b6212b9..30e74f0 100644
--- a/src/modules/avformat/consumer_avformat.c
+++ b/src/modules/avformat/consumer_avformat.c
@@ -1245,6 +1245,7 @@ static void *consumer_thread( void *arg )
 	mlt_properties frame_meta_properties = mlt_properties_new();
 	int error_count = 0;
 	int64_t synth_audio_pts = 0;
+	int header_written = 0;
 
 	// Initialize audio_st
 	int i = MAX_AUDIO_STREAMS;
@@ -1521,18 +1522,6 @@ static void *consumer_thread( void *arg )
 			}
 		}
 	
-		// Write the stream header.
-		if ( mlt_properties_get_int( properties, "running" ) )
-#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0)
-			if ( avformat_write_header( oc, NULL ) < 0 )
-#else
-			if ( av_write_header( oc ) < 0 )
-#endif
-			{
-				mlt_log_error( MLT_CONSUMER_SERVICE( consumer ), "Could not write header '%s'\n", filename );
-				mlt_events_fire( properties, "consumer-fatal-error", NULL );
-				goto on_fatal_error;
-			}
 	}
 #if LIBAVFORMAT_VERSION_INT < ((53<<16)+(2<<8)+0)
 	else
@@ -1585,12 +1574,29 @@ static void *consumer_thread( void *arg )
 		// Check that we have a frame to work with
 		if ( frame != NULL )
 		{
-			// Increment frames dispatched
-			frames ++;
-
 			// Default audio args
 			frame_properties = MLT_FRAME_PROPERTIES( frame );
 
+			// Write the stream header.
+			if ( !header_written )
+			{
+#if LIBAVFORMAT_VERSION_INT >= ((53<<16)+(2<<8)+0)
+				if ( avformat_write_header( oc, NULL ) < 0 )
+#else
+				if ( av_write_header( oc ) < 0 )
+#endif
+				{
+					mlt_log_error( MLT_CONSUMER_SERVICE( consumer ), "Could not write header '%s'\n", filename );
+					mlt_events_fire( properties, "consumer-fatal-error", NULL );
+					goto on_fatal_error;
+				}
+
+				header_written = 1;
+			}
+
+			// Increment frames dispatched
+			frames ++;
+
 			// Check for the terminated condition
 			terminated = terminate_on_pause && mlt_properties_get_double( frame_properties, "_speed" ) == 0.0;
 
-- 
1.7.7.6

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to