+
+ // Parse out params
+ url = strchr( url, '?' );
+ while ( url )
+ {
+ url[0] = 0;
+ char *name = strdup( ++url );
+ char *value = strchr( name, ':' );
+ if ( value )
+ {
+ value[0] = 0;
+ value++;
+ char *t = strchr( value, '&' );
+ if ( t )
+ t[0] = 0;
+ if ( !strcmp( name, "frame_rate" ) )
+ params->time_base.den = atoi( value );
+ else if ( !strcmp( name, "frame_rate_base" ) )
+ params->time_base.num = atoi( value );
+ else if ( !strcmp( name, "sample_rate" ) )
+ params->sample_rate = atoi( value );
+ else if ( !strcmp( name, "channel" ) )
+ params->channel = atoi( value );
+ else if ( !strcmp( name, "channels" ) )
+ params->channels = atoi( value );
+#if (LIBAVUTIL_VERSION_INT > ((50<<16)+(7<<8)+0))
+ else if ( !strcmp( name, "pix_fmt" ) )
+ params->pix_fmt = av_get_pix_fmt( value );
+#endif
+ else if ( !strcmp( name, "width" ) )
+ params->width = atoi( value );
+ else if ( !strcmp( name, "height" ) )
+ params->height = atoi( value );
+ else if ( !strcmp( name, "standard" ) )
+ params->standard = strdup( value );
+ }
+ free( name );
+ url = strchr( url, '&' );
+ }
+ }
+ }
+ free( protocol );
+ return result ? strdup( result ) : strdup( URL );
+}
+
+static int get_basic_info( producer_avformat self, mlt_profile profile, const char *filename )
+{
+ int error = 0;
+
+ // Get the properties
+ mlt_properties properties = MLT_PRODUCER_PROPERTIES( self->parent );
+
+ AVFormatContext *format = self->video_format;
+
+ // We will treat everything with the producer fps.
+ // TODO: make this more flexible.
+ double fps = mlt_profile_fps( profile );
+
+ // Get the duration
+ if ( !mlt_properties_get_int( properties, "_length_computed" ) )
+ {
+ // The _length_computed flag prevents overwriting explicity set length/out/eof properties
+ // when producer_open is called after initial call when restoring or reseting the producer.
+ if ( format->duration != AV_NOPTS_VALUE )
+ {
+ // This isn't going to be accurate for all formats
+ mlt_position frames = ( mlt_position )( ( ( double )format->duration / ( double )AV_TIME_BASE ) * fps );
+ mlt_properties_set_position( properties, "out", frames - 1 );
+ mlt_properties_set_position( properties, "length", frames );
+ mlt_properties_set_int( properties, "_length_computed", 1 );