if ( this != NULL )
{
// Get properties from the consumer
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Assign close callback
this->close = consumer_close;
static int consumer_start( mlt_consumer this )
{
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Check that we're not already running
if ( !mlt_properties_get_int( properties, "running" ) )
static int consumer_stop( mlt_consumer this )
{
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Check that we're running
if ( mlt_properties_get_int( properties, "running" ) )
static int consumer_is_stopped( mlt_consumer this )
{
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
return !mlt_properties_get_int( properties, "running" );
}
static AVStream *add_audio_stream( mlt_consumer this, AVFormatContext *oc, int codec_id )
{
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Create a new stream
AVStream *st = av_new_stream( oc, 1 );
static AVStream *add_video_stream( mlt_consumer this, AVFormatContext *oc, int codec_id )
{
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Create a new stream
AVStream *st = av_new_stream( oc, 0 );
mlt_consumer this = arg;
// Get the properties
- mlt_properties properties = mlt_consumer_properties( this );
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES( this );
// Get the terminate on pause property
int terminate_on_pause = mlt_properties_get_int( properties, "terminate_on_pause" );
fmt = guess_format( "mpeg", NULL, NULL );
// We need a filename - default to stdout?
- if ( filename == NULL )
+ if ( filename == NULL || !strcmp( filename, "" ) )
filename = "pipe:";
// Get the codec ids selected
// Open the output file, if needed
if ( !( fmt->flags & AVFMT_NOFILE ) )
{
- if (url_fopen(&oc->pb, filename, URL_RDWR) < 0)
+ if (url_fopen(&oc->pb, filename, URL_WRONLY) < 0)
{
fprintf(stderr, "Could not open '%s'\n", filename);
mlt_properties_set_int( properties, "running", 0 );
frames ++;
// Default audio args
- frame_properties = mlt_frame_properties( frame );
+ frame_properties = MLT_FRAME_PROPERTIES( frame );
// Check for the terminated condition
terminated = terminate_on_pause && mlt_properties_get_double( frame_properties, "_speed" ) == 0.0;
pkt.size = avcodec_encode_audio( c, audio_outbuf, audio_outbuf_size, buffer );
// Write the compressed frame in the media file
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= audio_st->index;
pkt.data= audio_outbuf;
- if ( av_write_frame( oc, &pkt ) != 0)
+ if ( av_interleaved_write_frame( oc, &pkt ) != 0)
fprintf(stderr, "Error while writing audio frame\n");
}
else
AVCodecContext *c;
frame = mlt_deque_pop_front( queue );
- frame_properties = mlt_frame_properties( frame );
+ frame_properties = MLT_FRAME_PROPERTIES( frame );
c = &video_st->codec;
uint8_t *p;
uint8_t *q;
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
+
+ // This will cause some fx to go awry....
+ if ( mlt_properties_get_int( properties, "transcode" ) )
+ {
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "normalised_width", img_height * 4.0 / 3.0 );
+ mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "normalised_height", img_height );
+ }
+
mlt_frame_get_image( frame, &image, &img_fmt, &img_width, &img_height, 0 );
q = image;
AVPacket pkt;
av_init_packet( &pkt );
- pkt.pts= c->coded_frame->pts;
+ if ( c->coded_frame )
+ pkt.pts= c->coded_frame->pts;
if(c->coded_frame->key_frame)
pkt.flags |= PKT_FLAG_KEY;
pkt.stream_index= video_st->index;
pkt.size= out_size;
// write the compressed frame in the media file
- ret = av_write_frame(oc, &pkt);
+ ret = av_interleaved_write_frame(oc, &pkt);
}
}
frame_count++;
if ( real_time_output && frames % 25 == 0 )
{
long passed = time_difference( &ante );
- long pending = ( ( ( long )sample_fifo_used( fifo ) * 1000 ) / frequency ) * 1000;
- passed -= pending;
+ if ( fifo != NULL )
+ {
+ long pending = ( ( ( long )sample_fifo_used( fifo ) * 1000 ) / frequency ) * 1000;
+ passed -= pending;
+ }
if ( passed < total_time )
{
long total = ( total_time - passed );
// Just in case we terminated on pause
mlt_properties_set_int( properties, "running", 0 );
+ mlt_consumer_stopped( this );
+
return NULL;
}