--- transcode-orig.c	2009-08-31 15:49:17.259441038 +0300
+++ transcode.c	2009-08-31 14:58:08.000000000 +0300
@@ -90,6 +90,9 @@
 #define VFILTER_LONGTEXT N_( \
     "Video filters will be applied to the video streams (after overlays " \
     "are applied). You must enter a comma-separated list of filters." )
+#define ASPECT_TEXT N_("Force an output aspect ratio")
+#define ASPECT_LONGTEXT N_("Overrides and sets the video aspect flag "\
+    "in the output stream.")
 
 #define AENC_TEXT N_("Audio encoder")
 #define AENC_LONGTEXT N_( \
@@ -196,6 +199,8 @@ vlc_module_begin ()
     add_module_list( SOUT_CFG_PREFIX "vfilter", "video filter2",
                      NULL, NULL,
                      VFILTER_TEXT, VFILTER_LONGTEXT, false )
+    add_string( SOUT_CFG_PREFIX "aspect-override", NULL, NULL, ASPECT_TEXT,
+                ASPECT_LONGTEXT, false );
 
     set_section( N_("Audio"), NULL )
     add_module( SOUT_CFG_PREFIX "aenc", "encoder", NULL, NULL, AENC_TEXT,
@@ -239,7 +244,7 @@ vlc_module_end ()
 
 static const char *const ppsz_sout_options[] = {
     "venc", "vcodec", "vb",
-    "scale", "fps", "width", "height", "vfilter", "deinterlace",
+    "scale", "fps", "width", "height", "vfilter", "deinterlace", "aspect-override",
     "deinterlace-module", "threads", "hurry-up", "aenc", "acodec", "ab",
     "afilter", "samplerate", "channels", "senc", "scodec", "soverlay",
     "sfilter", "osd", "audio-sync", "high-priority", "maxwidth", "maxheight",
@@ -342,6 +347,7 @@ struct sout_stream_sys_t
     int             i_threads;
     bool            b_high_priority;
     bool            b_hurry_up;
+    int             i_aspect_override;
 
     char            *psz_vf2;
 
@@ -527,6 +533,22 @@ static int Open( vlc_object_t *p_this )
     }
     free( val.psz_string );
 
+    var_Get( p_stream, SOUT_CFG_PREFIX "aspect-override", &val );
+    p_sys->i_aspect_override = 0;
+    if( val.psz_string && *val.psz_string )
+    {
+        char *psz_parser = strchr( val.psz_string, ':' );
+        if( psz_parser )
+        {
+            *psz_parser++ = '\0';
+            p_sys->i_aspect_override = atoi( val.psz_string ) *
+                VOUT_ASPECT_FACTOR / atoi( psz_parser );
+        }
+        else msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
+
+    }
+    free( val.psz_string );
+
     var_Get( p_stream, SOUT_CFG_PREFIX "threads", &val );
     p_sys->i_threads = val.i_int;
     var_Get( p_stream, SOUT_CFG_PREFIX "high-priority", &val );
@@ -1705,8 +1727,15 @@ static void transcode_video_encoder_init
     /* Check whether a particular aspect ratio was requested */
     if( !id->p_encoder->fmt_out.video.i_aspect )
     {
-        id->p_encoder->fmt_out.video.i_aspect =
-                (int)( f_aspect * VOUT_ASPECT_FACTOR + 0.5 );
+        if( p_sys->i_aspect_override )
+        {
+            id->p_encoder->fmt_out.video.i_aspect = p_sys->i_aspect_override;
+        }
+        else
+        {
+            id->p_encoder->fmt_out.video.i_aspect =
+                 (int)( f_aspect * VOUT_ASPECT_FACTOR + 0.5 );
+        }
     }
     id->p_encoder->fmt_in.video.i_aspect =
         id->p_encoder->fmt_out.video.i_aspect;
