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
uint8_t *p;
uint8_t *q;
+ mlt_events_fire( properties, "consumer-frame-show", frame, NULL );
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;
}