[vlc-devel] [PATCH] asf muxer cleanup + feature
Georgi Chorbadzhiyski
gf at unixsol.org
Fri Jun 27 10:48:58 CEST 2008
Hi, attached are two patches for ASF muxer.
- asf_mux_cleanup.diff
Just a small source code cleanup.
- asf_mux_add_bitrate_override.diff
This patch add 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.
Before this patch, asf muxer just adds 512000 bytes to out bitrate
for audio stream (this is too much) and 1000000 bytes for
each ES video stream (this can be too little).
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 this behavior 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...
The --sout-asf-bitrate-override allows setting hardcoded output bit
rate into ASF basically overriding any VLC guessing work.
The two patches are against 0.8.6h but probably can be used in 0.9
as well.
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
-------------- next part --------------
diff -ur vlc-0.8.6h/modules/mux/asf.c vlc-0.8.6h-patched/modules/mux/asf.c
--- vlc-0.8.6h/modules/mux/asf.c 2008-05-25 21:28:57.000000000 +0300
+++ vlc-0.8.6h-patched/modules/mux/asf.c 2008-06-27 11:09:12.000000000 +0300
@@ -79,7 +79,8 @@
COMMENT_LONGTEXT, VLC_TRUE );
add_string( SOUT_CFG_PREFIX "rating", "", NULL, RATING_TEXT,
RATING_LONGTEXT, VLC_TRUE );
- add_integer( "sout-asf-packet-size", 4096, NULL, PACKETSIZE_TEXT, PACKETSIZE_LONGTEXT, VLC_TRUE );
+ add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT,
+ PACKETSIZE_LONGTEXT, VLC_TRUE );
vlc_module_end();
-------------- next part --------------
diff -ur vlc-0.8.6h/modules/mux/asf.c vlc-0.8.6h-patched/modules/mux/asf.c
--- vlc-0.8.6h/modules/mux/asf.c 2008-06-27 11:10:10.000000000 +0300
+++ vlc-0.8.6h-patched/modules/mux/asf.c 2008-06-27 11:29:50.000000000 +0300
@@ -57,6 +57,9 @@
#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( _("ASF muxer") );
@@ -81,6 +84,8 @@
RATING_LONGTEXT, VLC_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();
@@ -126,6 +131,7 @@
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];
@@ -203,12 +209,16 @@
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 = VLC_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 */
@@ -475,8 +485,10 @@
}
else
{
- p_sys->i_bitrate += 512000;
+ p_sys->i_bitrate += 128000;
}
+ if (p_sys->i_bitrate_override)
+ p_sys->i_bitrate = p_sys->i_bitrate_override;
break;
}
case VIDEO_ES:
@@ -559,8 +571,10 @@
}
else
{
- p_sys->i_bitrate += 1000000;
+ p_sys->i_bitrate += 512000;
}
+ 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