#include <sched.h>
#include <libgen.h>
#include <limits.h>
+#include <unistd.h>
#include <framework/mlt.h>
static void show_usage( char *program_name )
{
- fprintf( stderr,
+ fprintf( stdout,
"Usage: %s [options] [producer [name=value]* ]+\n"
"Options:\n"
" -attach filter[:arg] [name=value]* Attach a filter to the output\n"
basename( program_name ) );
}
-static void guess_profile( mlt_producer melt, mlt_profile profile )
-{
- mlt_frame fr = NULL;
- uint8_t *buffer;
- mlt_image_format fmt = mlt_image_yuv422;
- mlt_properties p;
- int w = profile->width;
- int h = profile->height;
-
- if ( ! mlt_service_get_frame( MLT_PRODUCER_SERVICE(melt), &fr, 0 ) && fr )
- {
- mlt_properties_set_double( MLT_FRAME_PROPERTIES( fr ), "consumer_aspect_ratio", mlt_profile_sar( profile ) );
- if ( ! mlt_frame_get_image( fr, &buffer, &fmt, &w, &h, 0 ) )
- {
- // Some source properties are not exposed until after the first get_image call.
- mlt_frame_close( fr );
- mlt_service_get_frame( MLT_PRODUCER_SERVICE(melt), &fr, 0 );
- p = MLT_FRAME_PROPERTIES( fr );
-// mlt_properties_dump(p, stderr);
- if ( mlt_properties_get_int( p, "meta.media.frame_rate_den" ) && mlt_properties_get_int( p, "meta.media.sample_aspect_den" ) )
- {
- profile->width = mlt_properties_get_int( p, "meta.media.width" );
- profile->height = mlt_properties_get_int( p, "meta.media.height" );
- profile->progressive = mlt_properties_get_int( p, "meta.media.progressive" );
- profile->frame_rate_num = mlt_properties_get_int( p, "meta.media.frame_rate_num" );
- profile->frame_rate_den = mlt_properties_get_int( p, "meta.media.frame_rate_den" );
- // AVCHD is mis-reported as double frame rate.
- if ( profile->progressive == 0 && (
- profile->frame_rate_num / profile->frame_rate_den == 50 ||
- profile->frame_rate_num / profile->frame_rate_den == 59 ) )
- profile->frame_rate_num /= 2;
- profile->sample_aspect_num = mlt_properties_get_int( p, "meta.media.sample_aspect_num" );
- profile->sample_aspect_den = mlt_properties_get_int( p, "meta.media.sample_aspect_den" );
- profile->colorspace = mlt_properties_get_int( p, "meta.media.colorspace" );
- profile->display_aspect_num = (int) ( (double) profile->sample_aspect_num * profile->width / profile->sample_aspect_den + 0.5 );
- profile->display_aspect_den = profile->height;
- free( profile->description );
- profile->description = strdup( "automatic" );
- profile->is_explicit = 0;
- }
- }
- }
- mlt_frame_close( fr );
- mlt_producer_seek( melt, 0 );
-}
-
static void query_metadata( mlt_repository repo, mlt_service_type type, const char *typestr, char *id )
{
mlt_properties metadata = mlt_repository_metadata( repo, type, id );
if ( metadata )
{
char *s = mlt_properties_serialise_yaml( metadata );
- fprintf( stderr, "%s", s );
+ fprintf( stdout, "%s", s );
free( s );
}
else
{
- fprintf( stderr, "# No metadata for %s \"%s\"\n", typestr, id );
+ fprintf( stdout, "# No metadata for %s \"%s\"\n", typestr, id );
}
}
default:
return;
}
- fprintf( stderr, "---\n%s:\n", typestr );
+ fprintf( stdout, "---\n%s:\n", typestr );
if ( services )
{
int j;
for ( j = 0; j < mlt_properties_count( services ); j++ )
- fprintf( stderr, " - %s\n", mlt_properties_get_name( services, j ) );
+ fprintf( stdout, " - %s\n", mlt_properties_get_name( services, j ) );
}
- fprintf( stderr, "...\n" );
+ fprintf( stdout, "...\n" );
}
static void query_profiles()
{
mlt_properties profiles = mlt_profile_list();
- fprintf( stderr, "---\nprofiles:\n" );
+ fprintf( stdout, "---\nprofiles:\n" );
if ( profiles )
{
int j;
for ( j = 0; j < mlt_properties_count( profiles ); j++ )
- fprintf( stderr, " - %s\n", mlt_properties_get_name( profiles, j ) );
+ fprintf( stdout, " - %s\n", mlt_properties_get_name( profiles, j ) );
}
- fprintf( stderr, "...\n" );
+ fprintf( stdout, "...\n" );
mlt_properties_close( profiles );
}
if ( profile )
{
char *s = mlt_properties_serialise_yaml( profile );
- fprintf( stderr, "%s", s );
+ fprintf( stdout, "%s", s );
free( s );
}
else
{
- fprintf( stderr, "# No metadata for profile \"%s\"\n", id );
+ fprintf( stdout, "# No metadata for profile \"%s\"\n", id );
}
mlt_properties_close( profiles );
}
static void query_presets()
{
mlt_properties presets = mlt_repository_presets();
- fprintf( stderr, "---\npresets:\n" );
+ fprintf( stdout, "---\npresets:\n" );
if ( presets )
{
int j;
for ( j = 0; j < mlt_properties_count( presets ); j++ )
- fprintf( stderr, " - %s\n", mlt_properties_get_name( presets, j ) );
+ fprintf( stdout, " - %s\n", mlt_properties_get_name( presets, j ) );
}
- fprintf( stderr, "...\n" );
+ fprintf( stdout, "...\n" );
mlt_properties_close( presets );
}
if ( preset )
{
char *s = mlt_properties_serialise_yaml( preset );
- fprintf( stderr, "%s", s );
+ fprintf( stdout, "%s", s );
free( s );
}
else
{
- fprintf( stderr, "# No metadata for preset \"%s\"\n", id );
+ fprintf( stdout, "# No metadata for preset \"%s\"\n", id );
}
mlt_properties_close( presets );
}
}
else
{
- fprintf( stderr, "# No formats - failed to load avformat consumer\n" );
+ fprintf( stdout, "# No formats - failed to load avformat consumer\n" );
}
}
}
else
{
- fprintf( stderr, "# No audio codecs - failed to load avformat consumer\n" );
+ fprintf( stdout, "# No audio codecs - failed to load avformat consumer\n" );
}
}
}
else
{
- fprintf( stderr, "# No video codecs - failed to load avformat consumer\n" );
+ fprintf( stdout, "# No video codecs - failed to load avformat consumer\n" );
}
}
query_services( repo, filter_type );
query_services( repo, producer_type );
query_services( repo, transition_type );
- fprintf( stderr, "# You can query the metadata for a specific service using:\n"
+ fprintf( stdout, "# You can query the metadata for a specific service using:\n"
"# -query <type>=<identifer>\n"
"# where <type> is one of: consumer, filter, producer, or transition.\n" );
}
}
else if ( !strcmp( argv[ i ], "-version" ) || !strcmp( argv[ i ], "--version" ) )
{
- fprintf( stderr, "MLT %s " VERSION "\n"
+ fprintf( stdout, "MLT %s " VERSION "\n"
"Copyright (C) 2002-2011 Ushodaya Enterprises Limited\n"
"<http://www.mltframework.org/>\n"
"This is free software; see the source for copying conditions. There is NO\n"
mlt_log_set_level( MLT_LOG_DEBUG );
}
}
+ if ( !is_silent && !isatty( STDIN_FILENO ) )
+ is_progress = 1;
// Create profile if not set explicitly
if ( getenv( "MLT_PROFILE" ) )
// Generate an automatic profile if needed.
if ( ! profile->is_explicit )
{
- guess_profile( melt, profile );
+ mlt_profile_from_producer( profile, melt );
mlt_producer_close( melt );
melt = mlt_factory_producer( profile, "melt", &argv[ 1 ] );
}
// Reload the consumer with the fully qualified profile.
- // The producer or guess_profile could have changed the profile.
+ // The producer or auto-profile could have changed the profile.
load_consumer( &consumer, profile, argc, argv );
// If we have no consumer, default to sdl