/*****************************************************************************
* switcher.c: MPEG2 video switcher module
*****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
#define SIZES_TEXT N_("Sizes")
#define SIZES_LONGTEXT N_( \
"List of sizes separated by colons (720x576:480x576)." )
+#define RATIO_TEXT N_("Aspect ratio")
+#define RATIO_LONGTEXT N_( \
+ "Aspect ratio (4:3, 16:9)." )
#define PORT_TEXT N_("Command UDP port")
#define PORT_LONGTEXT N_( \
"UDP port to listen to for commands." )
"Number of P frames between two I frames." )
#define QSCALE_TEXT N_("Quantizer scale")
#define QSCALE_LONGTEXT N_( \
- "" )
+ "Fixed quantizer scale to use." )
vlc_module_begin();
set_description( _("MPEG2 video switcher stream output") );
FILES_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "sizes", "", NULL, SIZES_TEXT,
SIZES_LONGTEXT, VLC_FALSE );
+ add_string( SOUT_CFG_PREFIX "aspect-ratio", "4:3", NULL, RATIO_TEXT,
+ RATIO_LONGTEXT, VLC_FALSE );
add_integer( SOUT_CFG_PREFIX "port", 5001, NULL,
PORT_TEXT, PORT_LONGTEXT, VLC_TRUE );
add_integer( SOUT_CFG_PREFIX "command", 0, NULL,
vlc_module_end();
static const char *ppsz_sout_options[] = {
- "files", "sizes", "port", "command", "gop", "qscale", NULL
+ "files", "sizes", "aspect-ratio", "port", "command", "gop", "qscale", NULL
};
struct sout_stream_sys_t
sout_stream_t *p_out;
int i_gop;
int i_qscale;
+ int i_aspect;
sout_stream_id_t *pp_audio_ids[MAX_AUDIO];
/* Pictures */
p_sys->i_nb_pictures++;
}
+ var_Get( p_stream, SOUT_CFG_PREFIX "aspect-ratio", &val );
+ if ( val.psz_string )
+ {
+ char *psz_parser = strchr( val.psz_string, ':' );
+
+ if( psz_parser )
+ {
+ *psz_parser++ = '\0';
+ p_sys->i_aspect = atoi( val.psz_string ) * VOUT_ASPECT_FACTOR
+ / atoi( psz_parser );
+ }
+ else
+ {
+ msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
+ p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
+ }
+
+ free( val.psz_string );
+ }
+ else
+ {
+ p_sys->i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
+ }
+
var_Get( p_stream, SOUT_CFG_PREFIX "port", &val );
p_sys->i_fd = net_OpenUDP( p_stream, NULL, val.i_int, NULL, 0 );
if ( p_sys->i_fd < 0 )
{
/* Create a new encoder. */
int i_ff_codec = CODEC_ID_MPEG2VIDEO;
+ int i_aspect_num, i_aspect_den;
+
if( i_ff_codec == 0 )
{
msg_Err( p_stream, "cannot find encoder" );
id->ff_enc_c->width = p_sys->p_pictures[p_sys->i_cmd-1].format.i_width;
id->ff_enc_c->height = p_sys->p_pictures[p_sys->i_cmd-1].format.i_height;
-
+ av_reduce( &i_aspect_num, &i_aspect_den,
+ p_sys->i_aspect,
+ VOUT_ASPECT_FACTOR, 1 << 30 /* something big */ );
+ av_reduce( &id->ff_enc_c->sample_aspect_ratio.num,
+ &id->ff_enc_c->sample_aspect_ratio.den,
+ i_aspect_num * (int64_t)id->ff_enc_c->height,
+ i_aspect_den * (int64_t)id->ff_enc_c->width, 1 << 30 );
+
+#if LIBAVCODEC_BUILD >= 4754
+ id->ff_enc_c->time_base.num = 1;
+ id->ff_enc_c->time_base.den = 25; /* FIXME */
+#else
id->ff_enc_c->frame_rate = 25; /* FIXME */
id->ff_enc_c->frame_rate_base = 1;
+#endif
id->ff_enc_c->gop_size = 200;
id->ff_enc_c->max_b_frames = 0;
| CODEC_FLAG_LOW_DELAY;
id->ff_enc_c->mb_decision = FF_MB_DECISION_SIMPLE;
+ id->ff_enc_c->pix_fmt = PIX_FMT_YUV420P;
if( avcodec_open( id->ff_enc_c, id->ff_enc ) )
{
p_out->i_length = p_buffer->i_length;
p_out->i_pts = p_buffer->i_dts;
p_out->i_dts = p_buffer->i_dts;
+ p_out->i_rate = p_buffer->i_rate;
switch ( id->ff_enc_c->coded_frame->pict_type )
{
p_out->i_length = p_buffer->i_length;
p_out->i_pts = p_buffer->i_dts;
p_out->i_dts = p_buffer->i_dts;
+ p_out->i_rate = p_buffer->i_rate;
block_Release( p_buffer );