Revision 0871ae1a ffmpeg.c

View differences:

ffmpeg.c
592 592

  
593 593
        frame_bytes = enc->frame_size * 2 * enc->channels;
594 594

  
595
        while (av_fifo_read(&ost->fifo, audio_buf, frame_bytes) == 0) {
595
        while (av_fifo_size(&ost->fifo) >= frame_bytes) {
596 596
            AVPacket pkt;
597 597
            av_init_packet(&pkt);
598 598

  
599
            av_fifo_read(&ost->fifo, audio_buf, frame_bytes);
600

  
599 601
            //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
600 602

  
601 603
            ret = avcodec_encode_audio(enc, audio_out, audio_out_size,
......
1385 1387
                            if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
1386 1388
                                int fs_tmp = enc->frame_size;
1387 1389
                                enc->frame_size = fifo_bytes / (2 * enc->channels);
1388
                                if(av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes) == 0) {
1390
                                av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes);
1389 1391
                                    ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
1390
                                }
1391 1392
                                enc->frame_size = fs_tmp;
1392 1393
                            }
1393 1394
                            if(ret <= 0) {

Also available in: Unified diff