[vlc-devel] ffmpeg muxer and headers

Olivier Houchard cognet at ci0.org
Thu Feb 15 22:01:42 CET 2007


[I should probably just subscribe vlc-devel, please just Cc: me in your
answers in the meanwhile]

Hi guys,

The ffmpeg muxer doesn't seem to set the BLOCK_FLAG_HEADER flag before
writing the block containing the header, which will be a problem for most of
the access out modules.
The attached patch will set BLOCK_FLAG_HEADER if b_write_header is TRUE, and
calls the ffmpeg function put_flush_packet() to be sure only the header will
be written. That's a bit hackish, but given the way ffmpeg works, I can't
think of a better way to do it.

This patch, and the one I posted earlier, make me able to stream flv over http.

Regards,

Olivier
-------------- next part --------------
Index: vlc-trunk/modules/codec/ffmpeg/mux.c
===================================================================
--- vlc-trunk/modules/codec/ffmpeg/mux.c	(revision 18853)
+++ vlc-trunk/modules/codec/ffmpeg/mux.c	(working copy)
@@ -381,14 +381,16 @@
     {
         msg_Dbg( p_mux, "writing header" );
 
-        p_sys->b_write_header = VLC_FALSE;
 
         if( av_write_header( p_sys->oc ) < 0 )
         {
             msg_Err( p_mux, "could not write header" );
+            p_sys->b_write_header = VLC_FALSE;
             p_sys->b_error = VLC_TRUE;
             return VLC_EGENERIC;
         }
+        put_flush_packet(&p_sys->oc->pb);
+        p_sys->b_write_header = VLC_FALSE;
     }
 
     for( ;; )
@@ -441,6 +443,7 @@
     block_t *p_buf = block_New( p_mux->p_sout, buf_size );
     if( buf_size > 0 ) memcpy( p_buf->p_buffer, buf, buf_size );
 
+    if ( p_mux->p_sys->b_write_header) p_buf->i_flags |= BLOCK_FLAG_HEADER;
     i_ret = sout_AccessOutWrite( p_mux->p_access, p_buf );
     return i_ret ? i_ret : -1;
 }


More information about the vlc-devel mailing list