From e3a9160797677ed238c6941c66dbf2a464fa062b Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Fri, 1 Oct 2021 17:10:13 -0400 Subject: [PATCH] Added more AVI audio buffer protections. --- src/drivers/Qt/AviRecord.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/drivers/Qt/AviRecord.cpp b/src/drivers/Qt/AviRecord.cpp index 48799916..f2abdff4 100644 --- a/src/drivers/Qt/AviRecord.cpp +++ b/src/drivers/Qt/AviRecord.cpp @@ -1142,6 +1142,8 @@ static int initVideoStream( const char *codec_name, OutputStream *ost ) { ost->st->time_base.num = usec; ost->st->time_base.den = 1000000u; + //ost->st->time_base.num = (16*1024*1024) >> 3; + //ost->st->time_base.den = FCEUI_GetDesiredFPS() >> 3; } c->time_base = ost->st->time_base; //c->pix_fmt = AV_PIX_FMT_YUV420P; // Every video encoder seems to accept this @@ -1449,7 +1451,12 @@ static int initAudioStream( const char *codec_name, OutputStream *ost ) if (c->codec->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) { - nb_samples = 10000; + nb_samples = audioSampleRate / 4; + + if ( nb_samples < 10000 ) + { + nb_samples = 10000; + } } else { @@ -2507,6 +2514,8 @@ void AviRecordDiskThread_t::run(void) if ( localVideoFormat == AVI_LIBAV) { LIBAV::init( width, height ); + + audioChunkSize = avgAudioPerFrame; } #endif #ifdef WIN32