[vlc-devel] commit: Add --sout-asf-bitrate-override setting to ASF muxer ( Georgi Chorbadzhiyski )

git version control git at videolan.org
Mon Jun 30 13:40:10 CEST 2008


vlc | branch: master | Georgi Chorbadzhiyski <gf at unixsol.org> | Mon Jun 30 12:00:34 2008 +0300| [d1e3b1c2518db752f9e31fba2219010d7188003e]

Add --sout-asf-bitrate-override setting to ASF muxer

This patch adds setting to override calculated bit rate outputted
into ASF stream. This is needed in the cases where ASF muxer
receives stream in TS (for example) and can't correctly determine
what output bit rate should be.

Windows Media Player actually uses ASF bitrate setting to calculate
how much to cache and if the output bit rate is wrong it tries to
cache too much or too little.

To test the behaviour before this patch try to stream WMV in TS
container to another VLC that remuxes it into ASF. Open the remuxed
stream into WMP and you'll see how it tries to cache 1%, 2%, 3%
and so on...

Signed-off-by: Antoine Cellerier <dionoea at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d1e3b1c2518db752f9e31fba2219010d7188003e
---

 modules/mux/asf.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/modules/mux/asf.c b/modules/mux/asf.c
index 789da06..3f41328 100644
--- a/modules/mux/asf.c
+++ b/modules/mux/asf.c
@@ -61,6 +61,9 @@ static void Close  ( vlc_object_t * );
 #define RATING_LONGTEXT N_("\"Rating\" to put in ASF comments." )
 #define PACKETSIZE_TEXT N_("Packet Size")
 #define PACKETSIZE_LONGTEXT N_("ASF packet size -- default is 4096 bytes")
+#define BITRATE_TEXT N_("Bitrate override")
+#define BITRATE_LONGTEXT N_("Do not try to guess ASF bitrate. Setting this, allows you to control how Windows Media Player will cache streamed content. Set to audio+video bitrate in bytes")
+
 
 vlc_module_begin();
     set_description( N_("ASF muxer") );
@@ -85,6 +88,8 @@ vlc_module_begin();
                                  RATING_LONGTEXT, true );
     add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT,
                                  PACKETSIZE_LONGTEXT, VLC_TRUE );
+    add_integer( SOUT_CFG_PREFIX "bitrate-override", 0, NULL, BITRATE_TEXT,
+                                 BITRATE_LONGTEXT, VLC_TRUE );
 
 vlc_module_end();
 
@@ -130,6 +135,7 @@ struct sout_mux_sys_t
     mtime_t         i_dts_last;
     mtime_t         i_preroll_time;
     int64_t         i_bitrate;
+    int64_t         i_bitrate_override;
 
     int             i_track;
     asf_track_t     track[MAX_ASF_TRACKS];
@@ -207,12 +213,16 @@ static int Open( vlc_object_t *p_this )
     p_sys->i_dts_last   = 0;
     p_sys->i_preroll_time = 2000;
     p_sys->i_bitrate    = 0;
+    p_sys->i_bitrate_override = 0;
     p_sys->i_seq        = 0;
 
     p_sys->b_write_header = true;
     p_sys->i_track = 0;
     p_sys->i_packet_size = config_GetInt( p_mux, "sout-asf-packet-size" );
+    p_sys->i_bitrate_override = config_GetInt( p_mux, "sout-asf-bitrate-override" );
     msg_Dbg( p_mux, "Packet size %d", p_sys->i_packet_size);
+    if (p_sys->i_bitrate_override)
+        msg_Dbg( p_mux, "Bitrate override %d", p_sys->i_bitrate_override);
     p_sys->i_packet_count= 0;
 
     /* Generate a random fid */
@@ -481,6 +491,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             {
                 p_sys->i_bitrate += 512000;
             }
+            if (p_sys->i_bitrate_override)
+                p_sys->i_bitrate = p_sys->i_bitrate_override;
             break;
         }
         case VIDEO_ES:
@@ -565,6 +577,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
             {
                 p_sys->i_bitrate += 1000000;
             }
+            if (p_sys->i_bitrate_override)
+                p_sys->i_bitrate = p_sys->i_bitrate_override;
             break;
         }
         default:




More information about the vlc-devel mailing list