Commit d1e3b1c2 authored by Georgi Chorbadzhiyski's avatar Georgi Chorbadzhiyski Committed by Antoine Cellerier

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: default avatarAntoine Cellerier <dionoea@videolan.org>
parent fbaa0ee2
...@@ -61,6 +61,9 @@ static void Close ( vlc_object_t * ); ...@@ -61,6 +61,9 @@ static void Close ( vlc_object_t * );
#define RATING_LONGTEXT N_("\"Rating\" to put in ASF comments." ) #define RATING_LONGTEXT N_("\"Rating\" to put in ASF comments." )
#define PACKETSIZE_TEXT N_("Packet Size") #define PACKETSIZE_TEXT N_("Packet Size")
#define PACKETSIZE_LONGTEXT N_("ASF packet size -- default is 4096 bytes") #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(); vlc_module_begin();
set_description( N_("ASF muxer") ); set_description( N_("ASF muxer") );
...@@ -85,6 +88,8 @@ vlc_module_begin(); ...@@ -85,6 +88,8 @@ vlc_module_begin();
RATING_LONGTEXT, true ); RATING_LONGTEXT, true );
add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT, add_integer( SOUT_CFG_PREFIX "packet-size", 4096, NULL, PACKETSIZE_TEXT,
PACKETSIZE_LONGTEXT, VLC_TRUE ); PACKETSIZE_LONGTEXT, VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "bitrate-override", 0, NULL, BITRATE_TEXT,
BITRATE_LONGTEXT, VLC_TRUE );
vlc_module_end(); vlc_module_end();
...@@ -130,6 +135,7 @@ struct sout_mux_sys_t ...@@ -130,6 +135,7 @@ struct sout_mux_sys_t
mtime_t i_dts_last; mtime_t i_dts_last;
mtime_t i_preroll_time; mtime_t i_preroll_time;
int64_t i_bitrate; int64_t i_bitrate;
int64_t i_bitrate_override;
int i_track; int i_track;
asf_track_t track[MAX_ASF_TRACKS]; asf_track_t track[MAX_ASF_TRACKS];
...@@ -207,12 +213,16 @@ static int Open( vlc_object_t *p_this ) ...@@ -207,12 +213,16 @@ static int Open( vlc_object_t *p_this )
p_sys->i_dts_last = 0; p_sys->i_dts_last = 0;
p_sys->i_preroll_time = 2000; p_sys->i_preroll_time = 2000;
p_sys->i_bitrate = 0; p_sys->i_bitrate = 0;
p_sys->i_bitrate_override = 0;
p_sys->i_seq = 0; p_sys->i_seq = 0;
p_sys->b_write_header = true; p_sys->b_write_header = true;
p_sys->i_track = 0; p_sys->i_track = 0;
p_sys->i_packet_size = config_GetInt( p_mux, "sout-asf-packet-size" ); 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); 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; p_sys->i_packet_count= 0;
/* Generate a random fid */ /* Generate a random fid */
...@@ -481,6 +491,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -481,6 +491,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{ {
p_sys->i_bitrate += 512000; p_sys->i_bitrate += 512000;
} }
if (p_sys->i_bitrate_override)
p_sys->i_bitrate = p_sys->i_bitrate_override;
break; break;
} }
case VIDEO_ES: case VIDEO_ES:
...@@ -565,6 +577,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input ) ...@@ -565,6 +577,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
{ {
p_sys->i_bitrate += 1000000; p_sys->i_bitrate += 1000000;
} }
if (p_sys->i_bitrate_override)
p_sys->i_bitrate = p_sys->i_bitrate_override;
break; break;
} }
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment