]> git.sesse.net Git - mlt/commitdiff
Fix A/V sync error accumulation in avformat consumer.
authorDan Dennedy <dan@dennedy.org>
Sat, 30 Mar 2013 04:14:23 +0000 (21:14 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 30 Mar 2013 04:14:23 +0000 (21:14 -0700)
This appears to be a long-standing problem: we were not correctly
setting the number of audio samples per frame.

src/modules/avformat/consumer_avformat.c

index e2eb0e4ac38b0944077c22fa8f0d207b5a84ffbf..2bde65bf4b1519b0a9c157df6a807b269c18ea7b 100644 (file)
@@ -1575,6 +1575,7 @@ static void *consumer_thread( void *arg )
                                                                p = interleaved_to_planar( samples, channels, p, sizeof( uint8_t ) );
 #endif
 #if LIBAVCODEC_VERSION_MAJOR >= 55
+                                                       audio_avframe->nb_samples = samples;
                                                        avcodec_fill_audio_frame( audio_avframe, codec->channels, codec->sample_fmt,
                                                                (const uint8_t*) p, AUDIO_ENCODE_BUFFER_SIZE, 0 );
                                                        int got_packet = 0;
@@ -1584,6 +1585,7 @@ static void *consumer_thread( void *arg )
                                                        else if ( !got_packet )
                                                                pkt.size = 0;
 #else
+                                                       codec->frame_size = samples;
                                                        pkt.size = avcodec_encode_audio( codec, audio_outbuf, audio_outbuf_size, p );
                                                        pkt.pts = codec->coded_frame? codec->coded_frame->pts : AV_NOPTS_VALUE;
                                                        pkt.flags |= PKT_FLAG_KEY;